# PaintCommand

## Content

# Interface: PaintCommand

Represents a canvas paint command, optionally supporting serialization and undo operations.

## Properties

### name

```ts
readonly name: PaintCommandName;
```

The name or type of the paint command. Used to identify and group similar command operations.

***

### point?

```ts
optional point: PointLocation;
```

Optional point location (e.g. cursor or touch position) associated with the command. This can be used for positioning or context-aware execution.

***

### trigger

```ts
trigger: PointerTriggerType;
```

The type of pointer trigger (e.g., mouse, touch, pen) that initiated this command. Helps in distinguishing user input sources.

## Methods

### clone()

```ts
clone(): PaintCommand;
```

Creates a deep copy of this command instance. Useful for storing history or duplicating commands without side effects.

#### Returns

`PaintCommand`

A new instance of the same command with cloned properties.

***

### execute()

```ts
execute(
   mainCtx, 
   backCtx, 
   options): void;
```

Executes the paint command using the provided rendering contexts.

#### Parameters

##### mainCtx

`CanvasRenderingContext2D`

The main canvas rendering context where new edits are applied.

##### backCtx

`CanvasRenderingContext2D`

The background rendering context, typically containing the base image or previous state.

##### options

[`PaintExecuteOptions`](../type-aliases/PaintExecuteOptions)

Additional configuration or context-specific options required during execution.

#### Returns

`void`
