[]
        
(Showing Draft Content)

IPaintObject

Interface: IPaintObject<T>

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

Type Parameters

T

T extends PaintObjectType = PaintObjectType

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

Properties

name

readonly name: string;

The display name of the paint object


type

readonly type: T;

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

Accessors

bounds

Get Signature

get bounds(): Bounds;

Gets the bounding rectangle of the object in canvas coordinates

Returns

Bounds

Set Signature

set bounds(bounds): void;

Sets the bounding rectangle of the object

Parameters
bounds

Bounds

New bounding rectangle dimensions and position

Returns

void


canvasPadding

Get Signature

get 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.

Returns

number


endPosition

Get Signature

get endPosition(): PointLocation;

Gets the end position (particularly relevant for line objects)

Returns

PointLocation

Set Signature

set endPosition(pos): void;

Sets the end position (particularly relevant for line objects)

Parameters
pos

PointLocation

New end position coordinates

Returns

void

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


resetToFactoryDefaults()

resetToFactoryDefaults(): void;

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

Returns

void


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