# PaintObject

## Content

# Interface: PaintObject&lt;T&gt;

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

### bounds

```ts
readonly bounds: Bounds;
```

Gets the bounding rectangle of the object in canvas coordinates

***

### canvasPadding

```ts
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.

***

### endPosition

```ts
readonly endPosition: PointLocation;
```

Gets the end position (particularly relevant for line objects)

***

### name

```ts
readonly name: string;
```

The display name of the paint object

***

### startPosition

```ts
readonly startPosition: PointLocation;
```

Gets the end position (particularly relevant for line objects)

***

### type

```ts
readonly type: T;
```

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

## Methods

### draw()

```ts
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`](PaintObjectParameters)

Optional rendering parameters

#### Returns

`Promise`&lt;`void`&gt;

***

### getContentSize()

```ts
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)

Size object containing width and height

***

### getProperty()

```ts
getProperty<K>(propertyName): any;
```

Retrieves a property value by name

#### Type Parameters

##### K

`K` *extends* [`PaintObjectPropertyName`](../type-aliases/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()

```ts
resetToFactoryDefaults(): void;
```

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

#### Returns

`void`

***

### setProperty()

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

Updates a property value by name

#### Type Parameters

##### K

`K` *extends* [`PaintObjectPropertyName`](../type-aliases/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
