[]
        
(Showing Draft Content)

PaintObject

Interface: PaintObject<T>

Core interface representing a paint object that can be rendered on canvas.

Type Parameters

T

T

The specific type of paint object (e.g., 'rectangle', 'line')

Properties

type

readonly type: T;

The type identifier of the paint object (e.g., 'line', 'rectangle')


name

readonly name: string;

The display name of the paint object


bounds

readonly bounds: Bounds;

Gets the bounding rectangle of the object in canvas coordinates


startPosition

readonly startPosition: PointLocation;

Gets the end position (particularly relevant for line objects)


endPosition

readonly endPosition: PointLocation;

Gets the end position (particularly relevant for line objects)


canvasPadding

readonly canvasPadding: number;

Returns the additional padding (in pixels) required around the object to accommodate all visual elements like styled line caps. This is useful for properly sizing the canvas when rendering this object.

Methods

draw()

draw(
   destCtx, 
   mainCtx, 
   backCtx, 
   params?): Promise<void>;

Renders the object to the specified canvas context

Parameters

destCtx

CanvasRenderingContext2D

Primary drawing context

mainCtx

CanvasRenderingContext2D

Main canvas context (for composite operations)

backCtx

CanvasRenderingContext2D

Background context (for layered rendering)

params?

PaintObjectParameters

Optional rendering parameters

Returns

Promise<void>


getContentSize()

getContentSize(ctx): Size;

Calculates the content dimensions of the object

Parameters

ctx

CanvasRenderingContext2D

Canvas context used for measurements (e.g., text metrics)

Returns

Size

Size object containing width and height


getProperty()

getProperty<K>(propertyName): any;

Retrieves a property value by name

Type Parameters

K

K extends PaintObjectPropertyName

Type of the property name

Parameters

propertyName

K

Name of the property to retrieve

Returns

any

The property value or undefined if not found


setProperty()

setProperty<K>(propertyName, value): boolean;

Updates a property value by name

Type Parameters

K

K extends PaintObjectPropertyName

Type of the property name

Parameters

propertyName

K

Name of the property to set

value

any

New value for the property

Returns

boolean

True if the property was changed, false otherwise


resetToFactoryDefaults()

resetToFactoryDefaults(): void;

Resets all user-modified properties of the object back to their registered factory default values.

Returns

void