@next2d/display 3.15.0 → 3.16.0

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/src/Graphics.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { GraphicsBitmapFill } from "./GraphicsBitmapFill";
2
2
  import { GraphicsGradientFill } from "./GraphicsGradientFill";
3
3
  import { execute as graphicsCalcBoundsUseCase } from "./Graphics/usecase/GraphicsCalcBoundsUseCase";
4
+ import { $MOVE_TO, $CURVE_TO, $LINE_TO, $CUBIC, $ARC, $FILL_STYLE, $STROKE_STYLE, $END_FILL, $END_STROKE, $BEGIN_PATH, $GRADIENT_FILL, $GRADIENT_STROKE, $CLOSE_PATH, $BITMAP_FILL, $BITMAP_STROKE } from "./Graphics/GraphicsCommand";
4
5
  import { execute as graphicsMargePathService } from "./Graphics/service/GraphicsMargePathService";
5
6
  import { execute as graphicsDrawEllipseService } from "./Graphics/service/GraphicsDrawEllipseService";
6
7
  import { execute as graphicsDrawRectService } from "./Graphics/service/GraphicsDrawRectService";
@@ -30,310 +31,6 @@ export class Graphics {
30
31
  * @public
31
32
  */
32
33
  constructor() {
33
- /**
34
- * @description グラフィックの確認フラグ
35
- * Graphic confirmation flag
36
- *
37
- * @type {boolean}
38
- * @default false
39
- * @public
40
- */
41
- Object.defineProperty(this, "isConfirmed", {
42
- enumerable: true,
43
- configurable: true,
44
- writable: true,
45
- value: void 0
46
- });
47
- /**
48
- * @description グラフィックの最小x座標
49
- * Minimum x coordinate of graphic
50
- *
51
- * @type {number}
52
- * @default Number.MAX_VALUE
53
- * @public
54
- */
55
- Object.defineProperty(this, "xMin", {
56
- enumerable: true,
57
- configurable: true,
58
- writable: true,
59
- value: void 0
60
- });
61
- /**
62
- * @description グラフィックの最小y座標
63
- * Minimum y coordinate of graphic
64
- *
65
- * @type {number}
66
- * @default Number.MAX_VALUE
67
- * @public
68
- */
69
- Object.defineProperty(this, "yMin", {
70
- enumerable: true,
71
- configurable: true,
72
- writable: true,
73
- value: void 0
74
- });
75
- /**
76
- * @description グラフィックの最大x座標
77
- * Maximum x coordinate of graphic
78
- *
79
- * @type {number}
80
- * @default -Number.MAX_VALUE
81
- * @public
82
- */
83
- Object.defineProperty(this, "xMax", {
84
- enumerable: true,
85
- configurable: true,
86
- writable: true,
87
- value: void 0
88
- });
89
- /**
90
- * @description グラフィックの最大y座標
91
- * Maximum y coordinate of graphic
92
- *
93
- * @type {number}
94
- * @default -Number.MAX_VALUE
95
- * @public
96
- */
97
- Object.defineProperty(this, "yMax", {
98
- enumerable: true,
99
- configurable: true,
100
- writable: true,
101
- value: void 0
102
- });
103
- /**
104
- * @description グラフィックのコマンド配列
105
- * Graphic command array
106
- *
107
- * @type {array}
108
- * @default null
109
- * @public
110
- */
111
- Object.defineProperty(this, "$recodes", {
112
- enumerable: true,
113
- configurable: true,
114
- writable: true,
115
- value: void 0
116
- });
117
- /**
118
- * @type {Float32Array}
119
- * @default null
120
- * @private
121
- */
122
- Object.defineProperty(this, "_$buffer", {
123
- enumerable: true,
124
- configurable: true,
125
- writable: true,
126
- value: void 0
127
- });
128
- /**
129
- * @type {number}
130
- * @default 0
131
- * @private
132
- */
133
- Object.defineProperty(this, "_$maxAlpha", {
134
- enumerable: true,
135
- configurable: true,
136
- writable: true,
137
- value: void 0
138
- });
139
- /**
140
- * @type {boolean}
141
- * @default false
142
- * @private
143
- */
144
- Object.defineProperty(this, "_$isBeginning", {
145
- enumerable: true,
146
- configurable: true,
147
- writable: true,
148
- value: void 0
149
- });
150
- /**
151
- * @type {number}
152
- * @default 0
153
- * @private
154
- */
155
- Object.defineProperty(this, "_$positionX", {
156
- enumerable: true,
157
- configurable: true,
158
- writable: true,
159
- value: void 0
160
- });
161
- /**
162
- * @type {number}
163
- * @default 0
164
- * @private
165
- */
166
- Object.defineProperty(this, "_$positionY", {
167
- enumerable: true,
168
- configurable: true,
169
- writable: true,
170
- value: void 0
171
- });
172
- /**
173
- * @type {boolean}
174
- * @default false
175
- * @private
176
- */
177
- Object.defineProperty(this, "_$hasFillEnabled", {
178
- enumerable: true,
179
- configurable: true,
180
- writable: true,
181
- value: void 0
182
- });
183
- /**
184
- * @type {number}
185
- * @default 0
186
- * @private
187
- */
188
- Object.defineProperty(this, "_$fillType", {
189
- enumerable: true,
190
- configurable: true,
191
- writable: true,
192
- value: void 0
193
- });
194
- /**
195
- * @type {number}
196
- * @default 0
197
- * @private
198
- */
199
- Object.defineProperty(this, "_$fillColor", {
200
- enumerable: true,
201
- configurable: true,
202
- writable: true,
203
- value: void 0
204
- });
205
- /**
206
- * @type {GraphicsGradientFill}
207
- * @default null
208
- * @private
209
- */
210
- Object.defineProperty(this, "_$fillGradient", {
211
- enumerable: true,
212
- configurable: true,
213
- writable: true,
214
- value: void 0
215
- });
216
- /**
217
- * @type {GraphicsBitmapFill}
218
- * @default null
219
- * @private
220
- */
221
- Object.defineProperty(this, "_$fillBitmap", {
222
- enumerable: true,
223
- configurable: true,
224
- writable: true,
225
- value: void 0
226
- });
227
- /**
228
- * @type {array}
229
- * @default null
230
- * @private
231
- */
232
- Object.defineProperty(this, "_$fills", {
233
- enumerable: true,
234
- configurable: true,
235
- writable: true,
236
- value: void 0
237
- });
238
- /**
239
- * @type {boolean}
240
- * @default false
241
- * @private
242
- */
243
- Object.defineProperty(this, "_$hasLineEnabled", {
244
- enumerable: true,
245
- configurable: true,
246
- writable: true,
247
- value: void 0
248
- });
249
- /**
250
- * @type {number}
251
- * @default 0
252
- * @private
253
- */
254
- Object.defineProperty(this, "_$lineType", {
255
- enumerable: true,
256
- configurable: true,
257
- writable: true,
258
- value: void 0
259
- });
260
- /**
261
- * @type {number}
262
- * @default 0
263
- * @private
264
- */
265
- Object.defineProperty(this, "_$lineColor", {
266
- enumerable: true,
267
- configurable: true,
268
- writable: true,
269
- value: void 0
270
- });
271
- /**
272
- * @type {GraphicsGradientFill}
273
- * @default null
274
- * @private
275
- */
276
- Object.defineProperty(this, "_$lineGradient", {
277
- enumerable: true,
278
- configurable: true,
279
- writable: true,
280
- value: void 0
281
- });
282
- /**
283
- * @type {string}
284
- * @default "round"
285
- * @private
286
- */
287
- Object.defineProperty(this, "_$joints", {
288
- enumerable: true,
289
- configurable: true,
290
- writable: true,
291
- value: void 0
292
- });
293
- /**
294
- * @type {number}
295
- * @default 0
296
- * @private
297
- */
298
- Object.defineProperty(this, "_$miterLimit", {
299
- enumerable: true,
300
- configurable: true,
301
- writable: true,
302
- value: void 0
303
- });
304
- /**
305
- * @type {string}
306
- * @default "none"
307
- * @private
308
- */
309
- Object.defineProperty(this, "_$caps", {
310
- enumerable: true,
311
- configurable: true,
312
- writable: true,
313
- value: void 0
314
- });
315
- /**
316
- * @type {number}
317
- * @default 1
318
- * @private
319
- */
320
- Object.defineProperty(this, "_$lineWidth", {
321
- enumerable: true,
322
- configurable: true,
323
- writable: true,
324
- value: void 0
325
- });
326
- /**
327
- * @type {array}
328
- * @default null
329
- * @private
330
- */
331
- Object.defineProperty(this, "_$lines", {
332
- enumerable: true,
333
- configurable: true,
334
- writable: true,
335
- value: void 0
336
- });
337
34
  this.isConfirmed = false;
338
35
  this.xMin = Number.MAX_VALUE;
339
36
  this.yMin = Number.MAX_VALUE;
@@ -373,7 +70,7 @@ export class Graphics {
373
70
  * @static
374
71
  */
375
72
  static get MOVE_TO() {
376
- return 0;
73
+ return $MOVE_TO;
377
74
  }
378
75
  /**
379
76
  * @description 描画コマンド、2次ベジェ曲線の識別番号
@@ -384,7 +81,7 @@ export class Graphics {
384
81
  * @static
385
82
  */
386
83
  static get CURVE_TO() {
387
- return 1;
84
+ return $CURVE_TO;
388
85
  }
389
86
  /**
390
87
  * @description 描画コマンド、直線の識別番号
@@ -395,7 +92,7 @@ export class Graphics {
395
92
  * @static
396
93
  */
397
94
  static get LINE_TO() {
398
- return 2;
95
+ return $LINE_TO;
399
96
  }
400
97
  /**
401
98
  * @description 描画コマンド、3次ベジェ曲線の識別番号
@@ -406,7 +103,7 @@ export class Graphics {
406
103
  * @static
407
104
  */
408
105
  static get CUBIC() {
409
- return 3;
106
+ return $CUBIC;
410
107
  }
411
108
  /**
412
109
  * @description 描画コマンド、円弧の識別番号
@@ -417,7 +114,7 @@ export class Graphics {
417
114
  * @static
418
115
  */
419
116
  static get ARC() {
420
- return 4;
117
+ return $ARC;
421
118
  }
422
119
  /**
423
120
  * @description 描画コマンド、塗りの識別番号
@@ -428,7 +125,7 @@ export class Graphics {
428
125
  * @static
429
126
  */
430
127
  static get FILL_STYLE() {
431
- return 5;
128
+ return $FILL_STYLE;
432
129
  }
433
130
  /**
434
131
  * @description 描画コマンド、線の識別番号
@@ -439,7 +136,7 @@ export class Graphics {
439
136
  * @static
440
137
  */
441
138
  static get STROKE_STYLE() {
442
- return 6;
139
+ return $STROKE_STYLE;
443
140
  }
444
141
  /**
445
142
  * @description 描画コマンド、塗りの終了の識別番号
@@ -450,7 +147,7 @@ export class Graphics {
450
147
  * @static
451
148
  */
452
149
  static get END_FILL() {
453
- return 7;
150
+ return $END_FILL;
454
151
  }
455
152
  /**
456
153
  * @description 描画コマンド、線の終了の識別番号
@@ -461,7 +158,7 @@ export class Graphics {
461
158
  * @static
462
159
  */
463
160
  static get END_STROKE() {
464
- return 8;
161
+ return $END_STROKE;
465
162
  }
466
163
  /**
467
164
  * @description 描画コマンド、描画開始の識別番号
@@ -472,7 +169,7 @@ export class Graphics {
472
169
  * @static
473
170
  */
474
171
  static get BEGIN_PATH() {
475
- return 9;
172
+ return $BEGIN_PATH;
476
173
  }
477
174
  /**
478
175
  * @description 描画コマンド、塗りのグラデーション開始の識別番号
@@ -483,7 +180,7 @@ export class Graphics {
483
180
  * @static
484
181
  */
485
182
  static get GRADIENT_FILL() {
486
- return 10;
183
+ return $GRADIENT_FILL;
487
184
  }
488
185
  /**
489
186
  * @description 描画コマンド、線のグラデーション開始の識別番号
@@ -494,7 +191,7 @@ export class Graphics {
494
191
  * @static
495
192
  */
496
193
  static get GRADIENT_STROKE() {
497
- return 11;
194
+ return $GRADIENT_STROKE;
498
195
  }
499
196
  /**
500
197
  * @description 描画コマンド、描画結合の識別番号
@@ -505,7 +202,7 @@ export class Graphics {
505
202
  * @static
506
203
  */
507
204
  static get CLOSE_PATH() {
508
- return 12;
205
+ return $CLOSE_PATH;
509
206
  }
510
207
  /**
511
208
  * @description 描画コマンド、Bitmapの塗りの識別番号
@@ -516,7 +213,7 @@ export class Graphics {
516
213
  * @static
517
214
  */
518
215
  static get BITMAP_FILL() {
519
- return 13;
216
+ return $BITMAP_FILL;
520
217
  }
521
218
  /**
522
219
  * @description 描画コマンド、Bitmapの線の識別番号
@@ -527,7 +224,7 @@ export class Graphics {
527
224
  * @static
528
225
  */
529
226
  static get BITMAP_STROKE() {
530
- return 14;
227
+ return $BITMAP_STROKE;
531
228
  }
532
229
  /**
533
230
  * @description 描画コマンドが実行可能かを返却
@@ -799,9 +496,56 @@ export class Graphics {
799
496
  control_x2 = +control_x2 || 0;
800
497
  control_y2 = +control_y2 || 0;
801
498
  // calc bounds
802
- graphicsCalcBoundsUseCase(this, this._$hasLineEnabled, this._$positionX, this._$positionY, this._$lineWidth, this._$caps, control_x1, control_y1, control_x2, control_y2, anchor_x, anchor_y);
499
+ // 線が無いときは、塗りの範囲だけをその場で広げる (関数呼び出しと Math.min / Math.max を避ける)
500
+ if (this._$hasLineEnabled) {
501
+ graphicsCalcBoundsUseCase(this, this._$hasLineEnabled, this._$positionX, this._$positionY, this._$lineWidth, this._$caps, control_x1, control_y1, control_x2, control_y2, anchor_x, anchor_y);
502
+ }
503
+ else {
504
+ if (control_x1 < this.xMin) {
505
+ this.xMin = control_x1;
506
+ }
507
+ if (control_x1 > this.xMax) {
508
+ this.xMax = control_x1;
509
+ }
510
+ if (control_y1 < this.yMin) {
511
+ this.yMin = control_y1;
512
+ }
513
+ if (control_y1 > this.yMax) {
514
+ this.yMax = control_y1;
515
+ }
516
+ if (control_x2 < this.xMin) {
517
+ this.xMin = control_x2;
518
+ }
519
+ if (control_x2 > this.xMax) {
520
+ this.xMax = control_x2;
521
+ }
522
+ if (control_y2 < this.yMin) {
523
+ this.yMin = control_y2;
524
+ }
525
+ if (control_y2 > this.yMax) {
526
+ this.yMax = control_y2;
527
+ }
528
+ if (anchor_x < this.xMin) {
529
+ this.xMin = anchor_x;
530
+ }
531
+ if (anchor_x > this.xMax) {
532
+ this.xMax = anchor_x;
533
+ }
534
+ if (anchor_y < this.yMin) {
535
+ this.yMin = anchor_y;
536
+ }
537
+ if (anchor_y > this.yMax) {
538
+ this.yMax = anchor_y;
539
+ }
540
+ }
803
541
  // marge path
804
- graphicsMargePathService(this, this._$hasFillEnabled, this._$hasLineEnabled, this._$fills, this._$lines, Graphics.CUBIC, control_x1, control_y1, control_x2, control_y2, anchor_x, anchor_y);
542
+ this.isConfirmed = false;
543
+ if (this._$hasFillEnabled && this._$fills) {
544
+ this._$fills.push($CUBIC, control_x1, control_y1, control_x2, control_y2, anchor_x, anchor_y);
545
+ }
546
+ if (this._$hasLineEnabled && this._$lines) {
547
+ this._$lines.push($CUBIC, control_x1, control_y1, control_x2, control_y2, anchor_x, anchor_y);
548
+ }
805
549
  this._$positionX = anchor_x;
806
550
  this._$positionY = anchor_y;
807
551
  return this;
@@ -831,9 +575,44 @@ export class Graphics {
831
575
  control_x = +control_x || 0;
832
576
  control_y = +control_y || 0;
833
577
  // calc bounds
834
- graphicsCalcBoundsUseCase(this, this._$hasLineEnabled, this._$positionX, this._$positionY, this._$lineWidth, this._$caps, control_x, control_y, anchor_x, anchor_y);
578
+ // 線が無いときは、塗りの範囲だけをその場で広げる (関数呼び出しと Math.min / Math.max を避ける)
579
+ if (this._$hasLineEnabled) {
580
+ graphicsCalcBoundsUseCase(this, this._$hasLineEnabled, this._$positionX, this._$positionY, this._$lineWidth, this._$caps, control_x, control_y, anchor_x, anchor_y);
581
+ }
582
+ else {
583
+ if (control_x < this.xMin) {
584
+ this.xMin = control_x;
585
+ }
586
+ if (control_x > this.xMax) {
587
+ this.xMax = control_x;
588
+ }
589
+ if (control_y < this.yMin) {
590
+ this.yMin = control_y;
591
+ }
592
+ if (control_y > this.yMax) {
593
+ this.yMax = control_y;
594
+ }
595
+ if (anchor_x < this.xMin) {
596
+ this.xMin = anchor_x;
597
+ }
598
+ if (anchor_x > this.xMax) {
599
+ this.xMax = anchor_x;
600
+ }
601
+ if (anchor_y < this.yMin) {
602
+ this.yMin = anchor_y;
603
+ }
604
+ if (anchor_y > this.yMax) {
605
+ this.yMax = anchor_y;
606
+ }
607
+ }
835
608
  // marge path
836
- graphicsMargePathService(this, this._$hasFillEnabled, this._$hasLineEnabled, this._$fills, this._$lines, Graphics.CURVE_TO, control_x, control_y, anchor_x, anchor_y);
609
+ this.isConfirmed = false;
610
+ if (this._$hasFillEnabled && this._$fills) {
611
+ this._$fills.push($CURVE_TO, control_x, control_y, anchor_x, anchor_y);
612
+ }
613
+ if (this._$hasLineEnabled && this._$lines) {
614
+ this._$lines.push($CURVE_TO, control_x, control_y, anchor_x, anchor_y);
615
+ }
837
616
  this._$positionX = anchor_x;
838
617
  this._$positionY = anchor_y;
839
618
  return this;
@@ -1145,9 +924,32 @@ export class Graphics {
1145
924
  return this;
1146
925
  }
1147
926
  // calc bounds
1148
- graphicsCalcBoundsUseCase(this, this._$hasLineEnabled, this._$positionX, this._$positionY, this._$lineWidth, this._$caps, x, y);
927
+ // 線が無いときは、塗りの範囲だけをその場で広げる (関数呼び出しと Math.min / Math.max を避ける)
928
+ if (this._$hasLineEnabled) {
929
+ graphicsCalcBoundsUseCase(this, this._$hasLineEnabled, this._$positionX, this._$positionY, this._$lineWidth, this._$caps, x, y);
930
+ }
931
+ else {
932
+ if (x < this.xMin) {
933
+ this.xMin = x;
934
+ }
935
+ if (x > this.xMax) {
936
+ this.xMax = x;
937
+ }
938
+ if (y < this.yMin) {
939
+ this.yMin = y;
940
+ }
941
+ if (y > this.yMax) {
942
+ this.yMax = y;
943
+ }
944
+ }
1149
945
  // marge path
1150
- graphicsMargePathService(this, this._$hasFillEnabled, this._$hasLineEnabled, this._$fills, this._$lines, Graphics.LINE_TO, x, y);
946
+ this.isConfirmed = false;
947
+ if (this._$hasFillEnabled && this._$fills) {
948
+ this._$fills.push($LINE_TO, x, y);
949
+ }
950
+ if (this._$hasLineEnabled && this._$lines) {
951
+ this._$lines.push($LINE_TO, x, y);
952
+ }
1151
953
  this._$positionX = x;
1152
954
  this._$positionY = y;
1153
955
  return this;
@@ -1168,7 +970,24 @@ export class Graphics {
1168
970
  this._$positionX = x;
1169
971
  this._$positionY = y;
1170
972
  // calc bounds
1171
- graphicsCalcBoundsUseCase(this, this._$hasLineEnabled, this._$positionX, this._$positionY, this._$lineWidth, this._$caps, x, y);
973
+ // 線が無いときは、塗りの範囲だけをその場で広げる (関数呼び出しと Math.min / Math.max を避ける)
974
+ if (this._$hasLineEnabled) {
975
+ graphicsCalcBoundsUseCase(this, this._$hasLineEnabled, this._$positionX, this._$positionY, this._$lineWidth, this._$caps, x, y);
976
+ }
977
+ else {
978
+ if (x < this.xMin) {
979
+ this.xMin = x;
980
+ }
981
+ if (x > this.xMax) {
982
+ this.xMax = x;
983
+ }
984
+ if (y < this.yMin) {
985
+ this.yMin = y;
986
+ }
987
+ if (y > this.yMax) {
988
+ this.yMax = y;
989
+ }
990
+ }
1172
991
  let duplication = false;
1173
992
  if (this._$hasFillEnabled && this._$fills) {
1174
993
  const isMove = this._$fills[this._$fills.length - 3] === Graphics.MOVE_TO;
@@ -1188,7 +1007,13 @@ export class Graphics {
1188
1007
  }
1189
1008
  // marge path
1190
1009
  if (!duplication) {
1191
- graphicsMargePathService(this, this._$hasFillEnabled, this._$hasLineEnabled, this._$fills, this._$lines, Graphics.MOVE_TO, x, y);
1010
+ this.isConfirmed = false;
1011
+ if (this._$hasFillEnabled && this._$fills) {
1012
+ this._$fills.push($MOVE_TO, x, y);
1013
+ }
1014
+ if (this._$hasLineEnabled && this._$lines) {
1015
+ this._$lines.push($MOVE_TO, x, y);
1016
+ }
1192
1017
  }
1193
1018
  return this;
1194
1019
  }
@@ -20,30 +20,6 @@ export class GraphicsBitmapFill {
20
20
  * @private
21
21
  */
22
22
  constructor(bitmap_data, matrix = null, repeat = true, smooth = false) {
23
- Object.defineProperty(this, "_$bitmapData", {
24
- enumerable: true,
25
- configurable: true,
26
- writable: true,
27
- value: void 0
28
- });
29
- Object.defineProperty(this, "_$matrix", {
30
- enumerable: true,
31
- configurable: true,
32
- writable: true,
33
- value: void 0
34
- });
35
- Object.defineProperty(this, "_$repeat", {
36
- enumerable: true,
37
- configurable: true,
38
- writable: true,
39
- value: void 0
40
- });
41
- Object.defineProperty(this, "_$smooth", {
42
- enumerable: true,
43
- configurable: true,
44
- writable: true,
45
- value: void 0
46
- });
47
23
  /**
48
24
  * @description 透明または不透明なビットマップイメージです。
49
25
  * A transparent or opaque bitmap image.