1 | import { Node, NodeConfig } from './Node.js';
|
---|
2 | import { Context } from './Context.js';
|
---|
3 | import { GetSet, Vector2d } from './types.js';
|
---|
4 | import { HitCanvas, SceneCanvas } from './Canvas.js';
|
---|
5 | export type ShapeConfigHandler<TTarget> = {
|
---|
6 | bivarianceHack(ctx: Context, shape: TTarget): void;
|
---|
7 | }['bivarianceHack'];
|
---|
8 | export type LineJoin = 'round' | 'bevel' | 'miter';
|
---|
9 | export type LineCap = 'butt' | 'round' | 'square';
|
---|
10 | export interface ShapeConfig extends NodeConfig {
|
---|
11 | fill?: string | CanvasGradient;
|
---|
12 | fillPatternImage?: HTMLImageElement;
|
---|
13 | fillPatternX?: number;
|
---|
14 | fillPatternY?: number;
|
---|
15 | fillPatternOffset?: Vector2d;
|
---|
16 | fillPatternOffsetX?: number;
|
---|
17 | fillPatternOffsetY?: number;
|
---|
18 | fillPatternScale?: Vector2d;
|
---|
19 | fillPatternScaleX?: number;
|
---|
20 | fillPatternScaleY?: number;
|
---|
21 | fillPatternRotation?: number;
|
---|
22 | fillPatternRepeat?: string;
|
---|
23 | fillLinearGradientStartPoint?: Vector2d;
|
---|
24 | fillLinearGradientStartPointX?: number;
|
---|
25 | fillLinearGradientStartPointY?: number;
|
---|
26 | fillLinearGradientEndPoint?: Vector2d;
|
---|
27 | fillLinearGradientEndPointX?: number;
|
---|
28 | fillLinearGradientEndPointY?: number;
|
---|
29 | fillLinearGradientColorStops?: Array<number | string>;
|
---|
30 | fillRadialGradientStartPoint?: Vector2d;
|
---|
31 | fillRadialGradientStartPointX?: number;
|
---|
32 | fillRadialGradientStartPointY?: number;
|
---|
33 | fillRadialGradientEndPoint?: Vector2d;
|
---|
34 | fillRadialGradientEndPointX?: number;
|
---|
35 | fillRadialGradientEndPointY?: number;
|
---|
36 | fillRadialGradientStartRadius?: number;
|
---|
37 | fillRadialGradientEndRadius?: number;
|
---|
38 | fillRadialGradientColorStops?: Array<number | string>;
|
---|
39 | fillEnabled?: boolean;
|
---|
40 | fillPriority?: string;
|
---|
41 | fillRule?: CanvasFillRule;
|
---|
42 | stroke?: string | CanvasGradient;
|
---|
43 | strokeWidth?: number;
|
---|
44 | fillAfterStrokeEnabled?: boolean;
|
---|
45 | hitStrokeWidth?: number | string;
|
---|
46 | strokeScaleEnabled?: boolean;
|
---|
47 | strokeHitEnabled?: boolean;
|
---|
48 | strokeEnabled?: boolean;
|
---|
49 | lineJoin?: LineJoin;
|
---|
50 | lineCap?: LineCap;
|
---|
51 | sceneFunc?: (con: Context, shape: Shape) => void;
|
---|
52 | hitFunc?: (con: Context, shape: Shape) => void;
|
---|
53 | shadowColor?: string;
|
---|
54 | shadowBlur?: number;
|
---|
55 | shadowOffset?: Vector2d;
|
---|
56 | shadowOffsetX?: number;
|
---|
57 | shadowOffsetY?: number;
|
---|
58 | shadowOpacity?: number;
|
---|
59 | shadowEnabled?: boolean;
|
---|
60 | shadowForStrokeEnabled?: boolean;
|
---|
61 | dash?: number[];
|
---|
62 | dashOffset?: number;
|
---|
63 | dashEnabled?: boolean;
|
---|
64 | perfectDrawEnabled?: boolean;
|
---|
65 | }
|
---|
66 | export interface ShapeGetClientRectConfig {
|
---|
67 | skipTransform?: boolean;
|
---|
68 | skipShadow?: boolean;
|
---|
69 | skipStroke?: boolean;
|
---|
70 | relativeTo?: Node;
|
---|
71 | }
|
---|
72 | export type FillFuncOutput = void | [Path2D | CanvasFillRule] | [Path2D, CanvasFillRule];
|
---|
73 | export declare const shapes: {
|
---|
74 | [key: string]: Shape;
|
---|
75 | };
|
---|
76 | export declare class Shape<Config extends ShapeConfig = ShapeConfig> extends Node<Config> {
|
---|
77 | _centroid: boolean;
|
---|
78 | colorKey: string;
|
---|
79 | _fillFunc: (ctx: Context) => FillFuncOutput;
|
---|
80 | _strokeFunc: (ctx: Context) => void;
|
---|
81 | _fillFuncHit: (ctx: Context) => void;
|
---|
82 | _strokeFuncHit: (ctx: Context) => void;
|
---|
83 | constructor(config?: Config);
|
---|
84 | getContext(): Context;
|
---|
85 | getCanvas(): SceneCanvas;
|
---|
86 | getSceneFunc(): any;
|
---|
87 | getHitFunc(): any;
|
---|
88 | hasShadow(): any;
|
---|
89 | _hasShadow(): boolean;
|
---|
90 | _getFillPattern(): any;
|
---|
91 | __getFillPattern(): CanvasPattern | null | undefined;
|
---|
92 | _getLinearGradient(): any;
|
---|
93 | __getLinearGradient(): CanvasGradient | undefined;
|
---|
94 | _getRadialGradient(): any;
|
---|
95 | __getRadialGradient(): CanvasGradient | undefined;
|
---|
96 | getShadowRGBA(): any;
|
---|
97 | _getShadowRGBA(): string | undefined;
|
---|
98 | hasFill(): any;
|
---|
99 | hasStroke(): any;
|
---|
100 | hasHitStroke(): any;
|
---|
101 | intersects(point: any): boolean;
|
---|
102 | destroy(): this;
|
---|
103 | _useBufferCanvas(forceFill?: boolean): boolean;
|
---|
104 | setStrokeHitEnabled(val: number): void;
|
---|
105 | getStrokeHitEnabled(): boolean;
|
---|
106 | getSelfRect(): {
|
---|
107 | x: number;
|
---|
108 | y: number;
|
---|
109 | width: number;
|
---|
110 | height: number;
|
---|
111 | };
|
---|
112 | getClientRect(config?: ShapeGetClientRectConfig): {
|
---|
113 | width: number;
|
---|
114 | height: number;
|
---|
115 | x: number;
|
---|
116 | y: number;
|
---|
117 | };
|
---|
118 | drawScene(can?: SceneCanvas, top?: Node, bufferCanvas?: SceneCanvas): this;
|
---|
119 | drawHit(can?: HitCanvas, top?: Node, skipDragCheck?: boolean): this;
|
---|
120 | drawHitFromCache(alphaThreshold?: number): this;
|
---|
121 | hasPointerCapture(pointerId: number): boolean;
|
---|
122 | setPointerCapture(pointerId: number): void;
|
---|
123 | releaseCapture(pointerId: number): void;
|
---|
124 | draggable: GetSet<boolean, this>;
|
---|
125 | embossBlend: GetSet<boolean, this>;
|
---|
126 | dash: GetSet<number[], this>;
|
---|
127 | dashEnabled: GetSet<boolean, this>;
|
---|
128 | dashOffset: GetSet<number, this>;
|
---|
129 | fill: GetSet<string | CanvasGradient, this>;
|
---|
130 | fillEnabled: GetSet<boolean, this>;
|
---|
131 | fillLinearGradientColorStops: GetSet<Array<number | string>, this>;
|
---|
132 | fillLinearGradientStartPoint: GetSet<Vector2d, this>;
|
---|
133 | fillLinearGradientStartPointX: GetSet<number, this>;
|
---|
134 | fillLinearGradientStartPointY: GetSet<number, this>;
|
---|
135 | fillLinearGradientEndPoint: GetSet<Vector2d, this>;
|
---|
136 | fillLinearGradientEndPointX: GetSet<number, this>;
|
---|
137 | fillLinearGradientEndPointY: GetSet<number, this>;
|
---|
138 | fillLinearRadialStartPoint: GetSet<Vector2d, this>;
|
---|
139 | fillLinearRadialStartPointX: GetSet<number, this>;
|
---|
140 | fillLinearRadialStartPointY: GetSet<number, this>;
|
---|
141 | fillLinearRadialEndPoint: GetSet<Vector2d, this>;
|
---|
142 | fillLinearRadialEndPointX: GetSet<number, this>;
|
---|
143 | fillLinearRadialEndPointY: GetSet<number, this>;
|
---|
144 | fillPatternImage: GetSet<HTMLImageElement | HTMLCanvasElement, this>;
|
---|
145 | fillRadialGradientStartRadius: GetSet<number, this>;
|
---|
146 | fillRadialGradientEndRadius: GetSet<number, this>;
|
---|
147 | fillRadialGradientColorStops: GetSet<Array<number | string>, this>;
|
---|
148 | fillRadialGradientStartPoint: GetSet<Vector2d, this>;
|
---|
149 | fillRadialGradientStartPointX: GetSet<number, this>;
|
---|
150 | fillRadialGradientStartPointY: GetSet<number, this>;
|
---|
151 | fillRadialGradientEndPoint: GetSet<Vector2d, this>;
|
---|
152 | fillRadialGradientEndPointX: GetSet<number, this>;
|
---|
153 | fillRadialGradientEndPointY: GetSet<number, this>;
|
---|
154 | fillPatternOffset: GetSet<Vector2d, this>;
|
---|
155 | fillPatternOffsetX: GetSet<number, this>;
|
---|
156 | fillPatternOffsetY: GetSet<number, this>;
|
---|
157 | fillPatternRepeat: GetSet<string, this>;
|
---|
158 | fillPatternRotation: GetSet<number, this>;
|
---|
159 | fillPatternScale: GetSet<Vector2d, this>;
|
---|
160 | fillPatternScaleX: GetSet<number, this>;
|
---|
161 | fillPatternScaleY: GetSet<number, this>;
|
---|
162 | fillPatternX: GetSet<number, this>;
|
---|
163 | fillPatternY: GetSet<number, this>;
|
---|
164 | fillPriority: GetSet<string, this>;
|
---|
165 | hitFunc: GetSet<ShapeConfigHandler<this>, this>;
|
---|
166 | lineCap: GetSet<LineCap, this>;
|
---|
167 | lineJoin: GetSet<LineJoin, this>;
|
---|
168 | perfectDrawEnabled: GetSet<boolean, this>;
|
---|
169 | sceneFunc: GetSet<ShapeConfigHandler<this>, this>;
|
---|
170 | shadowColor: GetSet<string, this>;
|
---|
171 | shadowEnabled: GetSet<boolean, this>;
|
---|
172 | shadowForStrokeEnabled: GetSet<boolean, this>;
|
---|
173 | shadowOffset: GetSet<Vector2d, this>;
|
---|
174 | shadowOffsetX: GetSet<number, this>;
|
---|
175 | shadowOffsetY: GetSet<number, this>;
|
---|
176 | shadowOpacity: GetSet<number, this>;
|
---|
177 | shadowBlur: GetSet<number, this>;
|
---|
178 | stroke: GetSet<string | CanvasGradient, this>;
|
---|
179 | strokeEnabled: GetSet<boolean, this>;
|
---|
180 | fillAfterStrokeEnabled: GetSet<boolean, this>;
|
---|
181 | strokeScaleEnabled: GetSet<boolean, this>;
|
---|
182 | strokeHitEnabled: GetSet<boolean, this>;
|
---|
183 | strokeWidth: GetSet<number, this>;
|
---|
184 | hitStrokeWidth: GetSet<number | 'auto', this>;
|
---|
185 | strokeLinearGradientStartPoint: GetSet<Vector2d, this>;
|
---|
186 | strokeLinearGradientEndPoint: GetSet<Vector2d, this>;
|
---|
187 | strokeLinearGradientColorStops: GetSet<Array<number | string>, this>;
|
---|
188 | }
|
---|