Interface Canvas
access this type via: ui.Canvas (provides, requires or uses)
Canvas defines a fundamental drawing API, typically used by a Window and offered as a painting surface to any objects on the window.
Functions
void drawRect(Rect2D rect)
void drawRectOutline(Rect2D rect)
void drawLine(Line2D line)
void drawPoint(Point2D point)
void drawPixels(PixelMap map, int x, int y, optional int rotation)
void drawPixelsEx(PixelMap map, Rect subRect, int x, int y, int scaledWidth, int scaledHeight, int rotation)
void drawText(Point2D position, Font f, char text[])
void drawTextEx(Point2D position, Font f, char text[], int rotation)
void pushSurface(Rect rect, int xscr, int yscr, byte alpha)
void popSurface()
void drawRect(Rect2D rect)
Draw a filled rectangle using the given description of size, position, and color. The 0,0 coordinate of the draw location will be relative to the surface at the top of the surface stack.
rect Description of the rectangle to draw.
void drawRectOutline(Rect2D rect)
Draw an outline rectangle using the given description of size, position, and color. The 0,0 coordinate of the draw location will be relative to the surface at the top of the surface stack.
rect Description of the rectangle to draw.
void drawLine(Line2D line)
Draw a line between two points, the given description of size, position, and color. The 0,0 coordinate of the draw location will be relative to the surface at the top of the surface stack.
line Description of the line to draw.
void drawPoint(Point2D point)
Draw a single-pixel point at the given location and with the given color. The 0,0 coordinate of the draw location will be relative to the surface at the top of the surface stack.
point Description of the point to draw.
void drawPixels(PixelMap map, int x, int y, optional int rotation)
Draw a rectangle of pixels, at the given position, with the given rotation in degrees. The 0,0 coordinate of the draw location will be relative to the surface at the top of the surface stack.
map The pixels to draw.
x The X position at which to draw the top-left of the pixel map.
y The Y position at which to draw the top-left of the pixel map.
rotation The rotation to apply to the pixel map, in degrees.
void drawPixelsEx(PixelMap map, Rect subRect, int x, int y, int scaledWidth, int scaledHeight, int rotation)
Draw a rectangle of pixels, at the given position, with the given rotation in degrees, and with the given scaling factor and clipping boundary. The 0,0 coordinate of the draw location will be relative to the surface at the top of the surface stack.
map The pixels to draw.
subRect The clipping boundary.
x The X position at which to draw the top-left of the pixel map.
y The Y position at which to draw the top-left of the pixel map.
scaledWidth The width in pixels at which to scale the image.
scaledHeight The height in pixels at which to scale the image.
rotation The rotation to apply to the pixel map, in degrees.
void drawText(Point2D position, Font f, char text[])
Draw a piece of text, at the given position, with the given font. The 0,0 coordinate of the draw location will be relative to the surface at the top of the surface stack.
position The x/y coordinate at which to draw the top left of the text.
f The font with which to draw the text.
text The text to draw.
void drawTextEx(Point2D position, Font f, char text[], int rotation)
Draw a piece of text, at the given position, with the given font, and the given rotation. The 0,0 coordinate of the draw location will be relative to the surface at the top of the surface stack.
position The x/y coordinate at which to draw the top left of the text.
f The font with which to draw the text.
text The text to draw.
rotation The rotation to apply to the text, in degrees.
void pushSurface(Rect rect, int xscr, int yscr, byte alpha)
Push a new surface to the surface stack, using the given rect instance to indicate the x/y position and width/height. Any new draw operations will take place inside this surface, and will be clipped at the surface's width/height.
rect The x/y coordinate and width/height of the surface.
xscr The amount, in pixels, by which the surface is 'scrolled' on the X-axis.
yscr The amount, in pixels, by which the surface is 'scrolled' on the Y-axis.
alpha The alpha blend to apply to elements drawn on the surface.
void popSurface()
Pop the top-most surface from the surface stack.