src/toolbox/eraser/Eraser.ts
Properties |
Methods |
|
| Public autoClear |
Default value : false
|
|
Inherited from
ToolBox
|
|
Defined in
ToolBox:9
|
| Public history |
Type : HistoryCallback[]
|
Default value : []
|
|
Inherited from
ToolBox
|
|
Defined in
ToolBox:8
|
| Public Readonly layer |
Type : Layer
|
|
Inherited from
ToolBox
|
|
Defined in
ToolBox:9
|
| Public circular | ||||
circular(options)
|
||||
|
Defined in src/toolbox/eraser/Eraser.ts:18
|
||||
|
Parameters :
Returns :
this
|
| Public rectangular | ||||||
rectangular(options: EraserOptions)
|
||||||
|
Defined in src/toolbox/eraser/Eraser.ts:11
|
||||||
|
Parameters :
Returns :
this
|
| Public render |
render()
|
|
Inherited from
ToolBox
|
|
Defined in
ToolBox:27
|
|
Returns :
void
|
| Public restore |
restore()
|
|
Inherited from
ToolBox
|
|
Defined in
ToolBox:19
|
|
Returns :
this
|
| Public save |
save()
|
|
Inherited from
ToolBox
|
|
Defined in
ToolBox:11
|
|
Returns :
this
|
import { ToolBox } from "../base/ToolBox";
export interface EraserOptions {
x: number;
y: number;
width: number;
height: number;
}
export class EraserTool extends ToolBox {
public rectangular(options: EraserOptions) {
this.history.push((ctx) => {
ctx.clearRect(options.x, options.y, options.width, options.height);
});
return this;
}
public circular(options: Omit<EraserOptions, "width" | "height"> & { radius?: number }) {
this.history.push((ctx) => {
ctx.beginPath();
ctx.arc(options.x, options.y, options.radius ?? 50, 0, 2 * Math.PI);
ctx.clip();
ctx.clearRect(0, 0, this.layer.width, this.layer.height);
ctx.closePath();
});
return this;
}
}