src/toolbox/shapes/Ellipse.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 draw | ||||||
draw(options: DrawEllipseOptions)
|
||||||
|
Defined in src/toolbox/shapes/Ellipse.ts:17
|
||||||
|
Parameters :
Returns :
this
|
| Public drawCircle | ||||||
drawCircle(options: DrawCircleOptions)
|
||||||
|
Defined in src/toolbox/shapes/Ellipse.ts:35
|
||||||
|
Parameters :
Returns :
this
|
| Public addPoint |
addPoint()
|
|
Inherited from
BaseShapeTool
|
|
Defined in
BaseShapeTool:62
|
|
Returns :
this
|
| Public clip | ||||||
clip(options?: literal type)
|
||||||
|
Inherited from
BaseShapeTool
|
||||||
|
Defined in
BaseShapeTool:116
|
||||||
|
Parameters :
Returns :
this
|
| Public fill | ||||||
fill(options?: literal type)
|
||||||
|
Inherited from
BaseShapeTool
|
||||||
|
Defined in
BaseShapeTool:86
|
||||||
|
Parameters :
Returns :
this
|
| Public move |
move(x: number, y: number)
|
|
Inherited from
BaseShapeTool
|
|
Defined in
BaseShapeTool:78
|
|
Returns :
this
|
| Public removePoint |
removePoint()
|
|
Inherited from
BaseShapeTool
|
|
Defined in
BaseShapeTool:70
|
|
Returns :
this
|
| Public setDashOffset | ||||||
setDashOffset(offset: number)
|
||||||
|
Inherited from
BaseShapeTool
|
||||||
|
Defined in
BaseShapeTool:38
|
||||||
|
Parameters :
Returns :
this
|
| Public setFillColor | ||||||
setFillColor(color: string | CanvasGradient | CanvasPattern)
|
||||||
|
Inherited from
BaseShapeTool
|
||||||
|
Defined in
BaseShapeTool:6
|
||||||
|
Parameters :
Returns :
this
|
| Public setLineCap | ||||||
setLineCap(lineCapStyle: CanvasLineCap)
|
||||||
|
Inherited from
BaseShapeTool
|
||||||
|
Defined in
BaseShapeTool:30
|
||||||
|
Parameters :
Returns :
this
|
| Public setLineDash | ||||||||
setLineDash(segments: number[])
|
||||||||
|
Inherited from
BaseShapeTool
|
||||||||
|
Defined in
BaseShapeTool:108
|
||||||||
|
Parameters :
Returns :
this
|
| Public setLineJoinStyle | ||||||
setLineJoinStyle(style: "round" | "bevel" | "miter")
|
||||||
|
Inherited from
BaseShapeTool
|
||||||
|
Defined in
BaseShapeTool:46
|
||||||
|
Parameters :
Returns :
this
|
| Public setLineWidth | ||||||
setLineWidth(width: number)
|
||||||
|
Inherited from
BaseShapeTool
|
||||||
|
Defined in
BaseShapeTool:22
|
||||||
|
Parameters :
Returns :
this
|
| Public setMiterLimit | ||||||
setMiterLimit(limit: number)
|
||||||
|
Inherited from
BaseShapeTool
|
||||||
|
Defined in
BaseShapeTool:54
|
||||||
|
Parameters :
Returns :
this
|
| Public setStrokeColor | ||||||
setStrokeColor(color: string | CanvasGradient | CanvasPattern)
|
||||||
|
Inherited from
BaseShapeTool
|
||||||
|
Defined in
BaseShapeTool:14
|
||||||
|
Parameters :
Returns :
this
|
| Public stroke | ||||||
stroke(options?: literal type)
|
||||||
|
Inherited from
BaseShapeTool
|
||||||
|
Defined in
BaseShapeTool:100
|
||||||
|
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 { 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;
}
}