src/toolbox/eraser/Eraser.ts
Properties |
| height |
height:
|
Type : number
|
| width |
width:
|
Type : number
|
| x |
x:
|
Type : number
|
| y |
y:
|
Type : number
|
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;
}
}