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

Type Parameters

  • T extends PaintObjectType = PaintObjectType

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

Hierarchy

  • IPaintObject

Properties

type: T

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

name: string

The display name of the paint object

Accessors

  • get bounds(): Bounds
  • Gets the bounding rectangle of the object in canvas coordinates

    Returns Bounds

  • set bounds(bounds: Bounds): void
  • Sets the bounding rectangle of the object

    Parameters

    • bounds: Bounds

      New bounding rectangle dimensions and position

    Returns void

  • get endPosition(): PointLocation
  • Gets the end position (particularly relevant for line objects)

    Returns PointLocation

  • set endPosition(pos: PointLocation): void
  • Sets the end position (particularly relevant for line objects)

    Parameters

    Returns void

  • 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

Methods

  • 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)

    • Optional params: PaintObjectParameters

      Optional rendering parameters

    Returns Promise<void>

  • Calculates the content dimensions of the object

    Returns

    Size object containing width and height

    Parameters

    • ctx: CanvasRenderingContext2D

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

    Returns Size

  • Retrieves a property value by name

    Returns

    The property value or undefined if not found

    Type Parameters

    Parameters

    • propertyName: K

      Name of the property to retrieve

    Returns any

  • Updates a property value by name

    Returns

    True if the property was changed, false otherwise

    Type Parameters

    Parameters

    • propertyName: K

      Name of the property to set

    • value: any

      New value for the property

    Returns boolean

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

    Returns void