konva 8.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1140 -0
- package/LICENSE +22 -0
- package/README.md +189 -0
- package/konva.js +18090 -0
- package/konva.min.js +12 -0
- package/lib/Animation.d.ts +24 -0
- package/lib/Animation.js +141 -0
- package/lib/Canvas.d.ts +32 -0
- package/lib/Canvas.js +107 -0
- package/lib/Container.d.ts +47 -0
- package/lib/Container.js +318 -0
- package/lib/Context.d.ts +76 -0
- package/lib/Context.js +520 -0
- package/lib/Core.d.ts +3 -0
- package/lib/Core.js +3 -0
- package/lib/DragAndDrop.d.ts +17 -0
- package/lib/DragAndDrop.js +104 -0
- package/lib/Factory.d.ts +11 -0
- package/lib/Factory.js +117 -0
- package/lib/FastLayer.d.ts +4 -0
- package/lib/FastLayer.js +12 -0
- package/lib/Global.d.ts +30 -0
- package/lib/Global.js +53 -0
- package/lib/Group.d.ts +6 -0
- package/lib/Group.js +13 -0
- package/lib/Layer.d.ts +60 -0
- package/lib/Layer.js +301 -0
- package/lib/Node.d.ts +318 -0
- package/lib/Node.js +1381 -0
- package/lib/PointerEvents.d.ts +11 -0
- package/lib/PointerEvents.js +37 -0
- package/lib/Shape.d.ts +184 -0
- package/lib/Shape.js +515 -0
- package/lib/Stage.d.ts +85 -0
- package/lib/Stage.js +687 -0
- package/lib/Tween.d.ts +86 -0
- package/lib/Tween.js +516 -0
- package/lib/Util.d.ts +87 -0
- package/lib/Util.js +742 -0
- package/lib/Validators.d.ts +11 -0
- package/lib/Validators.js +171 -0
- package/lib/_CoreInternals.d.ts +144 -0
- package/lib/_CoreInternals.js +34 -0
- package/lib/_FullInternals.d.ts +188 -0
- package/lib/_FullInternals.js +78 -0
- package/lib/filters/Blur.d.ts +2 -0
- package/lib/filters/Blur.js +697 -0
- package/lib/filters/Brighten.d.ts +2 -0
- package/lib/filters/Brighten.js +12 -0
- package/lib/filters/Contrast.d.ts +2 -0
- package/lib/filters/Contrast.js +34 -0
- package/lib/filters/Emboss.d.ts +2 -0
- package/lib/filters/Emboss.js +102 -0
- package/lib/filters/Enhance.d.ts +2 -0
- package/lib/filters/Enhance.js +83 -0
- package/lib/filters/Grayscale.d.ts +2 -0
- package/lib/filters/Grayscale.js +9 -0
- package/lib/filters/HSL.d.ts +2 -0
- package/lib/filters/HSL.js +24 -0
- package/lib/filters/HSV.d.ts +2 -0
- package/lib/filters/HSV.js +24 -0
- package/lib/filters/Invert.d.ts +2 -0
- package/lib/filters/Invert.js +8 -0
- package/lib/filters/Kaleidoscope.d.ts +2 -0
- package/lib/filters/Kaleidoscope.js +132 -0
- package/lib/filters/Mask.d.ts +2 -0
- package/lib/filters/Mask.js +140 -0
- package/lib/filters/Noise.d.ts +2 -0
- package/lib/filters/Noise.js +12 -0
- package/lib/filters/Pixelate.d.ts +2 -0
- package/lib/filters/Pixelate.js +60 -0
- package/lib/filters/Posterize.d.ts +2 -0
- package/lib/filters/Posterize.js +10 -0
- package/lib/filters/RGB.d.ts +2 -0
- package/lib/filters/RGB.js +39 -0
- package/lib/filters/RGBA.d.ts +2 -0
- package/lib/filters/RGBA.js +49 -0
- package/lib/filters/Sepia.d.ts +2 -0
- package/lib/filters/Sepia.js +11 -0
- package/lib/filters/Solarize.d.ts +2 -0
- package/lib/filters/Solarize.js +25 -0
- package/lib/filters/Threshold.d.ts +2 -0
- package/lib/filters/Threshold.js +10 -0
- package/lib/index-node.d.ts +2 -0
- package/lib/index-node.js +18 -0
- package/lib/index-types.d.ts +179 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/shapes/Arc.d.ts +19 -0
- package/lib/shapes/Arc.js +35 -0
- package/lib/shapes/Arrow.d.ts +24 -0
- package/lib/shapes/Arrow.js +94 -0
- package/lib/shapes/Circle.d.ts +13 -0
- package/lib/shapes/Circle.js +33 -0
- package/lib/shapes/Ellipse.d.ts +16 -0
- package/lib/shapes/Ellipse.js +37 -0
- package/lib/shapes/Image.d.ts +23 -0
- package/lib/shapes/Image.js +100 -0
- package/lib/shapes/Label.d.ts +35 -0
- package/lib/shapes/Label.js +166 -0
- package/lib/shapes/Line.d.ts +28 -0
- package/lib/shapes/Line.js +155 -0
- package/lib/shapes/Path.d.ts +37 -0
- package/lib/shapes/Path.js +627 -0
- package/lib/shapes/Rect.d.ts +9 -0
- package/lib/shapes/Rect.js +42 -0
- package/lib/shapes/RegularPolygon.d.ts +22 -0
- package/lib/shapes/RegularPolygon.js +65 -0
- package/lib/shapes/Ring.d.ts +16 -0
- package/lib/shapes/Ring.js +33 -0
- package/lib/shapes/Sprite.d.ts +30 -0
- package/lib/shapes/Sprite.js +108 -0
- package/lib/shapes/Star.d.ts +17 -0
- package/lib/shapes/Star.js +38 -0
- package/lib/shapes/Text.d.ts +59 -0
- package/lib/shapes/Text.js +347 -0
- package/lib/shapes/TextPath.d.ts +54 -0
- package/lib/shapes/TextPath.js +343 -0
- package/lib/shapes/Transformer.d.ts +112 -0
- package/lib/shapes/Transformer.js +944 -0
- package/lib/shapes/Wedge.d.ts +17 -0
- package/lib/shapes/Wedge.js +38 -0
- package/lib/types.d.ts +50 -0
- package/lib/types.js +22 -0
- package/package.json +111 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { KonvaEventObject } from './Node';
|
|
2
|
+
import { Shape } from './Shape';
|
|
3
|
+
import { Stage } from './Stage';
|
|
4
|
+
export interface KonvaPointerEvent extends KonvaEventObject<PointerEvent> {
|
|
5
|
+
pointerId: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function getCapturedShape(pointerId: number): Stage | Shape<import("./Shape").ShapeConfig>;
|
|
8
|
+
export declare function createEvent(evt: PointerEvent): KonvaPointerEvent;
|
|
9
|
+
export declare function hasPointerCapture(pointerId: number, shape: Shape | Stage): boolean;
|
|
10
|
+
export declare function setPointerCapture(pointerId: number, shape: Shape | Stage): void;
|
|
11
|
+
export declare function releaseCapture(pointerId: number, target?: Shape | Stage): void;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Konva } from './Global.js';
|
|
2
|
+
const Captures = new Map();
|
|
3
|
+
const SUPPORT_POINTER_EVENTS = Konva._global['PointerEvent'] !== undefined;
|
|
4
|
+
export function getCapturedShape(pointerId) {
|
|
5
|
+
return Captures.get(pointerId);
|
|
6
|
+
}
|
|
7
|
+
export function createEvent(evt) {
|
|
8
|
+
return {
|
|
9
|
+
evt,
|
|
10
|
+
pointerId: evt.pointerId,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export function hasPointerCapture(pointerId, shape) {
|
|
14
|
+
return Captures.get(pointerId) === shape;
|
|
15
|
+
}
|
|
16
|
+
export function setPointerCapture(pointerId, shape) {
|
|
17
|
+
releaseCapture(pointerId);
|
|
18
|
+
const stage = shape.getStage();
|
|
19
|
+
if (!stage)
|
|
20
|
+
return;
|
|
21
|
+
Captures.set(pointerId, shape);
|
|
22
|
+
if (SUPPORT_POINTER_EVENTS) {
|
|
23
|
+
shape._fire('gotpointercapture', createEvent(new PointerEvent('gotpointercapture')));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export function releaseCapture(pointerId, target) {
|
|
27
|
+
const shape = Captures.get(pointerId);
|
|
28
|
+
if (!shape)
|
|
29
|
+
return;
|
|
30
|
+
const stage = shape.getStage();
|
|
31
|
+
if (stage && stage.content) {
|
|
32
|
+
}
|
|
33
|
+
Captures.delete(pointerId);
|
|
34
|
+
if (SUPPORT_POINTER_EVENTS) {
|
|
35
|
+
shape._fire('lostpointercapture', createEvent(new PointerEvent('lostpointercapture')));
|
|
36
|
+
}
|
|
37
|
+
}
|
package/lib/Shape.d.ts
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { Node, NodeConfig } from './Node';
|
|
2
|
+
import { Context } from './Context';
|
|
3
|
+
import { GetSet, Vector2d } from './types';
|
|
4
|
+
import { HitCanvas, SceneCanvas } from './Canvas';
|
|
5
|
+
export declare type ShapeConfigHandler<TTarget> = {
|
|
6
|
+
bivarianceHack(ctx: Context, shape: TTarget): void;
|
|
7
|
+
}['bivarianceHack'];
|
|
8
|
+
export declare type LineJoin = 'round' | 'bevel' | 'miter';
|
|
9
|
+
export declare type LineCap = 'butt' | 'round' | 'square';
|
|
10
|
+
export interface ShapeConfig extends NodeConfig {
|
|
11
|
+
fill?: string;
|
|
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
|
+
stroke?: string | CanvasGradient;
|
|
42
|
+
strokeWidth?: number;
|
|
43
|
+
fillAfterStrokeEnabled?: boolean;
|
|
44
|
+
hitStrokeWidth?: number | string;
|
|
45
|
+
strokeScaleEnabled?: boolean;
|
|
46
|
+
strokeHitEnabled?: boolean;
|
|
47
|
+
strokeEnabled?: boolean;
|
|
48
|
+
lineJoin?: LineJoin;
|
|
49
|
+
lineCap?: LineCap;
|
|
50
|
+
sceneFunc?: (con: Context, shape: Shape) => void;
|
|
51
|
+
hitFunc?: (con: Context, shape: Shape) => void;
|
|
52
|
+
shadowColor?: string;
|
|
53
|
+
shadowBlur?: number;
|
|
54
|
+
shadowOffset?: Vector2d;
|
|
55
|
+
shadowOffsetX?: number;
|
|
56
|
+
shadowOffsetY?: number;
|
|
57
|
+
shadowOpacity?: number;
|
|
58
|
+
shadowEnabled?: boolean;
|
|
59
|
+
shadowForStrokeEnabled?: boolean;
|
|
60
|
+
dash?: number[];
|
|
61
|
+
dashOffset?: number;
|
|
62
|
+
dashEnabled?: boolean;
|
|
63
|
+
perfectDrawEnabled?: boolean;
|
|
64
|
+
}
|
|
65
|
+
export interface ShapeGetClientRectConfig {
|
|
66
|
+
skipTransform?: boolean;
|
|
67
|
+
skipShadow?: boolean;
|
|
68
|
+
skipStroke?: boolean;
|
|
69
|
+
relativeTo?: Node;
|
|
70
|
+
}
|
|
71
|
+
export declare const shapes: {
|
|
72
|
+
[key: string]: Shape;
|
|
73
|
+
};
|
|
74
|
+
export declare class Shape<Config extends ShapeConfig = ShapeConfig> extends Node<Config> {
|
|
75
|
+
_centroid: boolean;
|
|
76
|
+
colorKey: string;
|
|
77
|
+
_fillFunc: (ctx: Context) => void;
|
|
78
|
+
_strokeFunc: (ctx: Context) => void;
|
|
79
|
+
_fillFuncHit: (ctx: Context) => void;
|
|
80
|
+
_strokeFuncHit: (ctx: Context) => void;
|
|
81
|
+
constructor(config?: Config);
|
|
82
|
+
getContext(): Context;
|
|
83
|
+
getCanvas(): SceneCanvas;
|
|
84
|
+
getSceneFunc(): any;
|
|
85
|
+
getHitFunc(): any;
|
|
86
|
+
hasShadow(): any;
|
|
87
|
+
_hasShadow(): boolean;
|
|
88
|
+
_getFillPattern(): any;
|
|
89
|
+
__getFillPattern(): CanvasPattern;
|
|
90
|
+
_getLinearGradient(): any;
|
|
91
|
+
__getLinearGradient(): CanvasGradient;
|
|
92
|
+
_getRadialGradient(): any;
|
|
93
|
+
__getRadialGradient(): CanvasGradient;
|
|
94
|
+
getShadowRGBA(): any;
|
|
95
|
+
_getShadowRGBA(): string;
|
|
96
|
+
hasFill(): any;
|
|
97
|
+
hasStroke(): any;
|
|
98
|
+
hasHitStroke(): any;
|
|
99
|
+
intersects(point: any): boolean;
|
|
100
|
+
destroy(): this;
|
|
101
|
+
_useBufferCanvas(forceFill?: boolean): boolean;
|
|
102
|
+
setStrokeHitEnabled(val: number): void;
|
|
103
|
+
getStrokeHitEnabled(): boolean;
|
|
104
|
+
getSelfRect(): {
|
|
105
|
+
x: number;
|
|
106
|
+
y: number;
|
|
107
|
+
width: number;
|
|
108
|
+
height: number;
|
|
109
|
+
};
|
|
110
|
+
getClientRect(config?: ShapeGetClientRectConfig): {
|
|
111
|
+
width: number;
|
|
112
|
+
height: number;
|
|
113
|
+
x: number;
|
|
114
|
+
y: number;
|
|
115
|
+
};
|
|
116
|
+
drawScene(can?: SceneCanvas, top?: Node): this;
|
|
117
|
+
drawHit(can?: HitCanvas, top?: Node, skipDragCheck?: boolean): this;
|
|
118
|
+
drawHitFromCache(alphaThreshold?: number): this;
|
|
119
|
+
hasPointerCapture(pointerId: number): boolean;
|
|
120
|
+
setPointerCapture(pointerId: number): void;
|
|
121
|
+
releaseCapture(pointerId: number): void;
|
|
122
|
+
draggable: GetSet<boolean, this>;
|
|
123
|
+
embossBlend: GetSet<boolean, this>;
|
|
124
|
+
dash: GetSet<number[], this>;
|
|
125
|
+
dashEnabled: GetSet<boolean, this>;
|
|
126
|
+
dashOffset: GetSet<number, this>;
|
|
127
|
+
fill: GetSet<string, this>;
|
|
128
|
+
fillEnabled: GetSet<boolean, this>;
|
|
129
|
+
fillLinearGradientColorStops: GetSet<Array<number | string>, this>;
|
|
130
|
+
fillLinearGradientStartPoint: GetSet<Vector2d, this>;
|
|
131
|
+
fillLinearGradientStartPointX: GetSet<number, this>;
|
|
132
|
+
fillLinearGradientStartPointY: GetSet<number, this>;
|
|
133
|
+
fillLinearGradientEndPoint: GetSet<Vector2d, this>;
|
|
134
|
+
fillLinearGradientEndPointX: GetSet<number, this>;
|
|
135
|
+
fillLinearGradientEndPointY: GetSet<number, this>;
|
|
136
|
+
fillLinearRadialStartPoint: GetSet<Vector2d, this>;
|
|
137
|
+
fillLinearRadialStartPointX: GetSet<number, this>;
|
|
138
|
+
fillLinearRadialStartPointY: GetSet<number, this>;
|
|
139
|
+
fillLinearRadialEndPoint: GetSet<Vector2d, this>;
|
|
140
|
+
fillLinearRadialEndPointX: GetSet<number, this>;
|
|
141
|
+
fillLinearRadialEndPointY: GetSet<number, this>;
|
|
142
|
+
fillPatternImage: GetSet<HTMLImageElement | HTMLCanvasElement, this>;
|
|
143
|
+
fillRadialGradientStartRadius: GetSet<number, this>;
|
|
144
|
+
fillRadialGradientEndRadius: GetSet<number, this>;
|
|
145
|
+
fillRadialGradientColorStops: GetSet<Array<number | string>, this>;
|
|
146
|
+
fillRadialGradientStartPoint: GetSet<Vector2d, this>;
|
|
147
|
+
fillRadialGradientStartPointX: GetSet<number, this>;
|
|
148
|
+
fillRadialGradientStartPointY: GetSet<number, this>;
|
|
149
|
+
fillRadialGradientEndPoint: GetSet<Vector2d, this>;
|
|
150
|
+
fillRadialGradientEndPointX: GetSet<number, this>;
|
|
151
|
+
fillRadialGradientEndPointY: GetSet<number, this>;
|
|
152
|
+
fillPatternOffset: GetSet<Vector2d, this>;
|
|
153
|
+
fillPatternOffsetX: GetSet<number, this>;
|
|
154
|
+
fillPatternOffsetY: GetSet<number, this>;
|
|
155
|
+
fillPatternRepeat: GetSet<string, this>;
|
|
156
|
+
fillPatternRotation: GetSet<number, this>;
|
|
157
|
+
fillPatternScale: GetSet<Vector2d, this>;
|
|
158
|
+
fillPatternScaleX: GetSet<number, this>;
|
|
159
|
+
fillPatternScaleY: GetSet<number, this>;
|
|
160
|
+
fillPatternX: GetSet<number, this>;
|
|
161
|
+
fillPatternY: GetSet<number, this>;
|
|
162
|
+
fillPriority: GetSet<string, this>;
|
|
163
|
+
hitFunc: GetSet<ShapeConfigHandler<this>, this>;
|
|
164
|
+
lineCap: GetSet<LineCap, this>;
|
|
165
|
+
lineJoin: GetSet<LineJoin, this>;
|
|
166
|
+
perfectDrawEnabled: GetSet<boolean, this>;
|
|
167
|
+
sceneFunc: GetSet<ShapeConfigHandler<this>, this>;
|
|
168
|
+
shadowColor: GetSet<string, this>;
|
|
169
|
+
shadowEnabled: GetSet<boolean, this>;
|
|
170
|
+
shadowForStrokeEnabled: GetSet<boolean, this>;
|
|
171
|
+
shadowOffset: GetSet<Vector2d, this>;
|
|
172
|
+
shadowOffsetX: GetSet<number, this>;
|
|
173
|
+
shadowOffsetY: GetSet<number, this>;
|
|
174
|
+
shadowOpacity: GetSet<number, this>;
|
|
175
|
+
shadowBlur: GetSet<number, this>;
|
|
176
|
+
stroke: GetSet<string, this>;
|
|
177
|
+
strokeEnabled: GetSet<boolean, this>;
|
|
178
|
+
fillAfterStrokeEnabled: GetSet<boolean, this>;
|
|
179
|
+
strokeScaleEnabled: GetSet<boolean, this>;
|
|
180
|
+
strokeHitEnabled: GetSet<boolean, this>;
|
|
181
|
+
strokeWidth: GetSet<number, this>;
|
|
182
|
+
hitStrokeWidth: GetSet<number | 'auto', this>;
|
|
183
|
+
strokeLinearGradientColorStops: GetSet<Array<number | string>, this>;
|
|
184
|
+
}
|
package/lib/Shape.js
ADDED
|
@@ -0,0 +1,515 @@
|
|
|
1
|
+
import { Konva } from './Global.js';
|
|
2
|
+
import { Transform, Util } from './Util.js';
|
|
3
|
+
import { Factory } from './Factory.js';
|
|
4
|
+
import { Node } from './Node.js';
|
|
5
|
+
import { getNumberValidator, getNumberOrAutoValidator, getStringValidator, getBooleanValidator, getStringOrGradientValidator, } from './Validators.js';
|
|
6
|
+
import { _registerNode } from './Global.js';
|
|
7
|
+
import * as PointerEvents from './PointerEvents.js';
|
|
8
|
+
var HAS_SHADOW = 'hasShadow';
|
|
9
|
+
var SHADOW_RGBA = 'shadowRGBA';
|
|
10
|
+
var patternImage = 'patternImage';
|
|
11
|
+
var linearGradient = 'linearGradient';
|
|
12
|
+
var radialGradient = 'radialGradient';
|
|
13
|
+
let dummyContext;
|
|
14
|
+
function getDummyContext() {
|
|
15
|
+
if (dummyContext) {
|
|
16
|
+
return dummyContext;
|
|
17
|
+
}
|
|
18
|
+
dummyContext = Util.createCanvasElement().getContext('2d');
|
|
19
|
+
return dummyContext;
|
|
20
|
+
}
|
|
21
|
+
export const shapes = {};
|
|
22
|
+
function _fillFunc(context) {
|
|
23
|
+
context.fill();
|
|
24
|
+
}
|
|
25
|
+
function _strokeFunc(context) {
|
|
26
|
+
context.stroke();
|
|
27
|
+
}
|
|
28
|
+
function _fillFuncHit(context) {
|
|
29
|
+
context.fill();
|
|
30
|
+
}
|
|
31
|
+
function _strokeFuncHit(context) {
|
|
32
|
+
context.stroke();
|
|
33
|
+
}
|
|
34
|
+
function _clearHasShadowCache() {
|
|
35
|
+
this._clearCache(HAS_SHADOW);
|
|
36
|
+
}
|
|
37
|
+
function _clearGetShadowRGBACache() {
|
|
38
|
+
this._clearCache(SHADOW_RGBA);
|
|
39
|
+
}
|
|
40
|
+
function _clearFillPatternCache() {
|
|
41
|
+
this._clearCache(patternImage);
|
|
42
|
+
}
|
|
43
|
+
function _clearLinearGradientCache() {
|
|
44
|
+
this._clearCache(linearGradient);
|
|
45
|
+
}
|
|
46
|
+
function _clearRadialGradientCache() {
|
|
47
|
+
this._clearCache(radialGradient);
|
|
48
|
+
}
|
|
49
|
+
export class Shape extends Node {
|
|
50
|
+
constructor(config) {
|
|
51
|
+
super(config);
|
|
52
|
+
let key;
|
|
53
|
+
while (true) {
|
|
54
|
+
key = Util.getRandomColor();
|
|
55
|
+
if (key && !(key in shapes)) {
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
this.colorKey = key;
|
|
60
|
+
shapes[key] = this;
|
|
61
|
+
}
|
|
62
|
+
getContext() {
|
|
63
|
+
Util.warn('shape.getContext() method is deprecated. Please do not use it.');
|
|
64
|
+
return this.getLayer().getContext();
|
|
65
|
+
}
|
|
66
|
+
getCanvas() {
|
|
67
|
+
Util.warn('shape.getCanvas() method is deprecated. Please do not use it.');
|
|
68
|
+
return this.getLayer().getCanvas();
|
|
69
|
+
}
|
|
70
|
+
getSceneFunc() {
|
|
71
|
+
return this.attrs.sceneFunc || this['_sceneFunc'];
|
|
72
|
+
}
|
|
73
|
+
getHitFunc() {
|
|
74
|
+
return this.attrs.hitFunc || this['_hitFunc'];
|
|
75
|
+
}
|
|
76
|
+
hasShadow() {
|
|
77
|
+
return this._getCache(HAS_SHADOW, this._hasShadow);
|
|
78
|
+
}
|
|
79
|
+
_hasShadow() {
|
|
80
|
+
return (this.shadowEnabled() &&
|
|
81
|
+
this.shadowOpacity() !== 0 &&
|
|
82
|
+
!!(this.shadowColor() ||
|
|
83
|
+
this.shadowBlur() ||
|
|
84
|
+
this.shadowOffsetX() ||
|
|
85
|
+
this.shadowOffsetY()));
|
|
86
|
+
}
|
|
87
|
+
_getFillPattern() {
|
|
88
|
+
return this._getCache(patternImage, this.__getFillPattern);
|
|
89
|
+
}
|
|
90
|
+
__getFillPattern() {
|
|
91
|
+
if (this.fillPatternImage()) {
|
|
92
|
+
var ctx = getDummyContext();
|
|
93
|
+
const pattern = ctx.createPattern(this.fillPatternImage(), this.fillPatternRepeat() || 'repeat');
|
|
94
|
+
if (pattern && pattern.setTransform) {
|
|
95
|
+
const tr = new Transform();
|
|
96
|
+
tr.translate(this.fillPatternX(), this.fillPatternY());
|
|
97
|
+
tr.rotate(Konva.getAngle(this.fillPatternRotation()));
|
|
98
|
+
tr.scale(this.fillPatternScaleX(), this.fillPatternScaleY());
|
|
99
|
+
tr.translate(-1 * this.fillPatternOffsetX(), -1 * this.fillPatternOffsetY());
|
|
100
|
+
const m = tr.getMatrix();
|
|
101
|
+
pattern.setTransform({
|
|
102
|
+
a: m[0],
|
|
103
|
+
b: m[1],
|
|
104
|
+
c: m[2],
|
|
105
|
+
d: m[3],
|
|
106
|
+
e: m[4],
|
|
107
|
+
f: m[5],
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
return pattern;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
_getLinearGradient() {
|
|
114
|
+
return this._getCache(linearGradient, this.__getLinearGradient);
|
|
115
|
+
}
|
|
116
|
+
__getLinearGradient() {
|
|
117
|
+
var colorStops = this.fillLinearGradientColorStops();
|
|
118
|
+
if (colorStops) {
|
|
119
|
+
var ctx = getDummyContext();
|
|
120
|
+
var start = this.fillLinearGradientStartPoint();
|
|
121
|
+
var end = this.fillLinearGradientEndPoint();
|
|
122
|
+
var grd = ctx.createLinearGradient(start.x, start.y, end.x, end.y);
|
|
123
|
+
for (var n = 0; n < colorStops.length; n += 2) {
|
|
124
|
+
grd.addColorStop(colorStops[n], colorStops[n + 1]);
|
|
125
|
+
}
|
|
126
|
+
return grd;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
_getRadialGradient() {
|
|
130
|
+
return this._getCache(radialGradient, this.__getRadialGradient);
|
|
131
|
+
}
|
|
132
|
+
__getRadialGradient() {
|
|
133
|
+
var colorStops = this.fillRadialGradientColorStops();
|
|
134
|
+
if (colorStops) {
|
|
135
|
+
var ctx = getDummyContext();
|
|
136
|
+
var start = this.fillRadialGradientStartPoint();
|
|
137
|
+
var end = this.fillRadialGradientEndPoint();
|
|
138
|
+
var grd = ctx.createRadialGradient(start.x, start.y, this.fillRadialGradientStartRadius(), end.x, end.y, this.fillRadialGradientEndRadius());
|
|
139
|
+
for (var n = 0; n < colorStops.length; n += 2) {
|
|
140
|
+
grd.addColorStop(colorStops[n], colorStops[n + 1]);
|
|
141
|
+
}
|
|
142
|
+
return grd;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
getShadowRGBA() {
|
|
146
|
+
return this._getCache(SHADOW_RGBA, this._getShadowRGBA);
|
|
147
|
+
}
|
|
148
|
+
_getShadowRGBA() {
|
|
149
|
+
if (this.hasShadow()) {
|
|
150
|
+
var rgba = Util.colorToRGBA(this.shadowColor());
|
|
151
|
+
return ('rgba(' +
|
|
152
|
+
rgba.r +
|
|
153
|
+
',' +
|
|
154
|
+
rgba.g +
|
|
155
|
+
',' +
|
|
156
|
+
rgba.b +
|
|
157
|
+
',' +
|
|
158
|
+
rgba.a * (this.shadowOpacity() || 1) +
|
|
159
|
+
')');
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
hasFill() {
|
|
163
|
+
return this._calculate('hasFill', [
|
|
164
|
+
'fillEnabled',
|
|
165
|
+
'fill',
|
|
166
|
+
'fillPatternImage',
|
|
167
|
+
'fillLinearGradientColorStops',
|
|
168
|
+
'fillRadialGradientColorStops',
|
|
169
|
+
], () => {
|
|
170
|
+
return (this.fillEnabled() &&
|
|
171
|
+
!!(this.fill() ||
|
|
172
|
+
this.fillPatternImage() ||
|
|
173
|
+
this.fillLinearGradientColorStops() ||
|
|
174
|
+
this.fillRadialGradientColorStops()));
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
hasStroke() {
|
|
178
|
+
return this._calculate('hasStroke', [
|
|
179
|
+
'strokeEnabled',
|
|
180
|
+
'strokeWidth',
|
|
181
|
+
'stroke',
|
|
182
|
+
'strokeLinearGradientColorStops',
|
|
183
|
+
], () => {
|
|
184
|
+
return (this.strokeEnabled() &&
|
|
185
|
+
this.strokeWidth() &&
|
|
186
|
+
!!(this.stroke() || this.strokeLinearGradientColorStops()));
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
hasHitStroke() {
|
|
190
|
+
const width = this.hitStrokeWidth();
|
|
191
|
+
if (width === 'auto') {
|
|
192
|
+
return this.hasStroke();
|
|
193
|
+
}
|
|
194
|
+
return this.strokeEnabled() && !!width;
|
|
195
|
+
}
|
|
196
|
+
intersects(point) {
|
|
197
|
+
var stage = this.getStage(), bufferHitCanvas = stage.bufferHitCanvas, p;
|
|
198
|
+
bufferHitCanvas.getContext().clear();
|
|
199
|
+
this.drawHit(bufferHitCanvas, null, true);
|
|
200
|
+
p = bufferHitCanvas.context.getImageData(Math.round(point.x), Math.round(point.y), 1, 1).data;
|
|
201
|
+
return p[3] > 0;
|
|
202
|
+
}
|
|
203
|
+
destroy() {
|
|
204
|
+
Node.prototype.destroy.call(this);
|
|
205
|
+
delete shapes[this.colorKey];
|
|
206
|
+
delete this.colorKey;
|
|
207
|
+
return this;
|
|
208
|
+
}
|
|
209
|
+
_useBufferCanvas(forceFill) {
|
|
210
|
+
var _a;
|
|
211
|
+
if (!this.getStage()) {
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
const perfectDrawEnabled = (_a = this.attrs.perfectDrawEnabled) !== null && _a !== void 0 ? _a : true;
|
|
215
|
+
if (!perfectDrawEnabled) {
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
const hasFill = forceFill || this.hasFill();
|
|
219
|
+
const hasStroke = this.hasStroke();
|
|
220
|
+
const isTransparent = this.getAbsoluteOpacity() !== 1;
|
|
221
|
+
if (hasFill && hasStroke && isTransparent) {
|
|
222
|
+
return true;
|
|
223
|
+
}
|
|
224
|
+
const hasShadow = this.hasShadow();
|
|
225
|
+
const strokeForShadow = this.shadowForStrokeEnabled();
|
|
226
|
+
if (hasFill && hasStroke && hasShadow && strokeForShadow) {
|
|
227
|
+
return true;
|
|
228
|
+
}
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
231
|
+
setStrokeHitEnabled(val) {
|
|
232
|
+
Util.warn('strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead.');
|
|
233
|
+
if (val) {
|
|
234
|
+
this.hitStrokeWidth('auto');
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
this.hitStrokeWidth(0);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
getStrokeHitEnabled() {
|
|
241
|
+
if (this.hitStrokeWidth() === 0) {
|
|
242
|
+
return false;
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
return true;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
getSelfRect() {
|
|
249
|
+
var size = this.size();
|
|
250
|
+
return {
|
|
251
|
+
x: this._centroid ? -size.width / 2 : 0,
|
|
252
|
+
y: this._centroid ? -size.height / 2 : 0,
|
|
253
|
+
width: size.width,
|
|
254
|
+
height: size.height,
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
getClientRect(config = {}) {
|
|
258
|
+
const skipTransform = config.skipTransform;
|
|
259
|
+
const relativeTo = config.relativeTo;
|
|
260
|
+
const fillRect = this.getSelfRect();
|
|
261
|
+
const applyStroke = !config.skipStroke && this.hasStroke();
|
|
262
|
+
const strokeWidth = (applyStroke && this.strokeWidth()) || 0;
|
|
263
|
+
const fillAndStrokeWidth = fillRect.width + strokeWidth;
|
|
264
|
+
const fillAndStrokeHeight = fillRect.height + strokeWidth;
|
|
265
|
+
const applyShadow = !config.skipShadow && this.hasShadow();
|
|
266
|
+
const shadowOffsetX = applyShadow ? this.shadowOffsetX() : 0;
|
|
267
|
+
const shadowOffsetY = applyShadow ? this.shadowOffsetY() : 0;
|
|
268
|
+
const preWidth = fillAndStrokeWidth + Math.abs(shadowOffsetX);
|
|
269
|
+
const preHeight = fillAndStrokeHeight + Math.abs(shadowOffsetY);
|
|
270
|
+
const blurRadius = (applyShadow && this.shadowBlur()) || 0;
|
|
271
|
+
const width = preWidth + blurRadius * 2;
|
|
272
|
+
const height = preHeight + blurRadius * 2;
|
|
273
|
+
let roundingOffset = 0;
|
|
274
|
+
if (Math.round(strokeWidth / 2) !== strokeWidth / 2) {
|
|
275
|
+
roundingOffset = 1;
|
|
276
|
+
}
|
|
277
|
+
const rect = {
|
|
278
|
+
width: width + roundingOffset,
|
|
279
|
+
height: height + roundingOffset,
|
|
280
|
+
x: -Math.round(strokeWidth / 2 + blurRadius) +
|
|
281
|
+
Math.min(shadowOffsetX, 0) +
|
|
282
|
+
fillRect.x,
|
|
283
|
+
y: -Math.round(strokeWidth / 2 + blurRadius) +
|
|
284
|
+
Math.min(shadowOffsetY, 0) +
|
|
285
|
+
fillRect.y,
|
|
286
|
+
};
|
|
287
|
+
if (!skipTransform) {
|
|
288
|
+
return this._transformedRect(rect, relativeTo);
|
|
289
|
+
}
|
|
290
|
+
return rect;
|
|
291
|
+
}
|
|
292
|
+
drawScene(can, top) {
|
|
293
|
+
var layer = this.getLayer(), canvas = can || layer.getCanvas(), context = canvas.getContext(), cachedCanvas = this._getCanvasCache(), drawFunc = this.getSceneFunc(), hasShadow = this.hasShadow(), stage, bufferCanvas, bufferContext;
|
|
294
|
+
var skipBuffer = canvas.isCache;
|
|
295
|
+
var cachingSelf = top === this;
|
|
296
|
+
if (!this.isVisible() && !cachingSelf) {
|
|
297
|
+
return this;
|
|
298
|
+
}
|
|
299
|
+
if (cachedCanvas) {
|
|
300
|
+
context.save();
|
|
301
|
+
var m = this.getAbsoluteTransform(top).getMatrix();
|
|
302
|
+
context.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
|
|
303
|
+
this._drawCachedSceneCanvas(context);
|
|
304
|
+
context.restore();
|
|
305
|
+
return this;
|
|
306
|
+
}
|
|
307
|
+
if (!drawFunc) {
|
|
308
|
+
return this;
|
|
309
|
+
}
|
|
310
|
+
context.save();
|
|
311
|
+
if (this._useBufferCanvas() && !skipBuffer) {
|
|
312
|
+
stage = this.getStage();
|
|
313
|
+
bufferCanvas = stage.bufferCanvas;
|
|
314
|
+
bufferContext = bufferCanvas.getContext();
|
|
315
|
+
bufferContext.clear();
|
|
316
|
+
bufferContext.save();
|
|
317
|
+
bufferContext._applyLineJoin(this);
|
|
318
|
+
var o = this.getAbsoluteTransform(top).getMatrix();
|
|
319
|
+
bufferContext.transform(o[0], o[1], o[2], o[3], o[4], o[5]);
|
|
320
|
+
drawFunc.call(this, bufferContext, this);
|
|
321
|
+
bufferContext.restore();
|
|
322
|
+
var ratio = bufferCanvas.pixelRatio;
|
|
323
|
+
if (hasShadow) {
|
|
324
|
+
context._applyShadow(this);
|
|
325
|
+
}
|
|
326
|
+
context._applyOpacity(this);
|
|
327
|
+
context._applyGlobalCompositeOperation(this);
|
|
328
|
+
context.drawImage(bufferCanvas._canvas, 0, 0, bufferCanvas.width / ratio, bufferCanvas.height / ratio);
|
|
329
|
+
}
|
|
330
|
+
else {
|
|
331
|
+
context._applyLineJoin(this);
|
|
332
|
+
if (!cachingSelf) {
|
|
333
|
+
var o = this.getAbsoluteTransform(top).getMatrix();
|
|
334
|
+
context.transform(o[0], o[1], o[2], o[3], o[4], o[5]);
|
|
335
|
+
context._applyOpacity(this);
|
|
336
|
+
context._applyGlobalCompositeOperation(this);
|
|
337
|
+
}
|
|
338
|
+
if (hasShadow) {
|
|
339
|
+
context._applyShadow(this);
|
|
340
|
+
}
|
|
341
|
+
drawFunc.call(this, context, this);
|
|
342
|
+
}
|
|
343
|
+
context.restore();
|
|
344
|
+
return this;
|
|
345
|
+
}
|
|
346
|
+
drawHit(can, top, skipDragCheck = false) {
|
|
347
|
+
if (!this.shouldDrawHit(top, skipDragCheck)) {
|
|
348
|
+
return this;
|
|
349
|
+
}
|
|
350
|
+
var layer = this.getLayer(), canvas = can || layer.hitCanvas, context = canvas && canvas.getContext(), drawFunc = this.hitFunc() || this.sceneFunc(), cachedCanvas = this._getCanvasCache(), cachedHitCanvas = cachedCanvas && cachedCanvas.hit;
|
|
351
|
+
if (!this.colorKey) {
|
|
352
|
+
Util.warn('Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()');
|
|
353
|
+
}
|
|
354
|
+
if (cachedHitCanvas) {
|
|
355
|
+
context.save();
|
|
356
|
+
var m = this.getAbsoluteTransform(top).getMatrix();
|
|
357
|
+
context.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
|
|
358
|
+
this._drawCachedHitCanvas(context);
|
|
359
|
+
context.restore();
|
|
360
|
+
return this;
|
|
361
|
+
}
|
|
362
|
+
if (!drawFunc) {
|
|
363
|
+
return this;
|
|
364
|
+
}
|
|
365
|
+
context.save();
|
|
366
|
+
context._applyLineJoin(this);
|
|
367
|
+
const selfCache = this === top;
|
|
368
|
+
if (!selfCache) {
|
|
369
|
+
var o = this.getAbsoluteTransform(top).getMatrix();
|
|
370
|
+
context.transform(o[0], o[1], o[2], o[3], o[4], o[5]);
|
|
371
|
+
}
|
|
372
|
+
drawFunc.call(this, context, this);
|
|
373
|
+
context.restore();
|
|
374
|
+
return this;
|
|
375
|
+
}
|
|
376
|
+
drawHitFromCache(alphaThreshold = 0) {
|
|
377
|
+
var cachedCanvas = this._getCanvasCache(), sceneCanvas = this._getCachedSceneCanvas(), hitCanvas = cachedCanvas.hit, hitContext = hitCanvas.getContext(), hitWidth = hitCanvas.getWidth(), hitHeight = hitCanvas.getHeight(), hitImageData, hitData, len, rgbColorKey, i, alpha;
|
|
378
|
+
hitContext.clear();
|
|
379
|
+
hitContext.drawImage(sceneCanvas._canvas, 0, 0, hitWidth, hitHeight);
|
|
380
|
+
try {
|
|
381
|
+
hitImageData = hitContext.getImageData(0, 0, hitWidth, hitHeight);
|
|
382
|
+
hitData = hitImageData.data;
|
|
383
|
+
len = hitData.length;
|
|
384
|
+
rgbColorKey = Util._hexToRgb(this.colorKey);
|
|
385
|
+
for (i = 0; i < len; i += 4) {
|
|
386
|
+
alpha = hitData[i + 3];
|
|
387
|
+
if (alpha > alphaThreshold) {
|
|
388
|
+
hitData[i] = rgbColorKey.r;
|
|
389
|
+
hitData[i + 1] = rgbColorKey.g;
|
|
390
|
+
hitData[i + 2] = rgbColorKey.b;
|
|
391
|
+
hitData[i + 3] = 255;
|
|
392
|
+
}
|
|
393
|
+
else {
|
|
394
|
+
hitData[i + 3] = 0;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
hitContext.putImageData(hitImageData, 0, 0);
|
|
398
|
+
}
|
|
399
|
+
catch (e) {
|
|
400
|
+
Util.error('Unable to draw hit graph from cached scene canvas. ' + e.message);
|
|
401
|
+
}
|
|
402
|
+
return this;
|
|
403
|
+
}
|
|
404
|
+
hasPointerCapture(pointerId) {
|
|
405
|
+
return PointerEvents.hasPointerCapture(pointerId, this);
|
|
406
|
+
}
|
|
407
|
+
setPointerCapture(pointerId) {
|
|
408
|
+
PointerEvents.setPointerCapture(pointerId, this);
|
|
409
|
+
}
|
|
410
|
+
releaseCapture(pointerId) {
|
|
411
|
+
PointerEvents.releaseCapture(pointerId, this);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
Shape.prototype._fillFunc = _fillFunc;
|
|
415
|
+
Shape.prototype._strokeFunc = _strokeFunc;
|
|
416
|
+
Shape.prototype._fillFuncHit = _fillFuncHit;
|
|
417
|
+
Shape.prototype._strokeFuncHit = _strokeFuncHit;
|
|
418
|
+
Shape.prototype._centroid = false;
|
|
419
|
+
Shape.prototype.nodeType = 'Shape';
|
|
420
|
+
_registerNode(Shape);
|
|
421
|
+
Shape.prototype.eventListeners = {};
|
|
422
|
+
Shape.prototype.on.call(Shape.prototype, 'shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva', _clearHasShadowCache);
|
|
423
|
+
Shape.prototype.on.call(Shape.prototype, 'shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva', _clearGetShadowRGBACache);
|
|
424
|
+
Shape.prototype.on.call(Shape.prototype, 'fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva', _clearFillPatternCache);
|
|
425
|
+
Shape.prototype.on.call(Shape.prototype, 'fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva', _clearLinearGradientCache);
|
|
426
|
+
Shape.prototype.on.call(Shape.prototype, 'fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva', _clearRadialGradientCache);
|
|
427
|
+
Factory.addGetterSetter(Shape, 'stroke', undefined, getStringOrGradientValidator());
|
|
428
|
+
Factory.addGetterSetter(Shape, 'strokeWidth', 2, getNumberValidator());
|
|
429
|
+
Factory.addGetterSetter(Shape, 'fillAfterStrokeEnabled', false);
|
|
430
|
+
Factory.addGetterSetter(Shape, 'hitStrokeWidth', 'auto', getNumberOrAutoValidator());
|
|
431
|
+
Factory.addGetterSetter(Shape, 'strokeHitEnabled', true, getBooleanValidator());
|
|
432
|
+
Factory.addGetterSetter(Shape, 'perfectDrawEnabled', true, getBooleanValidator());
|
|
433
|
+
Factory.addGetterSetter(Shape, 'shadowForStrokeEnabled', true, getBooleanValidator());
|
|
434
|
+
Factory.addGetterSetter(Shape, 'lineJoin');
|
|
435
|
+
Factory.addGetterSetter(Shape, 'lineCap');
|
|
436
|
+
Factory.addGetterSetter(Shape, 'sceneFunc');
|
|
437
|
+
Factory.addGetterSetter(Shape, 'hitFunc');
|
|
438
|
+
Factory.addGetterSetter(Shape, 'dash');
|
|
439
|
+
Factory.addGetterSetter(Shape, 'dashOffset', 0, getNumberValidator());
|
|
440
|
+
Factory.addGetterSetter(Shape, 'shadowColor', undefined, getStringValidator());
|
|
441
|
+
Factory.addGetterSetter(Shape, 'shadowBlur', 0, getNumberValidator());
|
|
442
|
+
Factory.addGetterSetter(Shape, 'shadowOpacity', 1, getNumberValidator());
|
|
443
|
+
Factory.addComponentsGetterSetter(Shape, 'shadowOffset', ['x', 'y']);
|
|
444
|
+
Factory.addGetterSetter(Shape, 'shadowOffsetX', 0, getNumberValidator());
|
|
445
|
+
Factory.addGetterSetter(Shape, 'shadowOffsetY', 0, getNumberValidator());
|
|
446
|
+
Factory.addGetterSetter(Shape, 'fillPatternImage');
|
|
447
|
+
Factory.addGetterSetter(Shape, 'fill', undefined, getStringOrGradientValidator());
|
|
448
|
+
Factory.addGetterSetter(Shape, 'fillPatternX', 0, getNumberValidator());
|
|
449
|
+
Factory.addGetterSetter(Shape, 'fillPatternY', 0, getNumberValidator());
|
|
450
|
+
Factory.addGetterSetter(Shape, 'fillLinearGradientColorStops');
|
|
451
|
+
Factory.addGetterSetter(Shape, 'strokeLinearGradientColorStops');
|
|
452
|
+
Factory.addGetterSetter(Shape, 'fillRadialGradientStartRadius', 0);
|
|
453
|
+
Factory.addGetterSetter(Shape, 'fillRadialGradientEndRadius', 0);
|
|
454
|
+
Factory.addGetterSetter(Shape, 'fillRadialGradientColorStops');
|
|
455
|
+
Factory.addGetterSetter(Shape, 'fillPatternRepeat', 'repeat');
|
|
456
|
+
Factory.addGetterSetter(Shape, 'fillEnabled', true);
|
|
457
|
+
Factory.addGetterSetter(Shape, 'strokeEnabled', true);
|
|
458
|
+
Factory.addGetterSetter(Shape, 'shadowEnabled', true);
|
|
459
|
+
Factory.addGetterSetter(Shape, 'dashEnabled', true);
|
|
460
|
+
Factory.addGetterSetter(Shape, 'strokeScaleEnabled', true);
|
|
461
|
+
Factory.addGetterSetter(Shape, 'fillPriority', 'color');
|
|
462
|
+
Factory.addComponentsGetterSetter(Shape, 'fillPatternOffset', ['x', 'y']);
|
|
463
|
+
Factory.addGetterSetter(Shape, 'fillPatternOffsetX', 0, getNumberValidator());
|
|
464
|
+
Factory.addGetterSetter(Shape, 'fillPatternOffsetY', 0, getNumberValidator());
|
|
465
|
+
Factory.addComponentsGetterSetter(Shape, 'fillPatternScale', ['x', 'y']);
|
|
466
|
+
Factory.addGetterSetter(Shape, 'fillPatternScaleX', 1, getNumberValidator());
|
|
467
|
+
Factory.addGetterSetter(Shape, 'fillPatternScaleY', 1, getNumberValidator());
|
|
468
|
+
Factory.addComponentsGetterSetter(Shape, 'fillLinearGradientStartPoint', [
|
|
469
|
+
'x',
|
|
470
|
+
'y',
|
|
471
|
+
]);
|
|
472
|
+
Factory.addComponentsGetterSetter(Shape, 'strokeLinearGradientStartPoint', [
|
|
473
|
+
'x',
|
|
474
|
+
'y',
|
|
475
|
+
]);
|
|
476
|
+
Factory.addGetterSetter(Shape, 'fillLinearGradientStartPointX', 0);
|
|
477
|
+
Factory.addGetterSetter(Shape, 'strokeLinearGradientStartPointX', 0);
|
|
478
|
+
Factory.addGetterSetter(Shape, 'fillLinearGradientStartPointY', 0);
|
|
479
|
+
Factory.addGetterSetter(Shape, 'strokeLinearGradientStartPointY', 0);
|
|
480
|
+
Factory.addComponentsGetterSetter(Shape, 'fillLinearGradientEndPoint', [
|
|
481
|
+
'x',
|
|
482
|
+
'y',
|
|
483
|
+
]);
|
|
484
|
+
Factory.addComponentsGetterSetter(Shape, 'strokeLinearGradientEndPoint', [
|
|
485
|
+
'x',
|
|
486
|
+
'y',
|
|
487
|
+
]);
|
|
488
|
+
Factory.addGetterSetter(Shape, 'fillLinearGradientEndPointX', 0);
|
|
489
|
+
Factory.addGetterSetter(Shape, 'strokeLinearGradientEndPointX', 0);
|
|
490
|
+
Factory.addGetterSetter(Shape, 'fillLinearGradientEndPointY', 0);
|
|
491
|
+
Factory.addGetterSetter(Shape, 'strokeLinearGradientEndPointY', 0);
|
|
492
|
+
Factory.addComponentsGetterSetter(Shape, 'fillRadialGradientStartPoint', [
|
|
493
|
+
'x',
|
|
494
|
+
'y',
|
|
495
|
+
]);
|
|
496
|
+
Factory.addGetterSetter(Shape, 'fillRadialGradientStartPointX', 0);
|
|
497
|
+
Factory.addGetterSetter(Shape, 'fillRadialGradientStartPointY', 0);
|
|
498
|
+
Factory.addComponentsGetterSetter(Shape, 'fillRadialGradientEndPoint', [
|
|
499
|
+
'x',
|
|
500
|
+
'y',
|
|
501
|
+
]);
|
|
502
|
+
Factory.addGetterSetter(Shape, 'fillRadialGradientEndPointX', 0);
|
|
503
|
+
Factory.addGetterSetter(Shape, 'fillRadialGradientEndPointY', 0);
|
|
504
|
+
Factory.addGetterSetter(Shape, 'fillPatternRotation', 0);
|
|
505
|
+
Factory.backCompat(Shape, {
|
|
506
|
+
dashArray: 'dash',
|
|
507
|
+
getDashArray: 'getDash',
|
|
508
|
+
setDashArray: 'getDash',
|
|
509
|
+
drawFunc: 'sceneFunc',
|
|
510
|
+
getDrawFunc: 'getSceneFunc',
|
|
511
|
+
setDrawFunc: 'setSceneFunc',
|
|
512
|
+
drawHitFunc: 'hitFunc',
|
|
513
|
+
getDrawHitFunc: 'getHitFunc',
|
|
514
|
+
setDrawHitFunc: 'setHitFunc',
|
|
515
|
+
});
|