Canvas Toolkit
← Class index

CCanvasPaintEngine

Painting · extends CPaintEngine

Paint engine that maps Canvas Toolkit drawing operations to a 2D canvas context.

import { CCanvasPaintEngine } from "canvas-toolkit-lib";

Declared members

constructor(context: CanvasRenderingContext2D);

Creates an engine for the specified 2D rendering context.

save(): void;

Saves the canvas rendering state.

restore(): void;

Restores the most recently saved canvas rendering state.

opacity(): number;
setOpacity(opacity: number): void;
translate(x: number, y: number): void;

Translates the canvas coordinate system.

fillRect(x: number, y: number, width: number, height: number): void;

Fills a rectangle using the current fill style.

strokeRect(x: number, y: number, width: number, height: number): void;

Strokes a rectangle using the current stroke style.

clearRect(x: number, y: number, width: number, height: number): void;

Clears a rectangular area.

setFillStyle(style: string): void;

Sets the canvas fill style.

setStrokeStyle(style: string): void;

Sets the canvas stroke style.

setLineWidth(width: number): void;

Sets the canvas line width.

textWidth(text: string): number;

Returns the measured width of text using the current font.

clipRect(x: number, y: number, width: number, height: number): void;

Intersects the clipping region with a rectangle.

font(): string;

Returns the current canvas font specification.

setFont(font: string): void;

Sets the current canvas font specification.

textAlign(): CanvasTextAlign;

Returns the current text alignment.

setTextAlign(align: CanvasTextAlign): void;

Sets the current text alignment.

setTextBaseline(baseline: CanvasTextBaseline): void;

Sets the current text baseline.

textBaseline(): CanvasTextBaseline;

Returns the current text baseline.

drawLine(x1: number, y1: number, x2: number, y2: number): void;

Draws a line segment.

drawText(text: string, x: number, y: number): void;

Draws text at the specified position.

drawPixmap(pixmap: CPixmap, x: number, y: number, w: number, h: number): void;

Draws a pixmap into the specified destination rectangle.

drawEllipse(x: number, y: number, w: number, h: number): void;

Draws the outline of an ellipse.

fillEllipse(x: number, y: number, w: number, h: number): void;

Fills an ellipse.

drawRect(x: number, y: number, w: number, h: number): void;

Draws a filled and stroked rectangle.

drawRoundedRect(x: number, y: number, w: number, h: number, r: number | number[]): void;

Draws a filled and stroked rounded rectangle.