File

src/toolbox/color/BackgroundColor.ts

Extends

ToolBox

Index

Properties
Methods

Properties

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

Methods

Public fill
fill(x: number, y: number, w: number, h: number)
Parameters :
Name Type Optional
x number No
y number No
w number No
h number No
Returns : this
Public render
render()
Inherited from ToolBox
Defined in ToolBox:39
Returns : void
Public setFillColor
setFillColor(color: string | CanvasPattern | CanvasGradient)
Parameters :
Name Type Optional
color string | CanvasPattern | CanvasGradient No
Returns : this
Public setStrokeColor
setStrokeColor(color: string | CanvasPattern | CanvasGradient)
Parameters :
Name Type Optional
color string | CanvasPattern | CanvasGradient No
Returns : this
Public setStrokeWidth
setStrokeWidth(w: number)
Parameters :
Name Type Optional
w number No
Returns : this
Public stroke
stroke(x: number, y: number, w: number, h: number)
Parameters :
Name Type Optional
x number No
y number No
w number No
h number No
Returns : this
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 class BackgroundColorTool extends ToolBox {
    public setFillColor(color: string | CanvasPattern | CanvasGradient) {
        this.history.push((ctx) => {
            ctx.fillStyle = color;
        });
        return this;
    }

    public fill(x: number, y: number, w: number, h: number) {
        this.history.push((ctx) => {
            ctx.fillRect(x, y, w, h);
        });
        return this;
    }

    public stroke(x: number, y: number, w: number, h: number) {
        this.history.push((ctx) => {
            ctx.strokeRect(x, y, w, h);
        });
        return this;
    }

    public setStrokeColor(color: string | CanvasPattern | CanvasGradient) {
        this.history.push((ctx) => {
            ctx.strokeStyle = color;
        });
        return this;
    }

    public setStrokeWidth(w: number) {
        this.history.push((ctx) => {
            ctx.lineWidth = w;
        });
        return this;
    }

    public render() {
        this.layer.applyTool(this);
    }
}

results matching ""

    No results matching ""