- Main Page
- Classes
- Files
- Directories
- Related Pages

- Class List
- Class Hierarchy
- Class Members

# KrCanvas Class Reference

A Canvas is a pixel area that a client program can draw to. More...

`#include <canvas.h>`

Inheritance diagram for KrCanvas:

List of all members.

## Public Member Functions
| KrCanvas (KrCanvasResource *resource)
| Construct from a resource - if the resource changes ALL the instances change.
int | Width ()
| Width.
int | Height ()
| Height.
KrRGBA * | Pixels ()
| Note that this method is a pass through to a Canvas Resource; if you change the pixel data, all instances of the Canvas Resource will change.
void | Refresh ()
| Note that this method is a pass through to a Canvas Resource; if you change the Refresh data, all instances of the Canvas Resource will change.
virtual KrImNode * | Clone ()
| Return a copy if this object, not in a Tree().
virtual void | QueryBoundingBox (grinliz::Rectangle2I *boundingBox, int window=0)
| Get the bounding box of the image, in its current state.
virtual bool | HitTest (int x, int y, int flags, std::vector< KrImage * > *results, int window)
| Hit test this object. Returns true if there was a hit, and 'this' will be added to results.
virtual KrCanvas * | ToCanvas ()
| Return a pointer if this is a canvas.

## Detailed Description

A Canvas is a pixel area that a client program can draw to.

A Canvas has the following advantages over just drawing to the framebuffer after the engine:

- automates dirty rectangle handling
- applies color and alpha transforms like all other Kyra objects
- can have multiple instances
- depth

## Member Function Documentation

virtual KrImNode* KrCanvas::Clone | ( |  | ) | `[virtual]`

Return a copy if this object, not in a Tree().

It is return untransformed. In the case of a sprite, the action and frame will be set to the current value.

Reimplemented from KrImNode.

KrRGBA* KrCanvas::Pixels | ( |  | ) | `[inline]`

Note that this method is a pass through to a Canvas Resource; if you change the pixel data, all instances of the Canvas Resource will change.

See also:
  KrCanvasResource

virtual void KrCanvas::QueryBoundingBox | ( | grinliz::Rectangle2I * | boundingBox,
|  | int | window = `0` |
| ) |  |  | `[virtual]`

Get the bounding box of the image, in its current state.

If this is a sprite, it will be the bounding box of the current frame and action. The bounds are relative to the hotspot, so xmin and ymin will often be not zero.

The current transformation matrix will be applied, so the result may be transformed bounds.

Implements KrImage.

void KrCanvas::Refresh | ( |  | ) | `[inline]`

Note that this method is a pass through to a Canvas Resource; if you change the Refresh data, all instances of the Canvas Resource will change.

See also:
  KrCanvasResource

The documentation for this class was generated from the following file:

- canvas.h