Skip to content

ArcNode

hhh edited this page Jan 28, 2023 · 7 revisions

ArcNode

/**
 * Type of options of {@link ArcNode}.
 */
type ArcNodeOptions<Events extends CanvasNodeEvents> = (ShapeNodeOptions<Events> & Partial<{
    /**
     * The start angle of the arc. (radian)
     * @default 0
     */
    startAngle: number;
    /**
     * The end angle of the arc. (radian)
     * @default Utils.Constants.TWO_PI
     */
    endAngle: number;
    /**
     * The radius of the arc.
     * @default 0
     */
    radius: number;
    /**
     * Whether the direction is clockwise,
     * from `startAngle` to `endAngle`.
     * @default false
     */
    clockwise: boolean;
    /**
     * Whether to set `radius` to
     * `Math.min(bounds.width, bounds.height) / 2` on update.
     * (Try this with stretch options!)
     * @default false
     */
    smartSize: boolean;
}>);

/**
 * Class of arc nodes. (or circle nodes)
 */
class ArcNode<Events extends CanvasNodeEvents = CanvasNodeEvents> extends ShapeNode<Events> {

    /**
     * Constructor of {@link ArcNode}.
     */
    constructor(options?: ArcNodeOptions<Events>);

    /**
     * @override CanvasNode.tag
     */
    readonly tag: string;

    /**
     * The start angle of the arc. (radian)
     * @default 0
     */
    startAngle: number;

    /**
     * The end angle of the arc. (radian)
     * @default Utils.Constants.TWO_PI
     */
    endAngle: number;

    /**
     * The radius of the arc.
     * @default 0
     */
    radius: number;

    /**
     * Whether to set `radius` to
     * `Math.min(bounds.width, bounds.height) / 2` on update.
     * (Try this with stretch options!)
     * @default false
     */
    smartSize: boolean;

    /**
     * Whether the direction is clockwise,
     * from `startAngle` to `endAngle`.
     * @default false
     */
    clockwise: boolean;

    /**
     * @override CanvasNode.beforeUpdate
     */
    protected beforeUpdate(timeStamp: number): void;

    /**
     * @override ShapeNode.path
     */
    path(context: CanvasRenderingContext2D): void;

    /**
     * @override ShapeNode.getRecordOptions
     */
    getRecordOptions(): NodeRecordOptions;
}

Documentation of canvasom

Clone this wiki locally