File

src/toolbox/shapes/Ellipse.ts

Index

Properties

Properties

counterclockwise
counterclockwise: boolean
Type : boolean
Optional
endAngle
endAngle: number
Type : number
radiusX
radiusX: number
Type : number
radiusY
radiusY: number
Type : number
rotation
rotation: number
Type : number
startAngle
startAngle: number
Type : number
x
x: number
Type : number
y
y: number
Type : number
import { BaseShapeTool } from "../base/BaseShapeTool";

export interface DrawEllipseOptions {
    x: number;
    y: number;
    radiusX: number;
    radiusY: number;
    rotation: number;
    startAngle: number;
    endAngle: number;
    counterclockwise?: boolean;
}

export type DrawCircleOptions = Omit<DrawEllipseOptions, "radiusX" | "radiusY" | "rotation"> & { radius: number };

export class EllipseTool extends BaseShapeTool {
    public draw(options: DrawEllipseOptions) {
        this.history.push((ctx) => {
            options.counterclockwise ??= false;
            ctx.ellipse(
                options.x,
                options.y,
                options.radiusX,
                options.radiusY,
                options.rotation,
                options.startAngle,
                options.endAngle,
                options.counterclockwise
            );
        });

        return this;
    }

    public drawCircle(options: DrawCircleOptions) {
        this.history.push((ctx) => {
            options.counterclockwise ??= false;
            ctx.arc(
                options.x,
                options.y,
                options.radius,
                options.startAngle,
                options.endAngle,
                options.counterclockwise
            );
        });

        return this;
    }
}

results matching ""

    No results matching ""