Main Page   Class Hierarchy   Compound List   File List   Compound Members  

KrCanvasResource Class Reference

A Canvas is a user-draw object. More...

#include <canvasresource.h>

Inheritance diagram for KrCanvasResource::

KrResource List of all members.

Public Methods

 KrCanvasResource (const std::string &name, int width, int height, int alphaSupport)
 A Canvas Resource is NOT created by a dat file, but is created by the client program. More...

virtual U32 Type ()
 The type of the resource. ( ex, KYRATAG_SPRITE ).

virtual const std::string & TypeName ()
 The name of the type. ( ex, "Sprite" ).

virtual KrCanvasResource * ToCanvasResource ()
 Return a pointer if this is a canvas resource.

int Width ()
 Width.

int Height ()
 Height.

KrRGBAPixels ()
 Base memory of the image.

int Alpha ()
 Returns true if this canvas is constructed to use an alpha channel.

void Refresh ()
 Refresh must be called if the CanvasResource changes so that the Canvas objects can be updated. More...

virtual void CacheScale (GlFixed xScale, GlFixed yScale)
 Create a cached resourced. More...

virtual bool IsScaleCached (GlFixed xScale, GlFixed yScale)
 Check the cache for a given scale.

virtual void FreeScaleCache ()
 Free up the cache.


Detailed Description

A Canvas is a user-draw object.

But like all objects in Kyra, there is a resource and instance (Image) component.


Constructor & Destructor Documentation

KrCanvasResource::KrCanvasResource const std::string &    name,
int    width,
int    height,
int    alphaSupport
 

A Canvas Resource is NOT created by a dat file, but is created by the client program.

Once a Canvas Resource is created (and normally placed in the vault) it is used like any other resource, with the exception that a Canvas Resource can be changed at run time. You can reach in, change the pixels in the Resource, and the call Refresh(). After Refresh() is called, the Canvas's using the CanvasResource will update to reflect the new image.

Parameters:
name  A name for this resource.
width  Width of the CanvasResource, in pixels.
height  Height of the CanvasResource, in pixels.
alphaSupport  A canvas is made up of KrRGBAs. In order to use the alpha channel, the CanvasResource must be created with the alphaSupport set to true. There is a performance penalty for using the alphaSupport however, so only turn it on if needed.


Member Function Documentation

virtual void KrCanvasResource::CacheScale GlFixed    xScale,
GlFixed    yScale
[inline, virtual]
 

Create a cached resourced.

A resource can be drawn much more quickly if its scaled image is pre-calculated. This generates and scaled version of the resource and stores it for fast drawing. The cached version will always be used before a version generated on the fly.

Reimplemented from KrResource.

void KrCanvasResource::Refresh  
 

Refresh must be called if the CanvasResource changes so that the Canvas objects can be updated.

This is generally called just after writing to the canvas.


The documentation for this class was generated from the following file:
Generated on Mon Sep 15 12:01:11 2003 for Kyra by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001