@wcardinal/wcardinal-ui 0.466.2 → 0.467.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.
Files changed (88) hide show
  1. package/dist/types/wcardinal/ui/shape/e-shape-defaults.d.ts +1 -1
  2. package/dist/types/wcardinal/ui/shape/e-shape-type.d.ts +1 -0
  3. package/dist/types/wcardinal/ui/shape/load/index.d.ts +1 -0
  4. package/dist/types/wcardinal/ui/shape/load/load-shape-rectangle-rounded-legacy.d.ts +1 -0
  5. package/dist/types/wcardinal/ui/shape/variant/build-rectangle-rounded-legacy.d.ts +11 -0
  6. package/dist/types/wcardinal/ui/shape/variant/build-rectangle-rounded.d.ts +1 -11
  7. package/dist/types/wcardinal/ui/shape/variant/builder-rectangle-rounded-legacy.d.ts +12 -0
  8. package/dist/types/wcardinal/ui/shape/variant/builder-rectangle-rounded.d.ts +1 -12
  9. package/dist/types/wcardinal/ui/shape/variant/create-rectangle-rounded-legacy-uploaded.d.ts +4 -0
  10. package/dist/types/wcardinal/ui/shape/variant/create-rectangle-rounded-uploaded.d.ts +1 -4
  11. package/dist/types/wcardinal/ui/shape/variant/deserialize-rectangle-rounded-legacy.d.ts +4 -0
  12. package/dist/types/wcardinal/ui/shape/variant/e-shape-line-of-rectangle-roundeds.d.ts +2 -2
  13. package/dist/types/wcardinal/ui/shape/variant/e-shape-rectangle-rounded-legacy.d.ts +7 -0
  14. package/dist/types/wcardinal/ui/shape/variant/e-shape-rectangle-rounded-triangulated-impl.d.ts +306 -0
  15. package/dist/types/wcardinal/ui/shape/variant/e-shape-rectangle-rounded-triangulated.d.ts +3 -0
  16. package/dist/types/wcardinal/ui/shape/variant/e-shape-rectangle-rounded.d.ts +4 -0
  17. package/dist/types/wcardinal/ui/shape/variant/index.d.ts +7 -0
  18. package/dist/wcardinal/ui/shape/e-shape-defaults.js +1 -1
  19. package/dist/wcardinal/ui/shape/e-shape-defaults.js.map +1 -1
  20. package/dist/wcardinal/ui/shape/e-shape-renderer.js +2 -2
  21. package/dist/wcardinal/ui/shape/e-shape-renderer.js.map +1 -1
  22. package/dist/wcardinal/ui/shape/e-shape-type.js +1 -0
  23. package/dist/wcardinal/ui/shape/e-shape-type.js.map +1 -1
  24. package/dist/wcardinal/ui/shape/load/index.js +1 -0
  25. package/dist/wcardinal/ui/shape/load/index.js.map +1 -1
  26. package/dist/wcardinal/ui/shape/load/load-shape-all.js +2 -0
  27. package/dist/wcardinal/ui/shape/load/load-shape-all.js.map +1 -1
  28. package/dist/wcardinal/ui/shape/load/load-shape-circle-legacy.js +1 -1
  29. package/dist/wcardinal/ui/shape/load/load-shape-circle-legacy.js.map +1 -1
  30. package/dist/wcardinal/ui/shape/load/load-shape-image.js +1 -1
  31. package/dist/wcardinal/ui/shape/load/load-shape-image.js.map +1 -1
  32. package/dist/wcardinal/ui/shape/load/load-shape-rectangle-rounded-legacy.js +17 -0
  33. package/dist/wcardinal/ui/shape/load/load-shape-rectangle-rounded-legacy.js.map +1 -0
  34. package/dist/wcardinal/ui/shape/load/load-shape-rectangle-rounded.js +2 -2
  35. package/dist/wcardinal/ui/shape/load/load-shape-rectangle-rounded.js.map +1 -1
  36. package/dist/wcardinal/ui/shape/variant/build-rectangle-rounded-legacy.js +1039 -0
  37. package/dist/wcardinal/ui/shape/variant/build-rectangle-rounded-legacy.js.map +1 -0
  38. package/dist/wcardinal/ui/shape/variant/build-rectangle-rounded.js +5 -1038
  39. package/dist/wcardinal/ui/shape/variant/build-rectangle-rounded.js.map +1 -1
  40. package/dist/wcardinal/ui/shape/variant/builder-line-of-rectangle-roundeds.js +16 -16
  41. package/dist/wcardinal/ui/shape/variant/builder-line-of-rectangle-roundeds.js.map +1 -1
  42. package/dist/wcardinal/ui/shape/variant/builder-rectangle-rounded-legacy.js +89 -0
  43. package/dist/wcardinal/ui/shape/variant/builder-rectangle-rounded-legacy.js.map +1 -0
  44. package/dist/wcardinal/ui/shape/variant/builder-rectangle-rounded.js +1 -84
  45. package/dist/wcardinal/ui/shape/variant/builder-rectangle-rounded.js.map +1 -1
  46. package/dist/wcardinal/ui/shape/variant/create-button-uploaded.js +2 -2
  47. package/dist/wcardinal/ui/shape/variant/create-button-uploaded.js.map +1 -1
  48. package/dist/wcardinal/ui/shape/variant/create-line-of-rectangle-roundeds-uploaded.js +2 -2
  49. package/dist/wcardinal/ui/shape/variant/create-line-of-rectangle-roundeds-uploaded.js.map +1 -1
  50. package/dist/wcardinal/ui/shape/variant/create-rectangle-rounded-legacy-uploaded.js +24 -0
  51. package/dist/wcardinal/ui/shape/variant/create-rectangle-rounded-legacy-uploaded.js.map +1 -0
  52. package/dist/wcardinal/ui/shape/variant/create-rectangle-rounded-uploaded.js +1 -19
  53. package/dist/wcardinal/ui/shape/variant/create-rectangle-rounded-uploaded.js.map +1 -1
  54. package/dist/wcardinal/ui/shape/variant/deserialize-rectangle-rounded-legacy.js +10 -0
  55. package/dist/wcardinal/ui/shape/variant/deserialize-rectangle-rounded-legacy.js.map +1 -0
  56. package/dist/wcardinal/ui/shape/variant/e-shape-line-of-rectangle-roundeds.js +2 -2
  57. package/dist/wcardinal/ui/shape/variant/e-shape-line-of-rectangle-roundeds.js.map +1 -1
  58. package/dist/wcardinal/ui/shape/variant/e-shape-rectangle-rounded-legacy.js +27 -0
  59. package/dist/wcardinal/ui/shape/variant/e-shape-rectangle-rounded-legacy.js.map +1 -0
  60. package/dist/wcardinal/ui/shape/variant/e-shape-rectangle-rounded-triangulated-impl.js +2663 -0
  61. package/dist/wcardinal/ui/shape/variant/e-shape-rectangle-rounded-triangulated-impl.js.map +1 -0
  62. package/dist/wcardinal/ui/shape/variant/e-shape-rectangle-rounded-triangulated.js +6 -0
  63. package/dist/wcardinal/ui/shape/variant/e-shape-rectangle-rounded-triangulated.js.map +1 -0
  64. package/dist/wcardinal/ui/shape/variant/e-shape-rectangle-rounded.js +14 -1
  65. package/dist/wcardinal/ui/shape/variant/e-shape-rectangle-rounded.js.map +1 -1
  66. package/dist/wcardinal/ui/shape/variant/e-shape-rectangle-triangulated-impl.js +31 -29
  67. package/dist/wcardinal/ui/shape/variant/e-shape-rectangle-triangulated-impl.js.map +1 -1
  68. package/dist/wcardinal/ui/shape/variant/index.js +7 -0
  69. package/dist/wcardinal/ui/shape/variant/index.js.map +1 -1
  70. package/dist/wcardinal/ui/shape/variant/to-packed.js +3 -3
  71. package/dist/wcardinal/ui/shape/variant/to-packed.js.map +1 -1
  72. package/dist/wcardinal-ui-theme-dark-en-us.js +1 -1
  73. package/dist/wcardinal-ui-theme-dark-en-us.min.js +1 -1
  74. package/dist/wcardinal-ui-theme-dark-ja-jp.js +1 -1
  75. package/dist/wcardinal-ui-theme-dark-ja-jp.min.js +1 -1
  76. package/dist/wcardinal-ui-theme-dark.js +1 -1
  77. package/dist/wcardinal-ui-theme-dark.min.js +1 -1
  78. package/dist/wcardinal-ui-theme-white-en-us.js +1 -1
  79. package/dist/wcardinal-ui-theme-white-en-us.min.js +1 -1
  80. package/dist/wcardinal-ui-theme-white-ja-jp.js +1 -1
  81. package/dist/wcardinal-ui-theme-white-ja-jp.min.js +1 -1
  82. package/dist/wcardinal-ui-theme-white.js +1 -1
  83. package/dist/wcardinal-ui-theme-white.min.js +1 -1
  84. package/dist/wcardinal-ui.cjs.js +13532 -10804
  85. package/dist/wcardinal-ui.js +14009 -11281
  86. package/dist/wcardinal-ui.min.js +2 -2
  87. package/dist/wcardinal-ui.min.js.map +1 -1
  88. package/package.json +1 -1
@@ -0,0 +1,2663 @@
1
+ /*
2
+ * Copyright (C) 2019-2026 Toshiba Corporation
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import { EShapeCorner } from "../e-shape-corner";
6
+ import { EShapeDefaults } from "../e-shape-defaults";
7
+ import { EShapeStrokeSide } from "../e-shape-stroke-side";
8
+ var EShapeRectangleRoundedTriangulatedImpl = /** @class */ (function () {
9
+ function EShapeRectangleRoundedTriangulatedImpl(parent) {
10
+ this._id = 0;
11
+ this._parent = parent;
12
+ this._width = 0;
13
+ this._height = 0;
14
+ this._strokeAlign = 0;
15
+ this._strokeWidth = 0;
16
+ this._strokeSide = EShapeStrokeSide.NONE;
17
+ this._radius = 0;
18
+ this._corner = EShapeCorner.NONE;
19
+ this._sizeX = 0;
20
+ this._sizeY = 0;
21
+ this._n = EShapeDefaults.CIRCLE_SEGMENT_COUNT;
22
+ this._vertices = [];
23
+ this._nvertices = 0;
24
+ this._distances = [];
25
+ this._lengths = [];
26
+ this._clippings = [];
27
+ this._uvs = [];
28
+ this._indices = [];
29
+ this._nindices = 0;
30
+ this._boundary = [0, 0, 0, 0];
31
+ }
32
+ Object.defineProperty(EShapeRectangleRoundedTriangulatedImpl.prototype, "id", {
33
+ get: function () {
34
+ this.triangulate();
35
+ return this._id;
36
+ },
37
+ enumerable: false,
38
+ configurable: true
39
+ });
40
+ Object.defineProperty(EShapeRectangleRoundedTriangulatedImpl.prototype, "vertices", {
41
+ get: function () {
42
+ this.triangulate();
43
+ return this._vertices;
44
+ },
45
+ enumerable: false,
46
+ configurable: true
47
+ });
48
+ Object.defineProperty(EShapeRectangleRoundedTriangulatedImpl.prototype, "nvertices", {
49
+ get: function () {
50
+ this.triangulate();
51
+ return this._nvertices;
52
+ },
53
+ enumerable: false,
54
+ configurable: true
55
+ });
56
+ Object.defineProperty(EShapeRectangleRoundedTriangulatedImpl.prototype, "distances", {
57
+ get: function () {
58
+ this.triangulate();
59
+ return this._distances;
60
+ },
61
+ enumerable: false,
62
+ configurable: true
63
+ });
64
+ Object.defineProperty(EShapeRectangleRoundedTriangulatedImpl.prototype, "lengths", {
65
+ get: function () {
66
+ this.triangulate();
67
+ return this._lengths;
68
+ },
69
+ enumerable: false,
70
+ configurable: true
71
+ });
72
+ Object.defineProperty(EShapeRectangleRoundedTriangulatedImpl.prototype, "clippings", {
73
+ get: function () {
74
+ this.triangulate();
75
+ return this._clippings;
76
+ },
77
+ enumerable: false,
78
+ configurable: true
79
+ });
80
+ Object.defineProperty(EShapeRectangleRoundedTriangulatedImpl.prototype, "uvs", {
81
+ get: function () {
82
+ this.triangulate();
83
+ return this._uvs;
84
+ },
85
+ enumerable: false,
86
+ configurable: true
87
+ });
88
+ Object.defineProperty(EShapeRectangleRoundedTriangulatedImpl.prototype, "indices", {
89
+ get: function () {
90
+ this.triangulate();
91
+ return this._indices;
92
+ },
93
+ enumerable: false,
94
+ configurable: true
95
+ });
96
+ Object.defineProperty(EShapeRectangleRoundedTriangulatedImpl.prototype, "nindices", {
97
+ get: function () {
98
+ this.triangulate();
99
+ return this._nindices;
100
+ },
101
+ enumerable: false,
102
+ configurable: true
103
+ });
104
+ Object.defineProperty(EShapeRectangleRoundedTriangulatedImpl.prototype, "boundary", {
105
+ get: function () {
106
+ this.triangulate();
107
+ return this._boundary;
108
+ },
109
+ enumerable: false,
110
+ configurable: true
111
+ });
112
+ EShapeRectangleRoundedTriangulatedImpl.prototype.triangulate = function () {
113
+ var isNotInitialized = this._id === 0;
114
+ var parent = this._parent;
115
+ var size = parent.size;
116
+ var width = size.x;
117
+ var height = size.y;
118
+ var isRectChanged = this._width !== width || this._height !== height;
119
+ var stroke = parent.stroke;
120
+ var strokeAlign = stroke.align;
121
+ var strokeWidth = stroke.enable ? stroke.width : 0;
122
+ var strokeSide = stroke.side;
123
+ var isStrokeChanged = this._strokeAlign !== strokeAlign ||
124
+ this._strokeWidth !== strokeWidth ||
125
+ this._strokeSide !== strokeSide;
126
+ var radius = parent.radius;
127
+ var corner = parent.corner;
128
+ var isRadiusChanged = this._radius !== radius || this._corner !== corner;
129
+ var isSizeChanged = false;
130
+ var sizeX = this._sizeX;
131
+ var sizeY = this._sizeY;
132
+ if (isRectChanged || isStrokeChanged) {
133
+ this._width = width;
134
+ this._height = height;
135
+ this._strokeAlign = strokeAlign;
136
+ this._strokeWidth = strokeWidth;
137
+ this._strokeSide = strokeSide;
138
+ var s = strokeAlign * strokeWidth;
139
+ sizeX = width * 0.5 + (0 <= width ? +s : -s);
140
+ sizeY = height * 0.5 + (0 <= height ? +s : -s);
141
+ isSizeChanged = this._sizeX !== sizeX || this._sizeY !== sizeY;
142
+ }
143
+ if (isNotInitialized || isSizeChanged || isStrokeChanged || isRadiusChanged) {
144
+ this._sizeX = sizeX;
145
+ this._sizeY = sizeY;
146
+ this._radius = radius;
147
+ this._corner = corner;
148
+ this.update(sizeX, sizeY, radius, corner, 1.1);
149
+ }
150
+ };
151
+ EShapeRectangleRoundedTriangulatedImpl.prototype.update = function (sizeX, sizeY, radius, corner, scale) {
152
+ // Boundary
153
+ var ax = Math.abs(sizeX);
154
+ var ay = Math.abs(sizeY);
155
+ var boundary = this._boundary;
156
+ boundary[0] = -ax;
157
+ boundary[1] = -ay;
158
+ boundary[2] = +ax;
159
+ boundary[3] = +ay;
160
+ // # of vertices and # of indices
161
+ var n = this._n >> 2;
162
+ var nv = 8 * n + 18;
163
+ var ni = 4 * n + 10;
164
+ this._nvertices = nv;
165
+ this._nindices = ni;
166
+ // ID
167
+ this._id += 1;
168
+ //
169
+ if (sizeX === 0 || sizeY === 0) {
170
+ this.pad(0, 0, nv, ni, 0);
171
+ }
172
+ else {
173
+ var fx = 1 / sizeX;
174
+ var fy = 1 / sizeY;
175
+ switch (this._strokeSide) {
176
+ case EShapeStrokeSide.NONE:
177
+ case EShapeStrokeSide.ALL:
178
+ if (ay <= ax) {
179
+ this.updateAll0(fx, fy, ax, ay, scale, radius, corner, nv, ni);
180
+ }
181
+ else {
182
+ this.updateAll1(fx, fy, ax, ay, scale, radius, corner, nv, ni);
183
+ }
184
+ break;
185
+ case EShapeStrokeSide.TOP:
186
+ this.updateTop(fx, fy, ax, ay, scale, radius, corner, nv, ni);
187
+ break;
188
+ case EShapeStrokeSide.RIGHT:
189
+ this.updateRight(fx, fy, ax, ay, scale, radius, corner, nv, ni);
190
+ break;
191
+ case EShapeStrokeSide.BOTTOM:
192
+ this.updateBottom(fx, fy, ax, ay, scale, radius, corner, nv, ni);
193
+ break;
194
+ case EShapeStrokeSide.LEFT:
195
+ this.updateLeft(fx, fy, ax, ay, scale, radius, corner, nv, ni);
196
+ break;
197
+ case EShapeStrokeSide.TOP_OR_BOTTOM:
198
+ this.updateTopBottom(fx, fy, ax, ay, scale, radius, corner, nv, ni);
199
+ break;
200
+ case EShapeStrokeSide.LEFT_OR_RIGHT:
201
+ this.updateLeftRight(fx, fy, ax, ay, scale, radius, corner, nv, ni);
202
+ break;
203
+ case EShapeStrokeSide.TOP_OR_RIGHT:
204
+ if (ay <= ax) {
205
+ this.updateTopRight0(fx, fy, ax, ay, scale, radius, corner, nv, ni);
206
+ }
207
+ else {
208
+ this.updateTopRight1(fx, fy, ax, ay, scale, radius, corner, nv, ni);
209
+ }
210
+ break;
211
+ case EShapeStrokeSide.TOP_OR_LEFT:
212
+ if (ay <= ax) {
213
+ this.updateTopLeft0(fx, fy, ax, ay, scale, radius, corner, nv, ni);
214
+ }
215
+ else {
216
+ this.updateTopLeft1(fx, fy, ax, ay, scale, radius, corner, nv, ni);
217
+ }
218
+ break;
219
+ case EShapeStrokeSide.BOTTOM_OR_RIGHT:
220
+ if (ay <= ax) {
221
+ this.updateBottomRight0(fx, fy, ax, ay, scale, radius, corner, nv, ni);
222
+ }
223
+ else {
224
+ this.updateBottomRight1(fx, fy, ax, ay, scale, radius, corner, nv, ni);
225
+ }
226
+ break;
227
+ case EShapeStrokeSide.BOTTOM_OR_LEFT:
228
+ if (ay <= ax) {
229
+ this.updateBottomLeft0(fx, fy, ax, ay, scale, radius, corner, nv, ni);
230
+ }
231
+ else {
232
+ this.updateBottomLeft1(fx, fy, ax, ay, scale, radius, corner, nv, ni);
233
+ }
234
+ break;
235
+ case EShapeStrokeSide.NOT_TOP:
236
+ if (ay <= ax) {
237
+ this.updateNotTop0(fx, fy, ax, ay, scale, radius, corner, nv, ni);
238
+ }
239
+ else {
240
+ this.updateNotTop1(fx, fy, ax, ay, scale, radius, corner, nv, ni);
241
+ }
242
+ break;
243
+ case EShapeStrokeSide.NOT_RIGHT:
244
+ if (ay <= ax) {
245
+ this.updateNotRight0(fx, fy, ax, ay, scale, radius, corner, nv, ni);
246
+ }
247
+ else {
248
+ this.updateNotRight1(fx, fy, ax, ay, scale, radius, corner, nv, ni);
249
+ }
250
+ break;
251
+ case EShapeStrokeSide.NOT_BOTTOM:
252
+ if (ay <= ax) {
253
+ this.updateNotBottom0(fx, fy, ax, ay, scale, radius, corner, nv, ni);
254
+ }
255
+ else {
256
+ this.updateNotBottom1(fx, fy, ax, ay, scale, radius, corner, nv, ni);
257
+ }
258
+ break;
259
+ case EShapeStrokeSide.NOT_LEFT:
260
+ if (ay <= ax) {
261
+ this.updateNotLeft0(fx, fy, ax, ay, scale, radius, corner, nv, ni);
262
+ }
263
+ else {
264
+ this.updateNotLeft1(fx, fy, ax, ay, scale, radius, corner, nv, ni);
265
+ }
266
+ break;
267
+ }
268
+ }
269
+ };
270
+ /**
271
+ * Fills the unused tail with degenerated triangles and trims the arrays
272
+ * so that the buffers always hold exactly `nv` vertices and `ni` triangles.
273
+ */
274
+ EShapeRectangleRoundedTriangulatedImpl.prototype.pad = function (iv, ii, nv, ni, fd) {
275
+ var vertices = this._vertices;
276
+ var distances = this._distances;
277
+ var lengths = this._lengths;
278
+ var clippings = this._clippings;
279
+ var uvs = this._uvs;
280
+ var indices = this._indices;
281
+ for (var i = iv; i < nv; ++i) {
282
+ var i2 = i << 1;
283
+ vertices[i2] = 0;
284
+ vertices[i2 + 1] = 0;
285
+ distances[i] = fd;
286
+ lengths[i] = 0;
287
+ clippings[i] = 0;
288
+ uvs[i2] = 0.5;
289
+ uvs[i2 + 1] = 0.5;
290
+ }
291
+ for (var i = ii, imax = ni * 3; i < imax; ++i) {
292
+ indices[i] = 0;
293
+ }
294
+ var nv2 = nv << 1;
295
+ vertices.length = nv2;
296
+ distances.length = nv;
297
+ lengths.length = nv;
298
+ clippings.length = nv;
299
+ uvs.length = nv2;
300
+ indices.length = ni * 3;
301
+ };
302
+ /**
303
+ * Preconditions:
304
+ * * shape.stroke.side === EShapeStrokeSide.TOP
305
+ * * 4 * N + 4 <= nv
306
+ * * 4 * N - 2 <= ni
307
+ */
308
+ EShapeRectangleRoundedTriangulatedImpl.prototype.updateTop = function (fx, fy, ax, ay, scale, radius, corner, nv, ni) {
309
+ var d = 2 * ay;
310
+ var fd = 1 / d;
311
+ var n = this._n >> 2;
312
+ var fs = (scale - 1) * d;
313
+ var r = radius * Math.min(ax, ay);
314
+ var cr = 0 < radius;
315
+ var ctl = cr && !!(corner & EShapeCorner.TOP_LEFT);
316
+ var ctr = cr && !!(corner & EShapeCorner.TOP_RIGHT);
317
+ var cbl = cr && !!(corner & EShapeCorner.BOTTOM_LEFT);
318
+ var cbr = cr && !!(corner & EShapeCorner.BOTTOM_RIGHT);
319
+ var xl = ctl || cbl ? -ax + r : -ax;
320
+ var xr = ctr || cbr ? +ax - r : +ax;
321
+ var yt = -ay - fs;
322
+ var yb = +ay;
323
+ var lot = 0;
324
+ var iv = 0;
325
+ var ii = 0;
326
+ this.writeQuadTop(iv, ii, lot, xl, yt, xr, yt, xr, yb, xl, yb, fd, scale, fx, fy, ax, ay);
327
+ iv += 4;
328
+ ii += 6;
329
+ if (ctr || cbr) {
330
+ this.writeStripTop(+1, xr, ctr, cbr, lot, iv, ii, n, r, ax, ay, scale, d, fd, fx, fy);
331
+ iv += 2 * n;
332
+ ii += 6 * (n - 1);
333
+ }
334
+ if (ctl || cbl) {
335
+ this.writeStripTop(-1, xl, ctl, cbl, lot, iv, ii, n, r, ax, ay, scale, d, fd, fx, fy);
336
+ iv += 2 * n;
337
+ ii += 6 * (n - 1);
338
+ }
339
+ this.pad(iv, ii, nv, ni, fd);
340
+ };
341
+ EShapeRectangleRoundedTriangulatedImpl.prototype.writeStripTop = function (sign, xi, ct, cb, lo, iv, ii, n, r, ax, ay, scale, d, fd, fx, fy) {
342
+ var cos = 1;
343
+ var sin = 0;
344
+ var dangle = (Math.PI * 0.5) / (n - 1);
345
+ var dcos = Math.cos(dangle);
346
+ var dsin = Math.sin(dangle);
347
+ var indices = this._indices;
348
+ for (var i = 0; i < n; ++i) {
349
+ var x = xi + sign * r * sin;
350
+ var raise = r * (1 - cos);
351
+ var ytop = ct ? -ay + raise : -ay - (scale - 1) * d;
352
+ var ybottom = cb ? +ay - raise : +ay;
353
+ var length_1 = lo + x + ax;
354
+ var ctop = Math.min(scale, (ytop + ay) * -fd + 1);
355
+ var cbottom = Math.min(scale, (ybottom + ay) * -fd + 1);
356
+ this.writeVertex(iv, x, ytop, fd, length_1, ctop, fx, fy);
357
+ this.writeVertex(iv + 1, x, ybottom, fd, length_1, cbottom, fx, fy);
358
+ if (0 < i) {
359
+ indices[ii++] = iv - 2;
360
+ indices[ii++] = iv - 1;
361
+ indices[ii++] = iv + 1;
362
+ indices[ii++] = iv - 2;
363
+ indices[ii++] = iv + 1;
364
+ indices[ii++] = iv;
365
+ }
366
+ iv += 2;
367
+ var ncos = dcos * cos - dsin * sin;
368
+ var nsin = dsin * cos + dcos * sin;
369
+ cos = ncos;
370
+ sin = nsin;
371
+ }
372
+ };
373
+ /**
374
+ * Preconditions:
375
+ * * shape.stroke.side === EShapeStrokeSide.RIGHT
376
+ * * 4 * N + 4 <= nv
377
+ * * 4 * N - 2 <= ni
378
+ */
379
+ EShapeRectangleRoundedTriangulatedImpl.prototype.updateRight = function (fx, fy, ax, ay, scale, radius, corner, nv, ni) {
380
+ var d = 2 * ax;
381
+ var fd = 1 / d;
382
+ var n = this._n >> 2;
383
+ var fs = (scale - 1) * d;
384
+ var r = radius * Math.min(ax, ay);
385
+ var cr = 0 < radius;
386
+ var ctl = cr && !!(corner & EShapeCorner.TOP_LEFT);
387
+ var ctr = cr && !!(corner & EShapeCorner.TOP_RIGHT);
388
+ var cbl = cr && !!(corner & EShapeCorner.BOTTOM_LEFT);
389
+ var cbr = cr && !!(corner & EShapeCorner.BOTTOM_RIGHT);
390
+ var yt = ctl || ctr ? -ay + r : -ay;
391
+ var yb = cbl || cbr ? +ay - r : +ay;
392
+ var xl = -ax;
393
+ var xr = +ax + fs;
394
+ var lot = 0;
395
+ var lor = lot + 2 * ax;
396
+ var iv = 0;
397
+ var ii = 0;
398
+ this.writeQuadRight(iv, ii, lor, xl, yt, xr, yt, xr, yb, xl, yb, fd, scale, fx, fy, ax, ay);
399
+ iv += 4;
400
+ ii += 6;
401
+ if (ctl || ctr) {
402
+ this.writeStripRight(-1, yt, ctl, ctr, lor, iv, ii, n, r, ax, ay, scale, d, fd, fx, fy);
403
+ iv += 2 * n;
404
+ ii += 6 * (n - 1);
405
+ }
406
+ if (cbl || cbr) {
407
+ this.writeStripRight(+1, yb, cbl, cbr, lor, iv, ii, n, r, ax, ay, scale, d, fd, fx, fy);
408
+ iv += 2 * n;
409
+ ii += 6 * (n - 1);
410
+ }
411
+ this.pad(iv, ii, nv, ni, fd);
412
+ };
413
+ EShapeRectangleRoundedTriangulatedImpl.prototype.writeStripRight = function (sign, yi, cl, cr, lo, iv, ii, n, r, ax, ay, scale, d, fd, fx, fy) {
414
+ var cos = 1;
415
+ var sin = 0;
416
+ var dangle = (Math.PI * 0.5) / (n - 1);
417
+ var dcos = Math.cos(dangle);
418
+ var dsin = Math.sin(dangle);
419
+ var indices = this._indices;
420
+ for (var i = 0; i < n; ++i) {
421
+ var y = yi + sign * r * sin;
422
+ var raise = r * (1 - cos);
423
+ var xleft = cl ? -ax + raise : -ax;
424
+ var xright = cr ? +ax - raise : +ax + (scale - 1) * d;
425
+ var length_2 = lo + y + ay;
426
+ var cleft = Math.min(scale, (xleft - ax) * fd + 1);
427
+ var cright = Math.min(scale, (xright - ax) * fd + 1);
428
+ this.writeVertex(iv, xleft, y, fd, length_2, cleft, fx, fy);
429
+ this.writeVertex(iv + 1, xright, y, fd, length_2, cright, fx, fy);
430
+ if (0 < i) {
431
+ indices[ii++] = iv - 2;
432
+ indices[ii++] = iv - 1;
433
+ indices[ii++] = iv + 1;
434
+ indices[ii++] = iv - 2;
435
+ indices[ii++] = iv + 1;
436
+ indices[ii++] = iv;
437
+ }
438
+ iv += 2;
439
+ var ncos = dcos * cos - dsin * sin;
440
+ var nsin = dsin * cos + dcos * sin;
441
+ cos = ncos;
442
+ sin = nsin;
443
+ }
444
+ };
445
+ /**
446
+ * Preconditions:
447
+ * * shape.stroke.side === EShapeStrokeSide.BOTTOM
448
+ * * 4 * N + 4 <= nv
449
+ * * 4 * N - 2 <= ni
450
+ */
451
+ EShapeRectangleRoundedTriangulatedImpl.prototype.updateBottom = function (fx, fy, ax, ay, scale, radius, corner, nv, ni) {
452
+ var n = this._n >> 2;
453
+ var r = radius * Math.min(ax, ay);
454
+ var d = 2 * ay;
455
+ var fd = 1 / d;
456
+ var cr = 0 < radius;
457
+ var ctl = cr && !!(corner & EShapeCorner.TOP_LEFT);
458
+ var ctr = cr && !!(corner & EShapeCorner.TOP_RIGHT);
459
+ var cbl = cr && !!(corner & EShapeCorner.BOTTOM_LEFT);
460
+ var cbr = cr && !!(corner & EShapeCorner.BOTTOM_RIGHT);
461
+ var xl = ctl || cbl ? -ax + r : -ax;
462
+ var xr = ctr || cbr ? +ax - r : +ax;
463
+ var yt = -ay;
464
+ var yb = +ay + (scale - 1) * d;
465
+ var lot = 0;
466
+ var lor = lot + 2 * ax;
467
+ var lob = lor + 2 * ay;
468
+ var iv = 0;
469
+ var ii = 0;
470
+ this.writeQuadBottom(iv, ii, lob, xl, yt, xr, yt, xr, yb, xl, yb, fd, scale, fx, fy, ax, ay);
471
+ iv += 4;
472
+ ii += 6;
473
+ if (ctr || cbr) {
474
+ this.writeStripBottom(+1, xr, ctr, cbr, lob, iv, ii, n, r, ax, ay, scale, d, fd, fx, fy);
475
+ iv += 2 * n;
476
+ ii += 6 * (n - 1);
477
+ }
478
+ if (ctl || cbl) {
479
+ this.writeStripBottom(-1, xl, ctl, cbl, lob, iv, ii, n, r, ax, ay, scale, d, fd, fx, fy);
480
+ iv += 2 * n;
481
+ ii += 6 * (n - 1);
482
+ }
483
+ this.pad(iv, ii, nv, ni, fd);
484
+ };
485
+ /**
486
+ * Writes a vertical strip of a corner column (n lines, 2 vertices per line).
487
+ * Distance is constant and clipping depends only on y, so the stroke inner edge stays straight.
488
+ * `sign` is +1 for the right column and -1 for the left column.
489
+ * `xi` is X of the line at the column's inner edge.
490
+ */
491
+ EShapeRectangleRoundedTriangulatedImpl.prototype.writeStripBottom = function (sign, xi, ct, cb, lo, iv, ii, n, r, ax, ay, scale, d, fd, fx, fy) {
492
+ var cos = 1;
493
+ var sin = 0;
494
+ var dangle = (Math.PI * 0.5) / (n - 1);
495
+ var dcos = Math.cos(dangle);
496
+ var dsin = Math.sin(dangle);
497
+ var indices = this._indices;
498
+ for (var i = 0; i < n; ++i) {
499
+ var x = xi + sign * r * sin;
500
+ var raise = r * (1 - cos);
501
+ var ytop = -ay + (ct ? raise : 0);
502
+ var ybottom = cb ? +ay - raise : +ay + (scale - 1) * d;
503
+ var length_3 = lo + ax - x;
504
+ var ctop = Math.min(scale, (ytop - ay) * fd + 1);
505
+ var cbottom = Math.min(scale, (ybottom - ay) * fd + 1);
506
+ this.writeVertex(iv, x, ytop, fd, length_3, ctop, fx, fy);
507
+ this.writeVertex(iv + 1, x, ybottom, fd, length_3, cbottom, fx, fy);
508
+ if (0 < i) {
509
+ indices[ii++] = iv - 2;
510
+ indices[ii++] = iv - 1;
511
+ indices[ii++] = iv + 1;
512
+ indices[ii++] = iv - 2;
513
+ indices[ii++] = iv + 1;
514
+ indices[ii++] = iv;
515
+ }
516
+ iv += 2;
517
+ var ncos = dcos * cos - dsin * sin;
518
+ var nsin = dsin * cos + dcos * sin;
519
+ cos = ncos;
520
+ sin = nsin;
521
+ }
522
+ };
523
+ /**
524
+ * Preconditions:
525
+ * * shape.stroke.side === EShapeStrokeSide.LEFT
526
+ * * 4 * N + 4 <= nv
527
+ * * 4 * N - 2 <= ni
528
+ */
529
+ EShapeRectangleRoundedTriangulatedImpl.prototype.updateLeft = function (fx, fy, ax, ay, scale, radius, corner, nv, ni) {
530
+ var d = 2 * ax;
531
+ var fd = 1 / d;
532
+ var n = this._n >> 2;
533
+ var fs = (scale - 1) * d;
534
+ var r = radius * Math.min(ax, ay);
535
+ var cr = 0 < radius;
536
+ var ctl = cr && !!(corner & EShapeCorner.TOP_LEFT);
537
+ var ctr = cr && !!(corner & EShapeCorner.TOP_RIGHT);
538
+ var cbl = cr && !!(corner & EShapeCorner.BOTTOM_LEFT);
539
+ var cbr = cr && !!(corner & EShapeCorner.BOTTOM_RIGHT);
540
+ var yt = ctl || ctr ? -ay + r : -ay;
541
+ var yb = cbl || cbr ? +ay - r : +ay;
542
+ var xl = -ax - fs;
543
+ var xr = +ax;
544
+ var lot = 0;
545
+ var lor = lot + 2 * ax;
546
+ var lob = lor + 2 * ay;
547
+ var lol = lob + 2 * ax;
548
+ var iv = 0;
549
+ var ii = 0;
550
+ this.writeQuadLeft(iv, ii, lol, xl, yt, xr, yt, xr, yb, xl, yb, fd, scale, fx, fy, ax, ay);
551
+ iv += 4;
552
+ ii += 6;
553
+ if (ctl || ctr) {
554
+ this.writeStripLeft(-1, yt, ctl, ctr, lol, iv, ii, n, r, ax, ay, scale, d, fd, fx, fy);
555
+ iv += 2 * n;
556
+ ii += 6 * (n - 1);
557
+ }
558
+ if (cbl || cbr) {
559
+ this.writeStripLeft(+1, yb, cbl, cbr, lol, iv, ii, n, r, ax, ay, scale, d, fd, fx, fy);
560
+ iv += 2 * n;
561
+ ii += 6 * (n - 1);
562
+ }
563
+ this.pad(iv, ii, nv, ni, fd);
564
+ };
565
+ EShapeRectangleRoundedTriangulatedImpl.prototype.writeStripLeft = function (sign, yi, cl, cr, lo, iv, ii, n, r, ax, ay, scale, d, fd, fx, fy) {
566
+ var cos = 1;
567
+ var sin = 0;
568
+ var dangle = (Math.PI * 0.5) / (n - 1);
569
+ var dcos = Math.cos(dangle);
570
+ var dsin = Math.sin(dangle);
571
+ var indices = this._indices;
572
+ for (var i = 0; i < n; ++i) {
573
+ var y = yi + sign * r * sin;
574
+ var raise = r * (1 - cos);
575
+ var xleft = cl ? -ax + raise : -ax - (scale - 1) * d;
576
+ var xright = cr ? +ax - raise : +ax;
577
+ var length_4 = lo + ay - y;
578
+ var cleft = Math.min(scale, (xleft + ax) * -fd + 1);
579
+ var cright = Math.min(scale, (xright + ax) * -fd + 1);
580
+ this.writeVertex(iv, xleft, y, fd, length_4, cleft, fx, fy);
581
+ this.writeVertex(iv + 1, xright, y, fd, length_4, cright, fx, fy);
582
+ if (0 < i) {
583
+ indices[ii++] = iv - 2;
584
+ indices[ii++] = iv - 1;
585
+ indices[ii++] = iv + 1;
586
+ indices[ii++] = iv - 2;
587
+ indices[ii++] = iv + 1;
588
+ indices[ii++] = iv;
589
+ }
590
+ iv += 2;
591
+ var ncos = dcos * cos - dsin * sin;
592
+ var nsin = dsin * cos + dcos * sin;
593
+ cos = ncos;
594
+ sin = nsin;
595
+ }
596
+ };
597
+ /**
598
+ * Preconditions:
599
+ * * shape.stroke.side === EShapeStrokeSide.LEFT_OR_RIGHT
600
+ * * 4 * N + 4 <= nv
601
+ * * 4 * N + 0 <= ni
602
+ */
603
+ EShapeRectangleRoundedTriangulatedImpl.prototype.updateLeftRight = function (fx, fy, ax, ay, scale, radius, corner, nv, ni) {
604
+ var fd = 1 / ax;
605
+ var n = this._n >> 2;
606
+ var r = radius * Math.min(ax, ay);
607
+ var cr = 0 < radius;
608
+ var ctl = cr && !!(corner & EShapeCorner.TOP_LEFT);
609
+ var ctr = cr && !!(corner & EShapeCorner.TOP_RIGHT);
610
+ var cbl = cr && !!(corner & EShapeCorner.BOTTOM_LEFT);
611
+ var cbr = cr && !!(corner & EShapeCorner.BOTTOM_RIGHT);
612
+ var lot = 0;
613
+ var lor = lot + 2 * ax;
614
+ var lob = lor + 2 * ay;
615
+ var lol = lob + 2 * ax;
616
+ var iv = 0;
617
+ var ii = 0;
618
+ this.writeSideLeftRight0(lol, ctl, cbl, iv, ii, n, r, ax, ay, scale, fd, fx, fy);
619
+ iv += 2 * n + 2;
620
+ ii += 6 * n;
621
+ this.writeSideLeftRight1(lor, ctr, cbr, iv, ii, n, r, ax, ay, scale, fd, fx, fy);
622
+ iv += 2 * n + 2;
623
+ ii += 6 * n;
624
+ this.pad(iv, ii, nv, ni, fd);
625
+ };
626
+ /**
627
+ * Writes the left (`sx` = -1) or the right (`sx` = +1) half as a triangle fan of 2N + 2 vertices.
628
+ * Order: the top center (fan origin), the bottom center, the bottom arc (N), the top arc (N).
629
+ */
630
+ EShapeRectangleRoundedTriangulatedImpl.prototype.writeSideLeftRight0 = function (lo, ct, cb, iv, ii, n, r, ax, ay, scale, fd, fx, fy) {
631
+ var fs = (scale - 1) / fd;
632
+ var xo = -ax - fs;
633
+ var dangle = (Math.PI * 0.5) / (n - 1);
634
+ var dcos = Math.cos(dangle);
635
+ var dsin = Math.sin(dangle);
636
+ this.writeVertexLeft(iv, 0, -ay, lo, fd, scale, fx, fy, ax, ay);
637
+ this.writeVertexLeft(iv + 1, 0, +ay, lo, fd, scale, fx, fy, ax, ay);
638
+ var ib = iv + 2;
639
+ var it = ib + n;
640
+ var cos = 1;
641
+ var sin = 0;
642
+ for (var i = 0; i < n; ++i) {
643
+ // The bottom arc runs from the bottom tangent point to the left one, so its angle is pi / 2 - i * dangle.
644
+ var xb = cb && i < n - 1 ? -ax + r - r * sin : xo;
645
+ var yb = cb ? +ay - r + r * cos : +ay;
646
+ this.writeVertexLeft(ib + i, xb, yb, lo, fd, scale, fx, fy, ax, ay);
647
+ var xt = ct && 0 < i ? -ax + r - r * cos : xo;
648
+ var yt = ct ? -ay + r - r * sin : -ay;
649
+ this.writeVertexLeft(it + i, xt, yt, lo, fd, scale, fx, fy, ax, ay);
650
+ var ncos = dcos * cos - dsin * sin;
651
+ var nsin = dsin * cos + dcos * sin;
652
+ cos = ncos;
653
+ sin = nsin;
654
+ }
655
+ var indices = this._indices;
656
+ for (var i = 1, imax = 2 * n + 1; i < imax; ++i) {
657
+ indices[ii++] = iv;
658
+ indices[ii++] = iv + i;
659
+ indices[ii++] = iv + i + 1;
660
+ }
661
+ };
662
+ /**
663
+ * Writes the left (`sx` = -1) or the right (`sx` = +1) half as a triangle fan of 2N + 2 vertices.
664
+ * Order: the top center (fan origin), the bottom center, the bottom arc (N), the top arc (N).
665
+ */
666
+ EShapeRectangleRoundedTriangulatedImpl.prototype.writeSideLeftRight1 = function (lo, ct, cb, iv, ii, n, r, ax, ay, scale, fd, fx, fy) {
667
+ var fs = (scale - 1) / fd;
668
+ var xo = -ax - fs;
669
+ var dangle = (Math.PI * 0.5) / (n - 1);
670
+ var dcos = Math.cos(dangle);
671
+ var dsin = Math.sin(dangle);
672
+ this.writeVertexRight(iv, 0, -ay, lo, fd, scale, fx, fy, ax, ay);
673
+ this.writeVertexRight(iv + 1, 0, +ay, lo, fd, scale, fx, fy, ax, ay);
674
+ var ib = iv + 2;
675
+ var it = ib + n;
676
+ var cos = 1;
677
+ var sin = 0;
678
+ for (var i = 0; i < n; ++i) {
679
+ // The bottom arc runs from the bottom tangent point to the left one, so its angle is pi / 2 - i * dangle.
680
+ var xb = cb && i < n - 1 ? -ax + r - r * sin : xo;
681
+ var yb = cb ? +ay - r + r * cos : +ay;
682
+ this.writeVertexRight(ib + i, -xb, yb, lo, fd, scale, fx, fy, ax, ay);
683
+ var xt = ct && 0 < i ? -ax + r - r * cos : xo;
684
+ var yt = ct ? -ay + r - r * sin : -ay;
685
+ this.writeVertexRight(it + i, -xt, yt, lo, fd, scale, fx, fy, ax, ay);
686
+ var ncos = dcos * cos - dsin * sin;
687
+ var nsin = dsin * cos + dcos * sin;
688
+ cos = ncos;
689
+ sin = nsin;
690
+ }
691
+ var indices = this._indices;
692
+ for (var i = 1, imax = 2 * n + 1; i < imax; ++i) {
693
+ indices[ii++] = iv;
694
+ indices[ii++] = iv + i + 1;
695
+ indices[ii++] = iv + i;
696
+ }
697
+ };
698
+ /**
699
+ * Preconditions:
700
+ * * shape.stroke.side === EShapeStrokeSide.TOP_OR_BOTTOM
701
+ * * 4 * N + 4 <= nv
702
+ * * 4 * N + 0 <= ni
703
+ */
704
+ EShapeRectangleRoundedTriangulatedImpl.prototype.updateTopBottom = function (fx, fy, ax, ay, scale, radius, corner, nv, ni) {
705
+ var fd = 1 / ay;
706
+ var n = this._n >> 2;
707
+ var r = radius * Math.min(ax, ay);
708
+ var cr = 0 < radius;
709
+ var ctl = cr && !!(corner & EShapeCorner.TOP_LEFT);
710
+ var ctr = cr && !!(corner & EShapeCorner.TOP_RIGHT);
711
+ var cbl = cr && !!(corner & EShapeCorner.BOTTOM_LEFT);
712
+ var cbr = cr && !!(corner & EShapeCorner.BOTTOM_RIGHT);
713
+ var lot = 0;
714
+ var lor = lot + 2 * ax;
715
+ var lob = lor + 2 * ay;
716
+ var iv = 0;
717
+ var ii = 0;
718
+ this.writeSideTopBottom0(lot, ctl, ctr, iv, ii, n, r, ax, ay, scale, fd, fx, fy);
719
+ iv += 2 * n + 2;
720
+ ii += 6 * n;
721
+ this.writeSideTopBottom1(lob, cbl, cbr, iv, ii, n, r, ax, ay, scale, fd, fx, fy);
722
+ iv += 2 * n + 2;
723
+ ii += 6 * n;
724
+ this.pad(iv, ii, nv, ni, fd);
725
+ };
726
+ EShapeRectangleRoundedTriangulatedImpl.prototype.writeSideTopBottom0 = function (lo, cl, cr, iv, ii, n, r, ax, ay, scale, fd, fx, fy) {
727
+ var fs = (scale - 1) / fd;
728
+ var yo = -ay - fs;
729
+ var cos = 1;
730
+ var sin = 0;
731
+ var dangle = (Math.PI * 0.5) / (n - 1);
732
+ var dcos = Math.cos(dangle);
733
+ var dsin = Math.sin(dangle);
734
+ var indices = this._indices;
735
+ this.writeVertexTop(iv, -ax, 0, lo, fd, scale, fx, fy, ax, ay);
736
+ this.writeVertexTop(iv + 1, +ax, 0, lo, fd, scale, fx, fy, ax, ay);
737
+ var ir = iv + 2;
738
+ var il = ir + n;
739
+ for (var i = 0; i < n; ++i) {
740
+ var xr = cr ? +ax - r + r * cos : +ax;
741
+ var yr = cr && i < n - 1 ? -ay + r - r * sin : yo;
742
+ var xl = cl ? -ax + r - r * sin : -ax;
743
+ var yl = cl && 0 < i ? -ay + r - r * cos : yo;
744
+ this.writeVertexTop(ir + i, xr, yr, lo, fd, scale, fx, fy, ax, ay);
745
+ this.writeVertexTop(il + i, xl, yl, lo, fd, scale, fx, fy, ax, ay);
746
+ var ncos = dcos * cos - dsin * sin;
747
+ var nsin = dsin * cos + dcos * sin;
748
+ cos = ncos;
749
+ sin = nsin;
750
+ }
751
+ for (var i = 1, imax = 2 * n + 1; i < imax; ++i) {
752
+ indices[ii++] = iv;
753
+ indices[ii++] = iv + i;
754
+ indices[ii++] = iv + i + 1;
755
+ }
756
+ };
757
+ EShapeRectangleRoundedTriangulatedImpl.prototype.writeSideTopBottom1 = function (lo, cl, cr, iv, ii, n, r, ax, ay, scale, fd, fx, fy) {
758
+ var fs = (scale - 1) / fd;
759
+ var yo = -ay - fs;
760
+ var cos = 1;
761
+ var sin = 0;
762
+ var dangle = (Math.PI * 0.5) / (n - 1);
763
+ var dcos = Math.cos(dangle);
764
+ var dsin = Math.sin(dangle);
765
+ var indices = this._indices;
766
+ this.writeVertexBottom(iv, -ax, 0, lo, fd, scale, fx, fy, ax, ay);
767
+ this.writeVertexBottom(iv + 1, +ax, 0, lo, fd, scale, fx, fy, ax, ay);
768
+ var ir = iv + 2;
769
+ var il = ir + n;
770
+ for (var i = 0; i < n; ++i) {
771
+ var xr = cr ? +ax - r + r * cos : +ax;
772
+ var yr = cr && i < n - 1 ? -ay + r - r * sin : yo;
773
+ var xl = cl ? -ax + r - r * sin : -ax;
774
+ var yl = cl && 0 < i ? -ay + r - r * cos : yo;
775
+ this.writeVertexBottom(ir + i, xr, -yr, lo, fd, scale, fx, fy, ax, ay);
776
+ this.writeVertexBottom(il + i, xl, -yl, lo, fd, scale, fx, fy, ax, ay);
777
+ var ncos = dcos * cos - dsin * sin;
778
+ var nsin = dsin * cos + dcos * sin;
779
+ cos = ncos;
780
+ sin = nsin;
781
+ }
782
+ for (var i = 1, imax = 2 * n + 1; i < imax; ++i) {
783
+ indices[ii++] = iv;
784
+ indices[ii++] = iv + i + 1;
785
+ indices[ii++] = iv + i;
786
+ }
787
+ };
788
+ /**
789
+ * Preconditions:
790
+ * * shape.stroke.side === EShapeStrokeSide.TOP_OR_RIGHT
791
+ * * ay <= ax
792
+ * * 5 * N + 5 <= nv
793
+ * * 4 * N + 1 <= ni
794
+ */
795
+ EShapeRectangleRoundedTriangulatedImpl.prototype.updateTopRight0 = function (fx, fy, ax, ay, scale, radius, corner, nv, ni) {
796
+ var r = radius * ay;
797
+ this.writeTopRight(fx, fy, ax, ay, scale, 2 * ay, r, corner, ax - 2 * ay, ay, 0, nv, ni);
798
+ };
799
+ /**
800
+ * Preconditions:
801
+ * * shape.stroke.side === EShapeStrokeSide.TOP_OR_RIGHT
802
+ * * ax < ay
803
+ * * 5 * N + 5 <= nv
804
+ * * 4 * N + 1 <= ni
805
+ */
806
+ EShapeRectangleRoundedTriangulatedImpl.prototype.updateTopRight1 = function (fx, fy, ax, ay, scale, radius, corner, nv, ni) {
807
+ var n = this._n >> 2;
808
+ var r = radius * ax;
809
+ this.writeTopRight(fx, fy, ax, ay, scale, 2 * ax, r, corner, -ax, 2 * ax - ay, n, nv, ni);
810
+ };
811
+ /**
812
+ * `(xred, yred)` is where the diagonal border meets the bottom edge or the left edge.
813
+ * `k` is the number of the bottom-left arc vertices on the right side of that point.
814
+ */
815
+ EShapeRectangleRoundedTriangulatedImpl.prototype.writeTopRight = function (fx, fy, ax, ay, scale, d, r, corner, xred, yred, k, nv, ni) {
816
+ var fd = 1 / d;
817
+ var n = this._n >> 2;
818
+ var fs = (scale - 1) * d;
819
+ var rs = r + fs;
820
+ var cr = 0 < r;
821
+ var ctl = cr && !!(corner & EShapeCorner.TOP_LEFT);
822
+ var ctr = cr && !!(corner & EShapeCorner.TOP_RIGHT);
823
+ var cbl = cr && !!(corner & EShapeCorner.BOTTOM_LEFT);
824
+ var cbr = cr && !!(corner & EShapeCorner.BOTTOM_RIGHT);
825
+ var lc = 0.5 * Math.PI * r - 2 * r;
826
+ var lot = ctl ? -r : 0;
827
+ var lor = lot + 2 * ax + (ctr ? lc : 0);
828
+ var dangle = (Math.PI * 0.5) / (n - 1);
829
+ var xo = +ax + fs;
830
+ var yo = -ay - fs;
831
+ // The diagonal border between the top and the right sides is x + y = ax - ay.
832
+ // It starts from the center of the top-right corner.
833
+ var xc = ctr ? +ax - r : xo;
834
+ var yc = ctr ? -ay + r : yo;
835
+ // The red point is on the bottom-left arc if the border meets the bottom-left corner.
836
+ if (cbl && xred < -ax + r && ay - r < yred) {
837
+ var e = ax - ay;
838
+ var z = Math.sqrt(0.5 * r * r - e * e);
839
+ xred = -ax + r - z + e;
840
+ yred = +ay - r + z + e;
841
+ k = Math.ceil(Math.atan2(z - e, z + e) / dangle);
842
+ }
843
+ // Bottom-right polygon of N + k + 3 vertices as a triangle fan.
844
+ // Order: the corner center (fan origin), the right end, the bottom-right arc (N), the bottom-left arc (k), the red point.
845
+ var iv = 0;
846
+ var ii = 0;
847
+ this.writeVertexRight(iv++, xc, yc, lor, fd, scale, fx, fy, ax, ay);
848
+ this.writeVertexRight(iv++, xo, yc, lor, fd, scale, fx, fy, ax, ay);
849
+ var dcos = Math.cos(dangle);
850
+ var dsin = Math.sin(dangle);
851
+ var cos = 1;
852
+ var sin = 0;
853
+ if (cbr) {
854
+ for (var i = 0; i < n; ++i) {
855
+ var x = 0 < i ? ax - r + r * cos : xo;
856
+ var y = +ay - r + r * sin;
857
+ this.writeVertexRight(iv++, x, y, lor, fd, scale, fx, fy, ax, ay);
858
+ var ncos = dcos * cos - dsin * sin;
859
+ var nsin = dsin * cos + dcos * sin;
860
+ cos = ncos;
861
+ sin = nsin;
862
+ }
863
+ }
864
+ else {
865
+ for (var i = 0; i < n; ++i) {
866
+ this.writeVertexRight(iv++, xo, ay, lor, fd, scale, fx, fy, ax, ay);
867
+ }
868
+ }
869
+ if (cbl) {
870
+ cos = 1;
871
+ sin = 0;
872
+ for (var i = 0; i < k; ++i) {
873
+ var x = -ax + r - r * sin;
874
+ var y = +ay - r + r * cos;
875
+ this.writeVertexRight(iv++, x, y, lor, fd, scale, fx, fy, ax, ay);
876
+ var ncos = dcos * cos - dsin * sin;
877
+ var nsin = dsin * cos + dcos * sin;
878
+ cos = ncos;
879
+ sin = nsin;
880
+ }
881
+ }
882
+ else {
883
+ for (var i = 0; i < k; ++i) {
884
+ this.writeVertexRight(iv++, -ax, ay, lor, fd, scale, fx, fy, ax, ay);
885
+ }
886
+ }
887
+ this.writeVertexRight(iv++, xred, yred, lor, fd, scale, fx, fy, ax, ay);
888
+ this.writeFanIndices(0, ii, iv);
889
+ ii += 3 * (iv - 2);
890
+ // Top-left polygon of M + N + 3 vertices as a triangle fan, where M = N - k.
891
+ // Order: the corner center (fan origin), the red point, the bottom-left arc (M), the top-left arc (N), the top end.
892
+ var iv0 = iv;
893
+ this.writeVertexTop(iv++, xc, yc, lot, fd, scale, fx, fy, ax, ay);
894
+ this.writeVertexTop(iv++, xred, yred, lot, fd, scale, fx, fy, ax, ay);
895
+ if (cbl) {
896
+ for (var i = k; i < n; ++i) {
897
+ var x = -ax + r - r * sin;
898
+ var y = +ay - r + r * cos;
899
+ this.writeVertexTop(iv++, x, y, lot, fd, scale, fx, fy, ax, ay);
900
+ var ncos = dcos * cos - dsin * sin;
901
+ var nsin = dsin * cos + dcos * sin;
902
+ cos = ncos;
903
+ sin = nsin;
904
+ }
905
+ }
906
+ else {
907
+ for (var i = k; i < n; ++i) {
908
+ this.writeVertexTop(iv++, -ax, ay, lot, fd, scale, fx, fy, ax, ay);
909
+ }
910
+ }
911
+ if (ctl) {
912
+ cos = 1;
913
+ sin = 0;
914
+ for (var i = 0; i < n; ++i) {
915
+ var x = -ax + r - r * cos;
916
+ var y = i < n - 1 ? -ay + r - r * sin : yo;
917
+ this.writeVertexTop(iv++, x, y, lot, fd, scale, fx, fy, ax, ay);
918
+ var ncos = dcos * cos - dsin * sin;
919
+ var nsin = dsin * cos + dcos * sin;
920
+ cos = ncos;
921
+ sin = nsin;
922
+ }
923
+ }
924
+ else {
925
+ for (var i = 0; i < n; ++i) {
926
+ this.writeVertexTop(iv++, -ax, yo, lot, fd, scale, fx, fy, ax, ay);
927
+ }
928
+ }
929
+ this.writeVertexTop(iv++, xc, yo, lot, fd, scale, fx, fy, ax, ay);
930
+ this.writeFanIndices(iv0, ii, iv - iv0);
931
+ ii += 3 * (iv - iv0 - 2);
932
+ if (ctr) {
933
+ var lo = lot + 2 * ax - r;
934
+ this.writeFan(+ax - r, -ay + r, 0, -1, lo, iv, ii, n, r, rs, fd, scale, fx, fy);
935
+ iv += 2 * n - 1;
936
+ ii += 3 * (n - 1);
937
+ }
938
+ this.pad(iv, ii, nv, ni, fd);
939
+ };
940
+ /**
941
+ * Preconditions:
942
+ * * shape.stroke.side === EShapeStrokeSide.BOTTOM_OR_LEFT
943
+ * * ay <= ax
944
+ * * 5 * N + 5 <= nv
945
+ * * 4 * N + 1 <= ni
946
+ */
947
+ EShapeRectangleRoundedTriangulatedImpl.prototype.updateBottomLeft0 = function (fx, fy, ax, ay, scale, radius, corner, nv, ni) {
948
+ var r = radius * ay;
949
+ this.writeBottomLeft(fx, fy, ax, ay, scale, 2 * ay, r, corner, 2 * ay - ax, -ay, 0, nv, ni);
950
+ };
951
+ /**
952
+ * Preconditions:
953
+ * * shape.stroke.side === EShapeStrokeSide.BOTTOM_OR_LEFT
954
+ * * ax < ay
955
+ * * 5 * N + 5 <= nv
956
+ * * 4 * N + 1 <= ni
957
+ */
958
+ EShapeRectangleRoundedTriangulatedImpl.prototype.updateBottomLeft1 = function (fx, fy, ax, ay, scale, radius, corner, nv, ni) {
959
+ var n = this._n >> 2;
960
+ var r = radius * ax;
961
+ this.writeBottomLeft(fx, fy, ax, ay, scale, 2 * ax, r, corner, ax, ay - 2 * ax, n, nv, ni);
962
+ };
963
+ /**
964
+ * `(xred, yred)` is where the diagonal border meets the top edge or the right edge.
965
+ * `k` is the number of the top-right arc vertices on the left side of that point.
966
+ */
967
+ EShapeRectangleRoundedTriangulatedImpl.prototype.writeBottomLeft = function (fx, fy, ax, ay, scale, d, r, corner, xred, yred, k, nv, ni) {
968
+ var fd = 1 / d;
969
+ var n = this._n >> 2;
970
+ var fs = (scale - 1) * d;
971
+ var rs = r + fs;
972
+ var cr = 0 < r;
973
+ var ctl = cr && !!(corner & EShapeCorner.TOP_LEFT);
974
+ var ctr = cr && !!(corner & EShapeCorner.TOP_RIGHT);
975
+ var cbl = cr && !!(corner & EShapeCorner.BOTTOM_LEFT);
976
+ var cbr = cr && !!(corner & EShapeCorner.BOTTOM_RIGHT);
977
+ var lc = 0.5 * Math.PI * r - 2 * r;
978
+ var lot = ctl ? -r : 0;
979
+ var lor = lot + 2 * ax + (ctr ? lc : 0);
980
+ var lob = lor + 2 * ay + (cbr ? lc : 0);
981
+ var lol = lob + 2 * ax + (cbl ? lc : 0);
982
+ var dangle = (Math.PI * 0.5) / (n - 1);
983
+ var xo = -ax - fs;
984
+ var yo = +ay + fs;
985
+ // The diagonal border between the left and the bottom sides is x + y = ay - ax.
986
+ // It starts from the center of the bottom-left corner.
987
+ var xc = cbl ? -ax + r : xo;
988
+ var yc = cbl ? +ay - r : yo;
989
+ // The red point is on the top-right arc if the border meets the top-right corner.
990
+ if (ctr && ax - r < xred && yred < -ay + r) {
991
+ var e = ax - ay;
992
+ var z = Math.sqrt(0.5 * r * r - e * e);
993
+ xred = ax - r + z - e;
994
+ yred = -ay + r - z - e;
995
+ k = Math.ceil(Math.atan2(z - e, z + e) / dangle);
996
+ }
997
+ // Top-left polygon of N + k + 3 vertices as a triangle fan.
998
+ // Order: the corner center (fan origin), the left end, the top-left arc (N), the top-right arc (k), the red point.
999
+ var iv = 0;
1000
+ var ii = 0;
1001
+ this.writeVertexLeft(iv++, xc, yc, lol, fd, scale, fx, fy, ax, ay);
1002
+ this.writeVertexLeft(iv++, xo, yc, lol, fd, scale, fx, fy, ax, ay);
1003
+ var dcos = Math.cos(dangle);
1004
+ var dsin = Math.sin(dangle);
1005
+ var cos = 1;
1006
+ var sin = 0;
1007
+ if (ctl) {
1008
+ for (var i = 0; i < n; ++i) {
1009
+ var x = 0 < i ? -ax + r - r * cos : xo;
1010
+ var y = -ay + r - r * sin;
1011
+ this.writeVertexLeft(iv++, x, y, lol, fd, scale, fx, fy, ax, ay);
1012
+ var ncos = dcos * cos - dsin * sin;
1013
+ var nsin = dsin * cos + dcos * sin;
1014
+ cos = ncos;
1015
+ sin = nsin;
1016
+ }
1017
+ }
1018
+ else {
1019
+ for (var i = 0; i < n; ++i) {
1020
+ this.writeVertexLeft(iv++, xo, -ay, lol, fd, scale, fx, fy, ax, ay);
1021
+ }
1022
+ }
1023
+ if (ctr) {
1024
+ cos = 1;
1025
+ sin = 0;
1026
+ for (var i = 0; i < k; ++i) {
1027
+ var x = ax - r + r * sin;
1028
+ var y = -ay + r - r * cos;
1029
+ this.writeVertexLeft(iv++, x, y, lol, fd, scale, fx, fy, ax, ay);
1030
+ var ncos = dcos * cos - dsin * sin;
1031
+ var nsin = dsin * cos + dcos * sin;
1032
+ cos = ncos;
1033
+ sin = nsin;
1034
+ }
1035
+ }
1036
+ else {
1037
+ for (var i = 0; i < k; ++i) {
1038
+ this.writeVertexLeft(iv++, ax, -ay, lol, fd, scale, fx, fy, ax, ay);
1039
+ }
1040
+ }
1041
+ this.writeVertexLeft(iv++, xred, yred, lol, fd, scale, fx, fy, ax, ay);
1042
+ this.writeFanIndices(0, ii, iv);
1043
+ ii += 3 * (iv - 2);
1044
+ // Bottom-right polygon of M + N + 3 vertices as a triangle fan, where M = N - k.
1045
+ // Order: the corner center (fan origin), the red point, the top-right arc (M), the bottom-right arc (N), the bottom end.
1046
+ var iv0 = iv;
1047
+ this.writeVertexBottom(iv++, xc, yc, lob, fd, scale, fx, fy, ax, ay);
1048
+ this.writeVertexBottom(iv++, xred, yred, lob, fd, scale, fx, fy, ax, ay);
1049
+ if (ctr) {
1050
+ for (var i = k; i < n; ++i) {
1051
+ var x = ax - r + r * sin;
1052
+ var y = -ay + r - r * cos;
1053
+ this.writeVertexBottom(iv++, x, y, lob, fd, scale, fx, fy, ax, ay);
1054
+ var ncos = dcos * cos - dsin * sin;
1055
+ var nsin = dsin * cos + dcos * sin;
1056
+ cos = ncos;
1057
+ sin = nsin;
1058
+ }
1059
+ }
1060
+ else {
1061
+ for (var i = k; i < n; ++i) {
1062
+ this.writeVertexBottom(iv++, ax, -ay, lob, fd, scale, fx, fy, ax, ay);
1063
+ }
1064
+ }
1065
+ if (cbr) {
1066
+ cos = 1;
1067
+ sin = 0;
1068
+ for (var i = 0; i < n; ++i) {
1069
+ var x = ax - r + r * cos;
1070
+ var y = i < n - 1 ? +ay - r + r * sin : yo;
1071
+ this.writeVertexBottom(iv++, x, y, lob, fd, scale, fx, fy, ax, ay);
1072
+ var ncos = dcos * cos - dsin * sin;
1073
+ var nsin = dsin * cos + dcos * sin;
1074
+ cos = ncos;
1075
+ sin = nsin;
1076
+ }
1077
+ }
1078
+ else {
1079
+ for (var i = 0; i < n; ++i) {
1080
+ this.writeVertexBottom(iv++, ax, yo, lob, fd, scale, fx, fy, ax, ay);
1081
+ }
1082
+ }
1083
+ this.writeVertexBottom(iv++, xc, yo, lob, fd, scale, fx, fy, ax, ay);
1084
+ this.writeFanIndices(iv0, ii, iv - iv0);
1085
+ ii += 3 * (iv - iv0 - 2);
1086
+ if (cbl) {
1087
+ var lo = lob + 2 * ax - r;
1088
+ this.writeFan(-ax + r, +ay - r, 0, 1, lo, iv, ii, n, r, rs, fd, scale, fx, fy);
1089
+ iv += 2 * n - 1;
1090
+ ii += 3 * (n - 1);
1091
+ }
1092
+ this.pad(iv, ii, nv, ni, fd);
1093
+ };
1094
+ EShapeRectangleRoundedTriangulatedImpl.prototype.writeFanIndices = function (iv, ii, count) {
1095
+ var indices = this._indices;
1096
+ for (var i = 1, imax = count - 1; i < imax; ++i) {
1097
+ indices[ii++] = iv;
1098
+ indices[ii++] = iv + i;
1099
+ indices[ii++] = iv + i + 1;
1100
+ }
1101
+ };
1102
+ /**
1103
+ * Preconditions:
1104
+ * * shape.stroke.side === EShapeStrokeSide.TOP_OR_LEFT
1105
+ * * ay <= ax
1106
+ * * 5 * N + 5 <= nv
1107
+ * * 4 * N + 1 <= ni
1108
+ */
1109
+ EShapeRectangleRoundedTriangulatedImpl.prototype.updateTopLeft0 = function (fx, fy, ax, ay, scale, radius, corner, nv, ni) {
1110
+ var r = radius * ay;
1111
+ this.writeTopLeft(fx, fy, ax, ay, scale, 2 * ay, r, corner, 2 * ay - ax, ay, 0, nv, ni);
1112
+ };
1113
+ /**
1114
+ * Preconditions:
1115
+ * * shape.stroke.side === EShapeStrokeSide.TOP_OR_LEFT
1116
+ * * ax < ay
1117
+ * * 5 * N + 5 <= nv
1118
+ * * 4 * N + 1 <= ni
1119
+ */
1120
+ EShapeRectangleRoundedTriangulatedImpl.prototype.updateTopLeft1 = function (fx, fy, ax, ay, scale, radius, corner, nv, ni) {
1121
+ var n = this._n >> 2;
1122
+ var r = radius * ax;
1123
+ this.writeTopLeft(fx, fy, ax, ay, scale, 2 * ax, r, corner, ax, 2 * ax - ay, n, nv, ni);
1124
+ };
1125
+ /**
1126
+ * `(xred, yred)` is where the diagonal border meets the bottom edge or the right edge.
1127
+ * `k` is the number of the bottom-right arc vertices before that point, counted from the bottom.
1128
+ */
1129
+ EShapeRectangleRoundedTriangulatedImpl.prototype.writeTopLeft = function (fx, fy, ax, ay, scale, d, r, corner, xred, yred, k, nv, ni) {
1130
+ var fd = 1 / d;
1131
+ var n = this._n >> 2;
1132
+ var fs = (scale - 1) * d;
1133
+ var rs = r + fs;
1134
+ var cr = 0 < r;
1135
+ var ctl = cr && !!(corner & EShapeCorner.TOP_LEFT);
1136
+ var ctr = cr && !!(corner & EShapeCorner.TOP_RIGHT);
1137
+ var cbl = cr && !!(corner & EShapeCorner.BOTTOM_LEFT);
1138
+ var cbr = cr && !!(corner & EShapeCorner.BOTTOM_RIGHT);
1139
+ var lc = 0.5 * Math.PI * r - 2 * r;
1140
+ var lot = ctl ? -r : 0;
1141
+ var lor = lot + 2 * ax + (ctr ? lc : 0);
1142
+ var lob = lor + 2 * ay + (cbr ? lc : 0);
1143
+ var lol = lob + 2 * ax + (cbl ? lc : 0);
1144
+ // The top side continues the left side beyond the top-left corner.
1145
+ var lop = lol + (ctl ? lc : 0) + 2 * ay;
1146
+ var dangle = (Math.PI * 0.5) / (n - 1);
1147
+ var xo = -ax - fs;
1148
+ var yo = -ay - fs;
1149
+ // The diagonal border between the top and the left sides is -x + y = ax - ay.
1150
+ // It starts from the center of the top-left corner.
1151
+ var xc = ctl ? -ax + r : xo;
1152
+ var yc = ctl ? -ay + r : yo;
1153
+ // The red point is on the bottom-right arc if the border meets the bottom-right corner.
1154
+ if (cbr && ax - r < xred && ay - r < yred) {
1155
+ var e = ax - ay;
1156
+ var z = Math.sqrt(0.5 * r * r - e * e);
1157
+ xred = ax - r + z - e;
1158
+ yred = +ay - r + z + e;
1159
+ k = Math.ceil(Math.atan2(z - e, z + e) / dangle);
1160
+ }
1161
+ // Bottom-left polygon of N + k + 3 vertices as a triangle fan.
1162
+ // Order: the corner center (fan origin), the red point, the bottom-right arc (k), the bottom-left arc (N), the left end.
1163
+ var iv = 0;
1164
+ var ii = 0;
1165
+ this.writeVertexLeft(iv++, xc, yc, lol, fd, scale, fx, fy, ax, ay);
1166
+ this.writeVertexLeft(iv++, xred, yred, lol, fd, scale, fx, fy, ax, ay);
1167
+ var dcos = Math.cos(dangle);
1168
+ var dsin = Math.sin(dangle);
1169
+ if (cbr) {
1170
+ var cos = 0;
1171
+ var sin = 1;
1172
+ if (0 < k) {
1173
+ for (var i = n - 1; k <= i; --i) {
1174
+ var ncos = dcos * cos + dsin * sin;
1175
+ var nsin = -dsin * cos + dcos * sin;
1176
+ cos = ncos;
1177
+ sin = nsin;
1178
+ }
1179
+ }
1180
+ for (var i = k - 1; 0 <= i; --i) {
1181
+ var x = ax - r + r * sin;
1182
+ var y = +ay - r + r * cos;
1183
+ this.writeVertexLeft(iv++, x, y, lol, fd, scale, fx, fy, ax, ay);
1184
+ var ncos = dcos * cos + dsin * sin;
1185
+ var nsin = -dsin * cos + dcos * sin;
1186
+ cos = ncos;
1187
+ sin = nsin;
1188
+ }
1189
+ }
1190
+ else {
1191
+ for (var i = k - 1; 0 <= i; --i) {
1192
+ this.writeVertexLeft(iv++, ax, +ay, lol, fd, scale, fx, fy, ax, ay);
1193
+ }
1194
+ }
1195
+ if (cbl) {
1196
+ var cos = 0;
1197
+ var sin = 1;
1198
+ for (var i = n - 1; 0 <= i; --i) {
1199
+ var x = 0 < i ? -ax + r - r * cos : xo;
1200
+ var y = +ay - r + r * sin;
1201
+ this.writeVertexLeft(iv++, x, y, lol, fd, scale, fx, fy, ax, ay);
1202
+ var ncos = dcos * cos + dsin * sin;
1203
+ var nsin = -dsin * cos + dcos * sin;
1204
+ cos = ncos;
1205
+ sin = nsin;
1206
+ }
1207
+ }
1208
+ else {
1209
+ for (var i = n - 1; 0 <= i; --i) {
1210
+ this.writeVertexLeft(iv++, xo, +ay, lol, fd, scale, fx, fy, ax, ay);
1211
+ }
1212
+ }
1213
+ this.writeVertexLeft(iv++, xo, yc, lol, fd, scale, fx, fy, ax, ay);
1214
+ this.writeFanIndices(0, ii, iv);
1215
+ ii += 3 * (iv - 2);
1216
+ // Top-right polygon of M + N + 3 vertices as a triangle fan, where M = N - k.
1217
+ // Order: the corner center (fan origin), the top end, the top-right arc (N), the bottom-right arc (M), the red point.
1218
+ var iv0 = iv;
1219
+ this.writeVertexTop(iv++, xc, yc, lop, fd, scale, fx, fy, ax, ay);
1220
+ this.writeVertexTop(iv++, xc, yo, lop, fd, scale, fx, fy, ax, ay);
1221
+ if (ctr) {
1222
+ var cos = 0;
1223
+ var sin = 1;
1224
+ for (var i = n - 1; 0 <= i; --i) {
1225
+ var x = ax - r + r * cos;
1226
+ var y = i < n - 1 ? -ay + r - r * sin : yo;
1227
+ this.writeVertexTop(iv++, x, y, lop, fd, scale, fx, fy, ax, ay);
1228
+ var ncos = dcos * cos + dsin * sin;
1229
+ var nsin = -dsin * cos + dcos * sin;
1230
+ cos = ncos;
1231
+ sin = nsin;
1232
+ }
1233
+ }
1234
+ else {
1235
+ for (var i = n - 1; 0 <= i; --i) {
1236
+ this.writeVertexTop(iv++, ax, yo, lop, fd, scale, fx, fy, ax, ay);
1237
+ }
1238
+ }
1239
+ if (cbr) {
1240
+ var cos = 0;
1241
+ var sin = 1;
1242
+ for (var i = n - 1; k <= i; --i) {
1243
+ var x = ax - r + r * sin;
1244
+ var y = +ay - r + r * cos;
1245
+ this.writeVertexTop(iv++, x, y, lop, fd, scale, fx, fy, ax, ay);
1246
+ var ncos = dcos * cos + dsin * sin;
1247
+ var nsin = -dsin * cos + dcos * sin;
1248
+ cos = ncos;
1249
+ sin = nsin;
1250
+ }
1251
+ }
1252
+ else {
1253
+ for (var i = n - 1; k <= i; --i) {
1254
+ this.writeVertexTop(iv++, ax, +ay, lop, fd, scale, fx, fy, ax, ay);
1255
+ }
1256
+ }
1257
+ this.writeVertexTop(iv++, xred, yred, lop, fd, scale, fx, fy, ax, ay);
1258
+ this.writeFanIndices(iv0, ii, iv - iv0);
1259
+ ii += 3 * (iv - iv0 - 2);
1260
+ if (ctl) {
1261
+ var lo = lol + 2 * ay - r;
1262
+ this.writeFan(-ax + r, -ay + r, -1, 0, lo, iv, ii, n, r, rs, fd, scale, fx, fy);
1263
+ iv += 2 * n - 1;
1264
+ ii += 3 * (n - 1);
1265
+ }
1266
+ this.pad(iv, ii, nv, ni, fd);
1267
+ };
1268
+ /**
1269
+ * Preconditions:
1270
+ * * shape.stroke.side === EShapeStrokeSide.BOTTOM_OR_RIGHT
1271
+ * * ay <= ax
1272
+ * * 5 * N + 5 <= nv
1273
+ * * 4 * N + 1 <= ni
1274
+ */
1275
+ EShapeRectangleRoundedTriangulatedImpl.prototype.updateBottomRight0 = function (fx, fy, ax, ay, scale, radius, corner, nv, ni) {
1276
+ var r = radius * ay;
1277
+ this.writeBottomRight(fx, fy, ax, ay, scale, 2 * ay, r, corner, ax - 2 * ay, -ay, 0, nv, ni);
1278
+ };
1279
+ /**
1280
+ * Preconditions:
1281
+ * * shape.stroke.side === EShapeStrokeSide.BOTTOM_OR_RIGHT
1282
+ * * ax < ay
1283
+ * * 5 * N + 5 <= nv
1284
+ * * 4 * N + 1 <= ni
1285
+ */
1286
+ EShapeRectangleRoundedTriangulatedImpl.prototype.updateBottomRight1 = function (fx, fy, ax, ay, scale, radius, corner, nv, ni) {
1287
+ var n = this._n >> 2;
1288
+ var r = radius * ax;
1289
+ this.writeBottomRight(fx, fy, ax, ay, scale, 2 * ax, r, corner, -ax, ay - 2 * ax, n, nv, ni);
1290
+ };
1291
+ /**
1292
+ * `(xred, yred)` is where the diagonal border meets the top edge or the left edge.
1293
+ * `k` is the number of the top-left arc vertices on the right side of that point.
1294
+ */
1295
+ EShapeRectangleRoundedTriangulatedImpl.prototype.writeBottomRight = function (fx, fy, ax, ay, scale, d, r, corner, xred, yred, k, nv, ni) {
1296
+ var fd = 1 / d;
1297
+ var n = this._n >> 2;
1298
+ var fs = (scale - 1) * d;
1299
+ var rs = r + fs;
1300
+ var cr = 0 < r;
1301
+ var ctl = cr && !!(corner & EShapeCorner.TOP_LEFT);
1302
+ var ctr = cr && !!(corner & EShapeCorner.TOP_RIGHT);
1303
+ var cbl = cr && !!(corner & EShapeCorner.BOTTOM_LEFT);
1304
+ var cbr = cr && !!(corner & EShapeCorner.BOTTOM_RIGHT);
1305
+ var lc = 0.5 * Math.PI * r - 2 * r;
1306
+ var lot = ctl ? -r : 0;
1307
+ var lor = lot + 2 * ax + (ctr ? lc : 0);
1308
+ var lob = lor + 2 * ay + (cbr ? lc : 0);
1309
+ var dangle = (Math.PI * 0.5) / (n - 1);
1310
+ var xo = +ax + fs;
1311
+ var yo = +ay + fs;
1312
+ // The diagonal border between the right and the bottom sides is -x + y = ay - ax.
1313
+ // It starts from the center of the bottom-right corner.
1314
+ var xc = cbr ? +ax - r : xo;
1315
+ var yc = cbr ? +ay - r : yo;
1316
+ // The red point is on the top-left arc if the border meets the top-left corner.
1317
+ if (ctl && xred < -ax + r && yred < -ay + r) {
1318
+ var e = ax - ay;
1319
+ var z = Math.sqrt(0.5 * r * r - e * e);
1320
+ xred = -ax + r - z + e;
1321
+ yred = -ay + r - z - e;
1322
+ k = Math.ceil(Math.atan2(z - e, z + e) / dangle);
1323
+ }
1324
+ // Top-right polygon of N + k + 3 vertices as a triangle fan.
1325
+ // Order: the corner center (fan origin), the red point, the top-left arc (k), the top-right arc (N), the right end.
1326
+ var iv = 0;
1327
+ var ii = 0;
1328
+ this.writeVertexRight(iv++, xc, yc, lor, fd, scale, fx, fy, ax, ay);
1329
+ this.writeVertexRight(iv++, xred, yred, lor, fd, scale, fx, fy, ax, ay);
1330
+ var dcos = Math.cos(dangle);
1331
+ var dsin = Math.sin(dangle);
1332
+ if (ctl) {
1333
+ var cos = 0;
1334
+ var sin = 1;
1335
+ if (0 < k) {
1336
+ for (var i = n - 1; k <= i; --i) {
1337
+ var ncos = dcos * cos + dsin * sin;
1338
+ var nsin = -dsin * cos + dcos * sin;
1339
+ cos = ncos;
1340
+ sin = nsin;
1341
+ }
1342
+ }
1343
+ for (var i = k - 1; 0 <= i; --i) {
1344
+ var x = -ax + r - r * sin;
1345
+ var y = -ay + r - r * cos;
1346
+ this.writeVertexRight(iv++, x, y, lor, fd, scale, fx, fy, ax, ay);
1347
+ var ncos = dcos * cos + dsin * sin;
1348
+ var nsin = -dsin * cos + dcos * sin;
1349
+ cos = ncos;
1350
+ sin = nsin;
1351
+ }
1352
+ }
1353
+ else {
1354
+ for (var i = k - 1; 0 <= i; --i) {
1355
+ this.writeVertexRight(iv++, -ax, -ay, lor, fd, scale, fx, fy, ax, ay);
1356
+ }
1357
+ }
1358
+ if (ctr) {
1359
+ var cos = 1;
1360
+ var sin = 0;
1361
+ for (var i = 0; i < n; ++i) {
1362
+ var x = i < n - 1 ? ax - r + r * sin : xo;
1363
+ var y = -ay + r - r * cos;
1364
+ this.writeVertexRight(iv++, x, y, lor, fd, scale, fx, fy, ax, ay);
1365
+ var ncos = dcos * cos - dsin * sin;
1366
+ var nsin = dsin * cos + dcos * sin;
1367
+ cos = ncos;
1368
+ sin = nsin;
1369
+ }
1370
+ }
1371
+ else {
1372
+ for (var i = 0; i < n; ++i) {
1373
+ this.writeVertexRight(iv++, xo, -ay, lor, fd, scale, fx, fy, ax, ay);
1374
+ }
1375
+ }
1376
+ this.writeVertexRight(iv++, xo, yc, lor, fd, scale, fx, fy, ax, ay);
1377
+ this.writeFanIndices(0, ii, iv);
1378
+ ii += 3 * (iv - 2);
1379
+ // Bottom-left polygon of M + N + 3 vertices as a triangle fan, where M = N - k.
1380
+ // Order: the corner center (fan origin), the bottom end, the bottom-left arc (N), the top-left arc (M), the red point.
1381
+ var iv0 = iv;
1382
+ this.writeVertexBottom(iv++, xc, yc, lob, fd, scale, fx, fy, ax, ay);
1383
+ this.writeVertexBottom(iv++, xc, yo, lob, fd, scale, fx, fy, ax, ay);
1384
+ if (cbl) {
1385
+ var cos = 1;
1386
+ var sin = 0;
1387
+ for (var i = 0; i < n; ++i) {
1388
+ var x = -ax + r - r * sin;
1389
+ var y = 0 < i ? +ay - r + r * cos : yo;
1390
+ this.writeVertexBottom(iv++, x, y, lob, fd, scale, fx, fy, ax, ay);
1391
+ var ncos = dcos * cos - dsin * sin;
1392
+ var nsin = dsin * cos + dcos * sin;
1393
+ cos = ncos;
1394
+ sin = nsin;
1395
+ }
1396
+ }
1397
+ else {
1398
+ for (var i = 0; i < n; ++i) {
1399
+ this.writeVertexBottom(iv++, -ax, yo, lob, fd, scale, fx, fy, ax, ay);
1400
+ }
1401
+ }
1402
+ if (ctl) {
1403
+ var cos = 0;
1404
+ var sin = 1;
1405
+ for (var i = n - 1; k <= i; --i) {
1406
+ var x = -ax + r - r * sin;
1407
+ var y = -ay + r - r * cos;
1408
+ this.writeVertexBottom(iv++, x, y, lob, fd, scale, fx, fy, ax, ay);
1409
+ var ncos = dcos * cos + dsin * sin;
1410
+ var nsin = -dsin * cos + dcos * sin;
1411
+ cos = ncos;
1412
+ sin = nsin;
1413
+ }
1414
+ }
1415
+ else {
1416
+ for (var i = n - 1; k <= i; --i) {
1417
+ this.writeVertexBottom(iv++, -ax, -ay, lob, fd, scale, fx, fy, ax, ay);
1418
+ }
1419
+ }
1420
+ this.writeVertexBottom(iv++, xred, yred, lob, fd, scale, fx, fy, ax, ay);
1421
+ this.writeFanIndices(iv0, ii, iv - iv0);
1422
+ ii += 3 * (iv - iv0 - 2);
1423
+ if (cbr) {
1424
+ var lo = lor + 2 * ay - r;
1425
+ this.writeFan(+ax - r, +ay - r, 1, 0, lo, iv, ii, n, r, rs, fd, scale, fx, fy);
1426
+ iv += 2 * n - 1;
1427
+ ii += 3 * (n - 1);
1428
+ }
1429
+ this.pad(iv, ii, nv, ni, fd);
1430
+ };
1431
+ /**
1432
+ * Preconditions:
1433
+ * * shape.stroke.side === EShapeStrokeSide.NOT_TOP
1434
+ * * ay <= ax
1435
+ * * 6 * N + 12 <= nv
1436
+ * * 4 * N + 6 <= ni
1437
+ */
1438
+ EShapeRectangleRoundedTriangulatedImpl.prototype.updateNotTop0 = function (fx, fy, ax, ay, scale, radius, corner, nv, ni) {
1439
+ // The deepest point of the stroke areas: the top edge if 2 * ay <= ax, otherwise the red point
1440
+ var d = Math.min(2 * ay, ax);
1441
+ var fd = 1 / d;
1442
+ var n = this._n >> 2;
1443
+ var fs = (scale - 1) * d;
1444
+ var r = radius * ay;
1445
+ var rs = r + fs;
1446
+ var cr = 0 < radius;
1447
+ var ctl = cr && !!(corner & EShapeCorner.TOP_LEFT);
1448
+ var ctr = cr && !!(corner & EShapeCorner.TOP_RIGHT);
1449
+ var cbl = cr && !!(corner & EShapeCorner.BOTTOM_LEFT);
1450
+ var cbr = cr && !!(corner & EShapeCorner.BOTTOM_RIGHT);
1451
+ var lc = 0.5 * Math.PI * r - 2 * r;
1452
+ var lot = ctl ? -r : 0;
1453
+ var lor = lot + 2 * ax + (ctr ? lc : 0);
1454
+ var lob = lor + 2 * ay + (cbr ? lc : 0);
1455
+ var lol = lob + 2 * ax + (cbl ? lc : 0);
1456
+ // The diagonal borders x + y = ay - ax and -x + y = ay - ax meet the top edge or each other (red point)
1457
+ var xred = Math.min(2 * ay - ax, 0);
1458
+ var yred = ay - ax - xred;
1459
+ var xl = cbl ? -ax + r : -ax - fs;
1460
+ var xr = cbr ? +ax - r : +ax + fs;
1461
+ var ydl = cbl ? +ay - r : +ay + fs;
1462
+ var ydr = cbr ? +ay - r : +ay + fs;
1463
+ var yo = +ay + fs;
1464
+ var iv = 0;
1465
+ var ii = 0;
1466
+ this.writeSideNotTop0(lol, ctl, cbl, iv, ii, n, r, ax, ay, scale, fd, fx, fy);
1467
+ iv += n + 4;
1468
+ ii += 3 * (n + 2);
1469
+ this.writeSideNotTop1(lor, ctr, cbr, iv, ii, n, r, ax, ay, scale, fd, fx, fy);
1470
+ iv += n + 4;
1471
+ ii += 3 * (n + 2);
1472
+ this.writeHexaBottom(iv, ii, lob, xred, yred, -xred, yred, xr, ydr, xr, yo, xl, yo, xl, ydl, fd, scale, fx, fy, ax, ay);
1473
+ iv += 6;
1474
+ ii += 12;
1475
+ if (cbl) {
1476
+ var lo = lob + 2 * ax - r;
1477
+ this.writeFan(-ax + r, +ay - r, 0, 1, lo, iv, ii, n, r, rs, fd, scale, fx, fy);
1478
+ iv += 2 * n - 1;
1479
+ ii += 3 * (n - 1);
1480
+ }
1481
+ if (cbr) {
1482
+ var lo = lor + 2 * ay - r;
1483
+ this.writeFan(+ax - r, +ay - r, 1, 0, lo, iv, ii, n, r, rs, fd, scale, fx, fy);
1484
+ iv += 2 * n - 1;
1485
+ ii += 3 * (n - 1);
1486
+ }
1487
+ this.pad(iv, ii, nv, ni, fd);
1488
+ };
1489
+ /**
1490
+ * Preconditions:
1491
+ * * shape.stroke.side === EShapeStrokeSide.NOT_TOP
1492
+ * * ax < ay
1493
+ * * 6 * N + 12 <= nv
1494
+ * * 4 * N + 6 <= ni
1495
+ */
1496
+ EShapeRectangleRoundedTriangulatedImpl.prototype.updateNotTop1 = function (fx, fy, ax, ay, scale, radius, corner, nv, ni) {
1497
+ var d = ax;
1498
+ var fd = 1 / d;
1499
+ var n = this._n >> 2;
1500
+ var fs = (scale - 1) * d;
1501
+ var r = radius * ax;
1502
+ var rs = r + fs;
1503
+ var cr = 0 < radius;
1504
+ var ctl = cr && !!(corner & EShapeCorner.TOP_LEFT);
1505
+ var ctr = cr && !!(corner & EShapeCorner.TOP_RIGHT);
1506
+ var cbl = cr && !!(corner & EShapeCorner.BOTTOM_LEFT);
1507
+ var cbr = cr && !!(corner & EShapeCorner.BOTTOM_RIGHT);
1508
+ var lc = 0.5 * Math.PI * r - 2 * r;
1509
+ var lot = ctl ? -r : 0;
1510
+ var lor = lot + 2 * ax + (ctr ? lc : 0);
1511
+ var lob = lor + 2 * ay + (cbr ? lc : 0);
1512
+ var lol = lob + 2 * ax + (cbl ? lc : 0);
1513
+ var xred = Math.min(2 * ay - ax, 0);
1514
+ var yred = ay - ax - xred;
1515
+ var xl = cbl ? -ax + r : -ax - fs;
1516
+ var xr = cbr ? +ax - r : +ax + fs;
1517
+ var ydl = cbl ? +ay - r : +ay + fs;
1518
+ var ydr = cbr ? +ay - r : +ay + fs;
1519
+ var yo = +ay + fs;
1520
+ var iv = 0;
1521
+ var ii = 0;
1522
+ this.writeSideNotTop0(lol, ctl, cbl, iv, ii, n, r, ax, ay, scale, fd, fx, fy);
1523
+ iv += n + 4;
1524
+ ii += 3 * (n + 2);
1525
+ this.writeSideNotTop1(lor, ctr, cbr, iv, ii, n, r, ax, ay, scale, fd, fx, fy);
1526
+ iv += n + 4;
1527
+ ii += 3 * (n + 2);
1528
+ this.writeHexaBottom(iv, ii, lob, xred, yred, -xred, yred, xr, ydr, xr, yo, xl, yo, xl, ydl, fd, scale, fx, fy, ax, ay);
1529
+ iv += 6;
1530
+ ii += 12;
1531
+ if (cbl) {
1532
+ var lo = lob + 2 * ax - r;
1533
+ this.writeFan(-ax + r, +ay - r, 0, 1, lo, iv, ii, n, r, rs, fd, scale, fx, fy);
1534
+ iv += 2 * n - 1;
1535
+ ii += 3 * (n - 1);
1536
+ }
1537
+ if (cbr) {
1538
+ var lo = lor + 2 * ay - r;
1539
+ this.writeFan(+ax - r, +ay - r, 1, 0, lo, iv, ii, n, r, rs, fd, scale, fx, fy);
1540
+ iv += 2 * n - 1;
1541
+ ii += 3 * (n - 1);
1542
+ }
1543
+ this.pad(iv, ii, nv, ni, fd);
1544
+ };
1545
+ /**
1546
+ * Writes the left (`sx` = -1) or the right (`sx` = +1) polygon of N + 4 vertices as a triangle fan.
1547
+ * Order: the red point (fan origin), the diagonal end, the outer bottom, the top arc (N), the blue point (0, -ay).
1548
+ * If 2 * ay <= ax, the red point is on the top edge and the last triangle degenerates.
1549
+ */
1550
+ EShapeRectangleRoundedTriangulatedImpl.prototype.writeSideNotTop0 = function (lo, ct, cb, iv, ii, n, r, ax, ay, scale, fd, fx, fy) {
1551
+ var fs = (scale - 1) / fd;
1552
+ var xo = -ax - fs;
1553
+ var xd = cb ? -ax + r : xo;
1554
+ var yd = cb ? +ay - r : +ay + fs;
1555
+ var xred = Math.min(2 * ay - ax, 0);
1556
+ var k = iv;
1557
+ this.writeVertexLeft(k++, xred, ay - ax - xred, lo, fd, scale, fx, fy, ax, ay);
1558
+ this.writeVertexLeft(k++, xd, yd, lo, fd, scale, fx, fy, ax, ay);
1559
+ this.writeVertexLeft(k++, xo, yd, lo, fd, scale, fx, fy, ax, ay);
1560
+ if (ct) {
1561
+ var dangle = (Math.PI * 0.5) / (n - 1);
1562
+ for (var i = 0; i < n; ++i) {
1563
+ var angle = i * dangle;
1564
+ var x = i === 0 ? xo : -ax + r - r * Math.cos(angle);
1565
+ var y = -ay + r - r * Math.sin(angle);
1566
+ this.writeVertexLeft(k++, x, y, lo, fd, scale, fx, fy, ax, ay);
1567
+ }
1568
+ }
1569
+ else {
1570
+ for (var i = 0; i < n; ++i) {
1571
+ this.writeVertexLeft(k++, xo, -ay, lo, fd, scale, fx, fy, ax, ay);
1572
+ }
1573
+ }
1574
+ this.writeVertexLeft(k++, 0, -ay, lo, fd, scale, fx, fy, ax, ay);
1575
+ var indices = this._indices;
1576
+ for (var i = 1, imax = k - iv - 1; i < imax; ++i) {
1577
+ indices[ii++] = iv;
1578
+ indices[ii++] = iv + i;
1579
+ indices[ii++] = iv + i + 1;
1580
+ }
1581
+ };
1582
+ EShapeRectangleRoundedTriangulatedImpl.prototype.writeSideNotTop1 = function (lo, ct, cb, iv, ii, n, r, ax, ay, scale, fd, fx, fy) {
1583
+ var fs = (scale - 1) / fd;
1584
+ var xo = -ax - fs;
1585
+ var xd = cb ? -ax + r : xo;
1586
+ var yd = cb ? +ay - r : +ay + fs;
1587
+ var xred = Math.min(2 * ay - ax, 0);
1588
+ var k = iv;
1589
+ this.writeVertexRight(k++, -xred, ay - ax - xred, lo, fd, scale, fx, fy, ax, ay);
1590
+ this.writeVertexRight(k++, -xd, yd, lo, fd, scale, fx, fy, ax, ay);
1591
+ this.writeVertexRight(k++, -xo, yd, lo, fd, scale, fx, fy, ax, ay);
1592
+ if (ct) {
1593
+ var dangle = (Math.PI * 0.5) / (n - 1);
1594
+ for (var i = 0; i < n; ++i) {
1595
+ var angle = i * dangle;
1596
+ var x = i === 0 ? xo : -ax + r - r * Math.cos(angle);
1597
+ var y = -ay + r - r * Math.sin(angle);
1598
+ this.writeVertexRight(k++, -x, y, lo, fd, scale, fx, fy, ax, ay);
1599
+ }
1600
+ }
1601
+ else {
1602
+ for (var i = 0; i < n; ++i) {
1603
+ this.writeVertexRight(k++, -xo, -ay, lo, fd, scale, fx, fy, ax, ay);
1604
+ }
1605
+ }
1606
+ this.writeVertexRight(k++, 0, -ay, lo, fd, scale, fx, fy, ax, ay);
1607
+ var indices = this._indices;
1608
+ for (var i = 1, imax = k - iv - 1; i < imax; ++i) {
1609
+ indices[ii++] = iv;
1610
+ indices[ii++] = iv + i + 1;
1611
+ indices[ii++] = iv + i;
1612
+ }
1613
+ };
1614
+ /**
1615
+ * Preconditions:
1616
+ * * shape.stroke.side === EShapeStrokeSide.NOT_BOTTOM
1617
+ * * ay <= ax
1618
+ * * 6 * N + 12 <= nv
1619
+ * * 4 * N + 6 <= ni
1620
+ */
1621
+ EShapeRectangleRoundedTriangulatedImpl.prototype.updateNotBottom0 = function (fx, fy, ax, ay, scale, radius, corner, nv, ni) {
1622
+ // The deepest point of the stroke areas: the bottom edge if 2 * ay <= ax, otherwise the red point
1623
+ var d = Math.min(2 * ay, ax);
1624
+ var fd = 1 / d;
1625
+ var n = this._n >> 2;
1626
+ var fs = (scale - 1) * d;
1627
+ var r = radius * ay;
1628
+ var rs = r + fs;
1629
+ var cr = 0 < radius;
1630
+ var ctl = cr && !!(corner & EShapeCorner.TOP_LEFT);
1631
+ var ctr = cr && !!(corner & EShapeCorner.TOP_RIGHT);
1632
+ var cbl = cr && !!(corner & EShapeCorner.BOTTOM_LEFT);
1633
+ var cbr = cr && !!(corner & EShapeCorner.BOTTOM_RIGHT);
1634
+ var lc = 0.5 * Math.PI * r - 2 * r;
1635
+ var lot = ctl ? -r : 0;
1636
+ var lor = lot + 2 * ax + (ctr ? lc : 0);
1637
+ var lob = lor + 2 * ay + (cbr ? lc : 0);
1638
+ var lol = lob + 2 * ax + (cbl ? lc : 0);
1639
+ var xred = Math.min(2 * ay - ax, 0);
1640
+ var yred = ay - ax - xred;
1641
+ var xl = ctl ? -ax + r : -ax - fs;
1642
+ var xr = ctr ? +ax - r : +ax + fs;
1643
+ var ydl = ctl ? +ay - r : +ay + fs;
1644
+ var ydr = ctr ? +ay - r : +ay + fs;
1645
+ var yo = +ay + fs;
1646
+ var iv = 0;
1647
+ var ii = 0;
1648
+ this.writeSideNotBottom0(lol, ctl, cbl, iv, ii, n, r, ax, ay, scale, fd, fx, fy);
1649
+ iv += n + 4;
1650
+ ii += 3 * (n + 2);
1651
+ this.writeSideNotBottom1(lor, ctr, cbr, iv, ii, n, r, ax, ay, scale, fd, fx, fy);
1652
+ iv += n + 4;
1653
+ ii += 3 * (n + 2);
1654
+ this.writeHexaTop(iv, ii, lot, xred, -yred, -xred, -yred, xr, -ydr, xr, -yo, xl, -yo, xl, -ydl, fd, scale, fx, fy, ax, ay);
1655
+ var indices = this._indices;
1656
+ for (var i = 0; i < 4; ++i) {
1657
+ var index = ii + 3 * i + 1;
1658
+ var value = indices[index];
1659
+ indices[index] = indices[index + 1];
1660
+ indices[index + 1] = value;
1661
+ }
1662
+ iv += 6;
1663
+ ii += 12;
1664
+ if (ctl) {
1665
+ var lo = lol + 2 * ay - r;
1666
+ this.writeFan(-ax + r, -ay + r, -1, 0, lo, iv, ii, n, r, rs, fd, scale, fx, fy);
1667
+ iv += 2 * n - 1;
1668
+ ii += 3 * (n - 1);
1669
+ }
1670
+ if (ctr) {
1671
+ var lo = lot + 2 * ax - r;
1672
+ this.writeFan(+ax - r, -ay + r, 0, -1, lo, iv, ii, n, r, rs, fd, scale, fx, fy);
1673
+ iv += 2 * n - 1;
1674
+ ii += 3 * (n - 1);
1675
+ }
1676
+ this.pad(iv, ii, nv, ni, fd);
1677
+ };
1678
+ /**
1679
+ * Preconditions:
1680
+ * * shape.stroke.side === EShapeStrokeSide.NOT_BOTTOM
1681
+ * * ax < ay
1682
+ * * 6 * N + 12 <= nv
1683
+ * * 4 * N + 6 <= ni
1684
+ */
1685
+ EShapeRectangleRoundedTriangulatedImpl.prototype.updateNotBottom1 = function (fx, fy, ax, ay, scale, radius, corner, nv, ni) {
1686
+ var d = ax;
1687
+ var fd = 1 / d;
1688
+ var n = this._n >> 2;
1689
+ var fs = (scale - 1) * d;
1690
+ var r = radius * ax;
1691
+ var rs = r + fs;
1692
+ var cr = 0 < radius;
1693
+ var ctl = cr && !!(corner & EShapeCorner.TOP_LEFT);
1694
+ var ctr = cr && !!(corner & EShapeCorner.TOP_RIGHT);
1695
+ var cbl = cr && !!(corner & EShapeCorner.BOTTOM_LEFT);
1696
+ var cbr = cr && !!(corner & EShapeCorner.BOTTOM_RIGHT);
1697
+ var lc = 0.5 * Math.PI * r - 2 * r;
1698
+ var lot = ctl ? -r : 0;
1699
+ var lor = lot + 2 * ax + (ctr ? lc : 0);
1700
+ var lob = lor + 2 * ay + (cbr ? lc : 0);
1701
+ var lol = lob + 2 * ax + (cbl ? lc : 0);
1702
+ var xred = Math.min(2 * ay - ax, 0);
1703
+ var yred = ay - ax - xred;
1704
+ var xl = ctl ? -ax + r : -ax - fs;
1705
+ var xr = ctr ? +ax - r : +ax + fs;
1706
+ var ydl = ctl ? +ay - r : +ay + fs;
1707
+ var ydr = ctr ? +ay - r : +ay + fs;
1708
+ var yo = +ay + fs;
1709
+ var iv = 0;
1710
+ var ii = 0;
1711
+ this.writeSideNotBottom0(lol, ctl, cbl, iv, ii, n, r, ax, ay, scale, fd, fx, fy);
1712
+ iv += n + 4;
1713
+ ii += 3 * (n + 2);
1714
+ this.writeSideNotBottom1(lor, ctr, cbr, iv, ii, n, r, ax, ay, scale, fd, fx, fy);
1715
+ iv += n + 4;
1716
+ ii += 3 * (n + 2);
1717
+ this.writeHexaTop(iv, ii, lot, xred, -yred, -xred, -yred, xr, -ydr, xr, -yo, xl, -yo, xl, -ydl, fd, scale, fx, fy, ax, ay);
1718
+ var indices = this._indices;
1719
+ for (var i = 0; i < 4; ++i) {
1720
+ var index = ii + 3 * i + 1;
1721
+ var value = indices[index];
1722
+ indices[index] = indices[index + 1];
1723
+ indices[index + 1] = value;
1724
+ }
1725
+ iv += 6;
1726
+ ii += 12;
1727
+ if (ctl) {
1728
+ var lo = lol + 2 * ay - r;
1729
+ this.writeFan(-ax + r, -ay + r, -1, 0, lo, iv, ii, n, r, rs, fd, scale, fx, fy);
1730
+ iv += 2 * n - 1;
1731
+ ii += 3 * (n - 1);
1732
+ }
1733
+ if (ctr) {
1734
+ var lo = lot + 2 * ax - r;
1735
+ this.writeFan(+ax - r, -ay + r, 0, -1, lo, iv, ii, n, r, rs, fd, scale, fx, fy);
1736
+ iv += 2 * n - 1;
1737
+ ii += 3 * (n - 1);
1738
+ }
1739
+ this.pad(iv, ii, nv, ni, fd);
1740
+ };
1741
+ EShapeRectangleRoundedTriangulatedImpl.prototype.writeSideNotBottom0 = function (lo, ct, cb, iv, ii, n, r, ax, ay, scale, fd, fx, fy) {
1742
+ var fs = (scale - 1) / fd;
1743
+ var xo = -ax - fs;
1744
+ var xd = ct ? -ax + r : xo;
1745
+ var yd = ct ? +ay - r : +ay + fs;
1746
+ var xred = Math.min(2 * ay - ax, 0);
1747
+ var yred = ay - ax - xred;
1748
+ var k = iv;
1749
+ this.writeVertexLeft(k++, xred, -yred, lo, fd, scale, fx, fy, ax, ay);
1750
+ this.writeVertexLeft(k++, xd, -yd, lo, fd, scale, fx, fy, ax, ay);
1751
+ this.writeVertexLeft(k++, xo, -yd, lo, fd, scale, fx, fy, ax, ay);
1752
+ if (cb) {
1753
+ var dangle = (Math.PI * 0.5) / (n - 1);
1754
+ for (var i = 0; i < n; ++i) {
1755
+ var angle = i * dangle;
1756
+ var x = i === 0 ? xo : -ax + r - r * Math.cos(angle);
1757
+ var y = +ay - r + r * Math.sin(angle);
1758
+ this.writeVertexLeft(k++, x, y, lo, fd, scale, fx, fy, ax, ay);
1759
+ }
1760
+ }
1761
+ else {
1762
+ for (var i = 0; i < n; ++i) {
1763
+ this.writeVertexLeft(k++, xo, +ay, lo, fd, scale, fx, fy, ax, ay);
1764
+ }
1765
+ }
1766
+ this.writeVertexLeft(k++, 0, +ay, lo, fd, scale, fx, fy, ax, ay);
1767
+ var indices = this._indices;
1768
+ for (var i = 1, imax = k - iv - 1; i < imax; ++i) {
1769
+ indices[ii++] = iv;
1770
+ indices[ii++] = iv + i;
1771
+ indices[ii++] = iv + i + 1;
1772
+ }
1773
+ };
1774
+ EShapeRectangleRoundedTriangulatedImpl.prototype.writeSideNotBottom1 = function (lo, ct, cb, iv, ii, n, r, ax, ay, scale, fd, fx, fy) {
1775
+ var fs = (scale - 1) / fd;
1776
+ var xo = -ax - fs;
1777
+ var xd = ct ? -ax + r : xo;
1778
+ var yd = ct ? +ay - r : +ay + fs;
1779
+ var xred = Math.min(2 * ay - ax, 0);
1780
+ var yred = ay - ax - xred;
1781
+ var k = iv;
1782
+ this.writeVertexRight(k++, -xred, -yred, lo, fd, scale, fx, fy, ax, ay);
1783
+ this.writeVertexRight(k++, -xd, -yd, lo, fd, scale, fx, fy, ax, ay);
1784
+ this.writeVertexRight(k++, -xo, -yd, lo, fd, scale, fx, fy, ax, ay);
1785
+ if (cb) {
1786
+ var dangle = (Math.PI * 0.5) / (n - 1);
1787
+ for (var i = 0; i < n; ++i) {
1788
+ var angle = i * dangle;
1789
+ var x = i === 0 ? xo : -ax + r - r * Math.cos(angle);
1790
+ var y = +ay - r + r * Math.sin(angle);
1791
+ this.writeVertexRight(k++, -x, y, lo, fd, scale, fx, fy, ax, ay);
1792
+ }
1793
+ }
1794
+ else {
1795
+ for (var i = 0; i < n; ++i) {
1796
+ this.writeVertexRight(k++, -xo, +ay, lo, fd, scale, fx, fy, ax, ay);
1797
+ }
1798
+ }
1799
+ this.writeVertexRight(k++, 0, +ay, lo, fd, scale, fx, fy, ax, ay);
1800
+ var indices = this._indices;
1801
+ for (var i = 1, imax = k - iv - 1; i < imax; ++i) {
1802
+ indices[ii++] = iv;
1803
+ indices[ii++] = iv + i + 1;
1804
+ indices[ii++] = iv + i;
1805
+ }
1806
+ };
1807
+ /**
1808
+ * Preconditions:
1809
+ * * shape.stroke.side === EShapeStrokeSide.NOT_LEFT
1810
+ * * ay <= ax
1811
+ * * 6 * N + 12 <= nv
1812
+ * * 4 * N + 6 <= ni
1813
+ */
1814
+ EShapeRectangleRoundedTriangulatedImpl.prototype.updateNotLeft0 = function (fx, fy, ax, ay, scale, radius, corner, nv, ni) {
1815
+ var d = ay;
1816
+ var fd = 1 / d;
1817
+ var n = this._n >> 2;
1818
+ var fs = (scale - 1) * d;
1819
+ var r = radius * ay;
1820
+ var rs = r + fs;
1821
+ var cr = 0 < radius;
1822
+ var ctl = cr && !!(corner & EShapeCorner.TOP_LEFT);
1823
+ var ctr = cr && !!(corner & EShapeCorner.TOP_RIGHT);
1824
+ var cbl = cr && !!(corner & EShapeCorner.BOTTOM_LEFT);
1825
+ var cbr = cr && !!(corner & EShapeCorner.BOTTOM_RIGHT);
1826
+ var lc = 0.5 * Math.PI * r - 2 * r;
1827
+ var lot = ctl ? -r : 0;
1828
+ var lor = lot + 2 * ax + (ctr ? lc : 0);
1829
+ var lob = lor + 2 * ay + (cbr ? lc : 0);
1830
+ var xred = Math.min(2 * ax - ay, 0);
1831
+ var yred = ax - ay - xred;
1832
+ var xl = ctr ? -ay + r : -ay - fs;
1833
+ var xr = cbr ? +ay - r : +ay + fs;
1834
+ var ydl = ctr ? +ax - r : +ax + fs;
1835
+ var ydr = cbr ? +ax - r : +ax + fs;
1836
+ var yo = +ax + fs;
1837
+ var iv = 0;
1838
+ var ii = 0;
1839
+ this.writeSideNotLeft0(lot, ctl, ctr, iv, ii, n, r, ax, ay, scale, fd, fx, fy);
1840
+ iv += n + 4;
1841
+ ii += 3 * (n + 2);
1842
+ this.writeSideNotLeft1(lob, cbl, cbr, iv, ii, n, r, ax, ay, scale, fd, fx, fy);
1843
+ iv += n + 4;
1844
+ ii += 3 * (n + 2);
1845
+ this.writeHexaRight(iv, ii, lor, yred, xred, yred, -xred, ydr, xr, yo, xr, yo, xl, ydl, xl, fd, scale, fx, fy, ax, ay);
1846
+ var indices = this._indices;
1847
+ for (var i = 0; i < 4; ++i) {
1848
+ var index = ii + 3 * i + 1;
1849
+ var value = indices[index];
1850
+ indices[index] = indices[index + 1];
1851
+ indices[index + 1] = value;
1852
+ }
1853
+ iv += 6;
1854
+ ii += 12;
1855
+ if (ctr) {
1856
+ var lo = lot + 2 * ax - r;
1857
+ this.writeFan(+ax - r, -ay + r, 0, -1, lo, iv, ii, n, r, rs, fd, scale, fx, fy);
1858
+ iv += 2 * n - 1;
1859
+ ii += 3 * (n - 1);
1860
+ }
1861
+ if (cbr) {
1862
+ var lo = lor + 2 * ay - r;
1863
+ this.writeFan(+ax - r, +ay - r, 1, 0, lo, iv, ii, n, r, rs, fd, scale, fx, fy);
1864
+ iv += 2 * n - 1;
1865
+ ii += 3 * (n - 1);
1866
+ }
1867
+ this.pad(iv, ii, nv, ni, fd);
1868
+ };
1869
+ /**
1870
+ * Preconditions:
1871
+ * * shape.stroke.side === EShapeStrokeSide.NOT_LEFT
1872
+ * * ax < ay
1873
+ * * 6 * N + 12 <= nv
1874
+ * * 4 * N + 6 <= ni
1875
+ */
1876
+ EShapeRectangleRoundedTriangulatedImpl.prototype.updateNotLeft1 = function (fx, fy, ax, ay, scale, radius, corner, nv, ni) {
1877
+ // The deepest point of the stroke areas: the left edge if 2 * ax <= ay, otherwise the red point
1878
+ var d = Math.min(2 * ax, ay);
1879
+ var fd = 1 / d;
1880
+ var n = this._n >> 2;
1881
+ var fs = (scale - 1) * d;
1882
+ var r = radius * ax;
1883
+ var rs = r + fs;
1884
+ var cr = 0 < radius;
1885
+ var ctl = cr && !!(corner & EShapeCorner.TOP_LEFT);
1886
+ var ctr = cr && !!(corner & EShapeCorner.TOP_RIGHT);
1887
+ var cbl = cr && !!(corner & EShapeCorner.BOTTOM_LEFT);
1888
+ var cbr = cr && !!(corner & EShapeCorner.BOTTOM_RIGHT);
1889
+ var lc = 0.5 * Math.PI * r - 2 * r;
1890
+ var lot = ctl ? -r : 0;
1891
+ var lor = lot + 2 * ax + (ctr ? lc : 0);
1892
+ var lob = lor + 2 * ay + (cbr ? lc : 0);
1893
+ var xred = Math.min(2 * ax - ay, 0);
1894
+ var yred = ax - ay - xred;
1895
+ var xl = ctr ? -ay + r : -ay - fs;
1896
+ var xr = cbr ? +ay - r : +ay + fs;
1897
+ var ydl = ctr ? +ax - r : +ax + fs;
1898
+ var ydr = cbr ? +ax - r : +ax + fs;
1899
+ var yo = +ax + fs;
1900
+ var iv = 0;
1901
+ var ii = 0;
1902
+ this.writeSideNotLeft0(lot, ctl, ctr, iv, ii, n, r, ax, ay, scale, fd, fx, fy);
1903
+ iv += n + 4;
1904
+ ii += 3 * (n + 2);
1905
+ this.writeSideNotLeft1(lob, cbl, cbr, iv, ii, n, r, ax, ay, scale, fd, fx, fy);
1906
+ iv += n + 4;
1907
+ ii += 3 * (n + 2);
1908
+ this.writeHexaRight(iv, ii, lor, yred, xred, yred, -xred, ydr, xr, yo, xr, yo, xl, ydl, xl, fd, scale, fx, fy, ax, ay);
1909
+ var indices = this._indices;
1910
+ for (var i = 0; i < 4; ++i) {
1911
+ var index = ii + 3 * i + 1;
1912
+ var value = indices[index];
1913
+ indices[index] = indices[index + 1];
1914
+ indices[index + 1] = value;
1915
+ }
1916
+ iv += 6;
1917
+ ii += 12;
1918
+ if (ctr) {
1919
+ var lo = lot + 2 * ax - r;
1920
+ this.writeFan(+ax - r, -ay + r, 0, -1, lo, iv, ii, n, r, rs, fd, scale, fx, fy);
1921
+ iv += 2 * n - 1;
1922
+ ii += 3 * (n - 1);
1923
+ }
1924
+ if (cbr) {
1925
+ var lo = lor + 2 * ay - r;
1926
+ this.writeFan(+ax - r, +ay - r, 1, 0, lo, iv, ii, n, r, rs, fd, scale, fx, fy);
1927
+ iv += 2 * n - 1;
1928
+ ii += 3 * (n - 1);
1929
+ }
1930
+ this.pad(iv, ii, nv, ni, fd);
1931
+ };
1932
+ EShapeRectangleRoundedTriangulatedImpl.prototype.writeSideNotLeft0 = function (lo, ct, cb, iv, ii, n, r, ax, ay, scale, fd, fx, fy) {
1933
+ var fs = (scale - 1) / fd;
1934
+ var xo = -ay - fs;
1935
+ var xd = cb ? -ay + r : xo;
1936
+ var yd = cb ? +ax - r : +ax + fs;
1937
+ var xred = Math.min(2 * ax - ay, 0);
1938
+ var yred = ax - ay - xred;
1939
+ var k = iv;
1940
+ this.writeVertexTop(k++, yred, xred, lo, fd, scale, fx, fy, ax, ay);
1941
+ this.writeVertexTop(k++, yd, xd, lo, fd, scale, fx, fy, ax, ay);
1942
+ this.writeVertexTop(k++, yd, xo, lo, fd, scale, fx, fy, ax, ay);
1943
+ if (ct) {
1944
+ var dangle = (Math.PI * 0.5) / (n - 1);
1945
+ for (var i = 0; i < n; ++i) {
1946
+ var angle = i * dangle;
1947
+ var x = i === 0 ? xo : -ay + r - r * Math.cos(angle);
1948
+ var y = -ax + r - r * Math.sin(angle);
1949
+ this.writeVertexTop(k++, y, x, lo, fd, scale, fx, fy, ax, ay);
1950
+ }
1951
+ }
1952
+ else {
1953
+ for (var i = 0; i < n; ++i) {
1954
+ this.writeVertexTop(k++, -ax, xo, lo, fd, scale, fx, fy, ax, ay);
1955
+ }
1956
+ }
1957
+ this.writeVertexTop(k++, -ax, 0, lo, fd, scale, fx, fy, ax, ay);
1958
+ var indices = this._indices;
1959
+ for (var i = 1, imax = k - iv - 1; i < imax; ++i) {
1960
+ indices[ii++] = iv;
1961
+ indices[ii++] = iv + i + 1;
1962
+ indices[ii++] = iv + i;
1963
+ }
1964
+ };
1965
+ EShapeRectangleRoundedTriangulatedImpl.prototype.writeSideNotLeft1 = function (lo, ct, cb, iv, ii, n, r, ax, ay, scale, fd, fx, fy) {
1966
+ var fs = (scale - 1) / fd;
1967
+ var xo = -ay - fs;
1968
+ var xd = cb ? -ay + r : xo;
1969
+ var yd = cb ? +ax - r : +ax + fs;
1970
+ var xred = Math.min(2 * ax - ay, 0);
1971
+ var yred = ax - ay - xred;
1972
+ var k = iv;
1973
+ this.writeVertexBottom(k++, yred, -xred, lo, fd, scale, fx, fy, ax, ay);
1974
+ this.writeVertexBottom(k++, yd, -xd, lo, fd, scale, fx, fy, ax, ay);
1975
+ this.writeVertexBottom(k++, yd, -xo, lo, fd, scale, fx, fy, ax, ay);
1976
+ if (ct) {
1977
+ var dangle = (Math.PI * 0.5) / (n - 1);
1978
+ for (var i = 0; i < n; ++i) {
1979
+ var angle = i * dangle;
1980
+ var x = i === 0 ? xo : -ay + r - r * Math.cos(angle);
1981
+ var y = -ax + r - r * Math.sin(angle);
1982
+ this.writeVertexBottom(k++, y, -x, lo, fd, scale, fx, fy, ax, ay);
1983
+ }
1984
+ }
1985
+ else {
1986
+ for (var i = 0; i < n; ++i) {
1987
+ this.writeVertexBottom(k++, -ax, -xo, lo, fd, scale, fx, fy, ax, ay);
1988
+ }
1989
+ }
1990
+ this.writeVertexBottom(k++, -ax, 0, lo, fd, scale, fx, fy, ax, ay);
1991
+ var indices = this._indices;
1992
+ for (var i = 1, imax = k - iv - 1; i < imax; ++i) {
1993
+ indices[ii++] = iv;
1994
+ indices[ii++] = iv + i;
1995
+ indices[ii++] = iv + i + 1;
1996
+ }
1997
+ };
1998
+ /**
1999
+ * Preconditions:
2000
+ * * shape.stroke.side === EShapeStrokeSide.NOT_RIGHT
2001
+ * * ay <= ax
2002
+ * * 6 * N + 12 <= nv
2003
+ * * 4 * N + 6 <= ni
2004
+ */
2005
+ EShapeRectangleRoundedTriangulatedImpl.prototype.updateNotRight0 = function (fx, fy, ax, ay, scale, radius, corner, nv, ni) {
2006
+ var d = ay;
2007
+ var fd = 1 / d;
2008
+ var n = this._n >> 2;
2009
+ var fs = (scale - 1) * d;
2010
+ var r = radius * ay;
2011
+ var rs = r + fs;
2012
+ var cr = 0 < radius;
2013
+ var ctl = cr && !!(corner & EShapeCorner.TOP_LEFT);
2014
+ var ctr = cr && !!(corner & EShapeCorner.TOP_RIGHT);
2015
+ var cbl = cr && !!(corner & EShapeCorner.BOTTOM_LEFT);
2016
+ var cbr = cr && !!(corner & EShapeCorner.BOTTOM_RIGHT);
2017
+ var lc = 0.5 * Math.PI * r - 2 * r;
2018
+ var lot = ctl ? -r : 0;
2019
+ var lor = lot + 2 * ax + (ctr ? lc : 0);
2020
+ var lob = lor + 2 * ay + (cbr ? lc : 0);
2021
+ var lol = lob + 2 * ax + (cbl ? lc : 0);
2022
+ var xred = Math.min(2 * ax - ay, 0);
2023
+ var yred = ax - ay - xred;
2024
+ var xl = ctl ? -ay + r : -ay - fs;
2025
+ var xr = cbl ? +ay - r : +ay + fs;
2026
+ var ydl = ctl ? +ax - r : +ax + fs;
2027
+ var ydr = cbl ? +ax - r : +ax + fs;
2028
+ var yo = +ax + fs;
2029
+ var iv = 0;
2030
+ var ii = 0;
2031
+ this.writeSideNotRight0(lot, ctr, ctl, iv, ii, n, r, ax, ay, scale, fd, fx, fy);
2032
+ iv += n + 4;
2033
+ ii += 3 * (n + 2);
2034
+ this.writeSideNotRight1(lob, cbr, cbl, iv, ii, n, r, ax, ay, scale, fd, fx, fy);
2035
+ iv += n + 4;
2036
+ ii += 3 * (n + 2);
2037
+ this.writeHexaLeft(iv, ii, lol, -yred, xred, -yred, -xred, -ydr, xr, -yo, xr, -yo, xl, -ydl, xl, fd, scale, fx, fy, ax, ay);
2038
+ iv += 6;
2039
+ ii += 12;
2040
+ if (ctl) {
2041
+ var lo = lol + 2 * ay - r;
2042
+ this.writeFan(-ax + r, -ay + r, -1, 0, lo, iv, ii, n, r, rs, fd, scale, fx, fy);
2043
+ iv += 2 * n - 1;
2044
+ ii += 3 * (n - 1);
2045
+ }
2046
+ if (cbl) {
2047
+ var lo = lob + 2 * ax - r;
2048
+ this.writeFan(-ax + r, +ay - r, 0, 1, lo, iv, ii, n, r, rs, fd, scale, fx, fy);
2049
+ iv += 2 * n - 1;
2050
+ ii += 3 * (n - 1);
2051
+ }
2052
+ this.pad(iv, ii, nv, ni, fd);
2053
+ };
2054
+ /**
2055
+ * Preconditions:
2056
+ * * shape.stroke.side === EShapeStrokeSide.NOT_RIGHT
2057
+ * * ax < ay
2058
+ * * 6 * N + 12 <= nv
2059
+ * * 4 * N + 6 <= ni
2060
+ */
2061
+ EShapeRectangleRoundedTriangulatedImpl.prototype.updateNotRight1 = function (fx, fy, ax, ay, scale, radius, corner, nv, ni) {
2062
+ // The deepest point of the stroke areas: the right edge if 2 * ax <= ay, otherwise the red point
2063
+ var d = Math.min(2 * ax, ay);
2064
+ var fd = 1 / d;
2065
+ var n = this._n >> 2;
2066
+ var fs = (scale - 1) * d;
2067
+ var r = radius * ax;
2068
+ var rs = r + fs;
2069
+ var cr = 0 < radius;
2070
+ var ctl = cr && !!(corner & EShapeCorner.TOP_LEFT);
2071
+ var ctr = cr && !!(corner & EShapeCorner.TOP_RIGHT);
2072
+ var cbl = cr && !!(corner & EShapeCorner.BOTTOM_LEFT);
2073
+ var cbr = cr && !!(corner & EShapeCorner.BOTTOM_RIGHT);
2074
+ var lc = 0.5 * Math.PI * r - 2 * r;
2075
+ var lot = ctl ? -r : 0;
2076
+ var lor = lot + 2 * ax + (ctr ? lc : 0);
2077
+ var lob = lor + 2 * ay + (cbr ? lc : 0);
2078
+ var lol = lob + 2 * ax + (cbl ? lc : 0);
2079
+ var xred = Math.min(2 * ax - ay, 0);
2080
+ var yred = ax - ay - xred;
2081
+ var xl = ctl ? -ay + r : -ay - fs;
2082
+ var xr = cbl ? +ay - r : +ay + fs;
2083
+ var ydl = ctl ? +ax - r : +ax + fs;
2084
+ var ydr = cbl ? +ax - r : +ax + fs;
2085
+ var yo = +ax + fs;
2086
+ var iv = 0;
2087
+ var ii = 0;
2088
+ this.writeSideNotRight0(lot, ctr, ctl, iv, ii, n, r, ax, ay, scale, fd, fx, fy);
2089
+ iv += n + 4;
2090
+ ii += 3 * (n + 2);
2091
+ this.writeSideNotRight1(lob, cbr, cbl, iv, ii, n, r, ax, ay, scale, fd, fx, fy);
2092
+ iv += n + 4;
2093
+ ii += 3 * (n + 2);
2094
+ this.writeHexaLeft(iv, ii, lol, -yred, xred, -yred, -xred, -ydr, xr, -yo, xr, -yo, xl, -ydl, xl, fd, scale, fx, fy, ax, ay);
2095
+ iv += 6;
2096
+ ii += 12;
2097
+ if (ctl) {
2098
+ var lo = lol + 2 * ay - r;
2099
+ this.writeFan(-ax + r, -ay + r, -1, 0, lo, iv, ii, n, r, rs, fd, scale, fx, fy);
2100
+ iv += 2 * n - 1;
2101
+ ii += 3 * (n - 1);
2102
+ }
2103
+ if (cbl) {
2104
+ var lo = lob + 2 * ax - r;
2105
+ this.writeFan(-ax + r, +ay - r, 0, 1, lo, iv, ii, n, r, rs, fd, scale, fx, fy);
2106
+ iv += 2 * n - 1;
2107
+ ii += 3 * (n - 1);
2108
+ }
2109
+ this.pad(iv, ii, nv, ni, fd);
2110
+ };
2111
+ EShapeRectangleRoundedTriangulatedImpl.prototype.writeSideNotRight0 = function (lo, ct, cb, iv, ii, n, r, ax, ay, scale, fd, fx, fy) {
2112
+ var fs = (scale - 1) / fd;
2113
+ var xo = -ay - fs;
2114
+ var xd = cb ? -ay + r : xo;
2115
+ var yd = cb ? +ax - r : +ax + fs;
2116
+ var xred = Math.min(2 * ax - ay, 0);
2117
+ var yred = ax - ay - xred;
2118
+ var k = iv;
2119
+ this.writeVertexTop(k++, -yred, xred, lo, fd, scale, fx, fy, ax, ay);
2120
+ this.writeVertexTop(k++, -yd, xd, lo, fd, scale, fx, fy, ax, ay);
2121
+ this.writeVertexTop(k++, -yd, xo, lo, fd, scale, fx, fy, ax, ay);
2122
+ if (ct) {
2123
+ var dangle = (Math.PI * 0.5) / (n - 1);
2124
+ for (var i = 0; i < n; ++i) {
2125
+ var angle = i * dangle;
2126
+ var x = i === 0 ? xo : -ay + r - r * Math.cos(angle);
2127
+ var y = -ax + r - r * Math.sin(angle);
2128
+ this.writeVertexTop(k++, -y, x, lo, fd, scale, fx, fy, ax, ay);
2129
+ }
2130
+ }
2131
+ else {
2132
+ for (var i = 0; i < n; ++i) {
2133
+ this.writeVertexTop(k++, +ax, xo, lo, fd, scale, fx, fy, ax, ay);
2134
+ }
2135
+ }
2136
+ this.writeVertexTop(k++, +ax, 0, lo, fd, scale, fx, fy, ax, ay);
2137
+ var indices = this._indices;
2138
+ for (var i = 1, imax = k - iv - 1; i < imax; ++i) {
2139
+ indices[ii++] = iv;
2140
+ indices[ii++] = iv + i;
2141
+ indices[ii++] = iv + i + 1;
2142
+ }
2143
+ };
2144
+ EShapeRectangleRoundedTriangulatedImpl.prototype.writeSideNotRight1 = function (lo, ct, cb, iv, ii, n, r, ax, ay, scale, fd, fx, fy) {
2145
+ var fs = (scale - 1) / fd;
2146
+ var xo = -ay - fs;
2147
+ var xd = cb ? -ay + r : xo;
2148
+ var yd = cb ? +ax - r : +ax + fs;
2149
+ var xred = Math.min(2 * ax - ay, 0);
2150
+ var yred = ax - ay - xred;
2151
+ var k = iv;
2152
+ this.writeVertexBottom(k++, -yred, -xred, lo, fd, scale, fx, fy, ax, ay);
2153
+ this.writeVertexBottom(k++, -yd, -xd, lo, fd, scale, fx, fy, ax, ay);
2154
+ this.writeVertexBottom(k++, -yd, -xo, lo, fd, scale, fx, fy, ax, ay);
2155
+ if (ct) {
2156
+ var dangle = (Math.PI * 0.5) / (n - 1);
2157
+ for (var i = 0; i < n; ++i) {
2158
+ var angle = i * dangle;
2159
+ var x = i === 0 ? xo : -ay + r - r * Math.cos(angle);
2160
+ var y = -ax + r - r * Math.sin(angle);
2161
+ this.writeVertexBottom(k++, -y, -x, lo, fd, scale, fx, fy, ax, ay);
2162
+ }
2163
+ }
2164
+ else {
2165
+ for (var i = 0; i < n; ++i) {
2166
+ this.writeVertexBottom(k++, +ax, -xo, lo, fd, scale, fx, fy, ax, ay);
2167
+ }
2168
+ }
2169
+ this.writeVertexBottom(k++, +ax, 0, lo, fd, scale, fx, fy, ax, ay);
2170
+ var indices = this._indices;
2171
+ for (var i = 1, imax = k - iv - 1; i < imax; ++i) {
2172
+ indices[ii++] = iv;
2173
+ indices[ii++] = iv + i + 1;
2174
+ indices[ii++] = iv + i;
2175
+ }
2176
+ };
2177
+ /**
2178
+ * Preconditions:
2179
+ * * shape.stroke.side === EShapeStrokeSide.ALL or NONE
2180
+ * * ay <= ax
2181
+ * * 8 * N + 18 <= nv
2182
+ * * 4 * N + 10 <= ni
2183
+ */
2184
+ EShapeRectangleRoundedTriangulatedImpl.prototype.updateAll0 = function (fx, fy, ax, ay, scale, radius, corner, nv, ni) {
2185
+ var d = ay;
2186
+ var fd = 1 / d;
2187
+ var n = this._n >> 2;
2188
+ var s = scale;
2189
+ var fs = (scale - 1) * d;
2190
+ var r = radius * ay;
2191
+ var x0 = -ax - fs;
2192
+ var x1 = -ax + r;
2193
+ var x2 = -ax + d;
2194
+ var x3 = +ax - d;
2195
+ var x4 = +ax - r;
2196
+ var x5 = +ax + fs;
2197
+ var y0 = -ay - fs;
2198
+ var y1 = -ay + r;
2199
+ var y4 = +ay - r;
2200
+ var y5 = +ay + fs;
2201
+ var cr = 0 < radius;
2202
+ var ctl = cr && !!(corner & EShapeCorner.TOP_LEFT);
2203
+ var ctr = cr && !!(corner & EShapeCorner.TOP_RIGHT);
2204
+ var cbl = cr && !!(corner & EShapeCorner.BOTTOM_LEFT);
2205
+ var cbr = cr && !!(corner & EShapeCorner.BOTTOM_RIGHT);
2206
+ var lc = 0.5 * Math.PI * r - 2 * r;
2207
+ var lot = ctl ? -r : 0;
2208
+ var lor = lot + 2 * ax + (ctr ? lc : 0);
2209
+ var lob = lor + 2 * ay + (cbr ? lc : 0);
2210
+ var lol = lob + 2 * ax + (cbl ? lc : 0);
2211
+ var iv = 0;
2212
+ var ii = 0;
2213
+ this.writeHexaTop(iv, ii, lot, ctl ? x1 : x0, ctl ? y1 : y0, x1, y0, x4, y0, ctr ? x4 : x5, ctr ? y1 : y0, x3, 0, x2, 0, fd, s, fx, fy, ax, ay);
2214
+ iv += 6;
2215
+ ii += 12;
2216
+ this.writePentaRight(iv, ii, lor, ctr ? x4 : x5, ctr ? y1 : y0, x5, y1, x5, y4, cbr ? x4 : x5, cbr ? y4 : y5, x3, 0, fd, s, fx, fy, ax, ay);
2217
+ iv += 5;
2218
+ ii += 9;
2219
+ this.writeHexaBottom(iv, ii, lob, cbr ? x4 : x5, cbr ? y4 : y5, x4, y5, x1, y5, cbl ? x1 : x0, cbl ? y4 : y5, x2, 0, x3, 0, fd, s, fx, fy, ax, ay);
2220
+ iv += 6;
2221
+ ii += 12;
2222
+ this.writePentaLeft(iv, ii, lol, cbl ? x1 : x0, cbl ? y4 : y5, x0, y4, x0, y1, ctl ? x1 : x0, ctl ? y1 : y0, x2, 0, fd, s, fx, fy, ax, ay);
2223
+ iv += 5;
2224
+ ii += 9;
2225
+ var rs = r + fs;
2226
+ var l = 2 * ax + lot;
2227
+ if (ctr) {
2228
+ this.writeFan(x4, y1, 0, -1, l, iv, ii, n, r, rs, fd, s, fx, fy);
2229
+ iv += 2 * n - 1;
2230
+ ii += 3 * (n - 1);
2231
+ l += 2 * ay + lc;
2232
+ }
2233
+ else {
2234
+ l += 2 * ay;
2235
+ }
2236
+ if (cbr) {
2237
+ this.writeFan(x4, y4, 1, 0, l, iv, ii, n, r, rs, fd, s, fx, fy);
2238
+ iv += 2 * n - 1;
2239
+ ii += 3 * (n - 1);
2240
+ l += 2 * ax + lc;
2241
+ }
2242
+ else {
2243
+ l += 2 * ax;
2244
+ }
2245
+ if (cbl) {
2246
+ this.writeFan(x1, y4, 0, 1, l, iv, ii, n, r, rs, fd, s, fx, fy);
2247
+ iv += 2 * n - 1;
2248
+ ii += 3 * (n - 1);
2249
+ l += 2 * ay + lc;
2250
+ }
2251
+ else {
2252
+ l += 2 * ay;
2253
+ }
2254
+ if (ctl) {
2255
+ this.writeFan(x1, y1, -1, 0, l, iv, ii, n, r, rs, fd, s, fx, fy);
2256
+ iv += 2 * n - 1;
2257
+ ii += 3 * (n - 1);
2258
+ }
2259
+ this.pad(iv, ii, nv, ni, fd);
2260
+ };
2261
+ /**
2262
+ * Preconditions:
2263
+ * * shape.stroke.side === EShapeStrokeSide.ALL or NONE
2264
+ * * ax < ay
2265
+ * * 8 * N + 18 <= nv
2266
+ * * 4 * N + 10 <= ni
2267
+ */
2268
+ EShapeRectangleRoundedTriangulatedImpl.prototype.updateAll1 = function (fx, fy, ax, ay, scale, radius, corner, nv, ni) {
2269
+ var d = ax;
2270
+ var fd = 1 / d;
2271
+ var n = this._n >> 2;
2272
+ var s = scale;
2273
+ var fs = (scale - 1) * d;
2274
+ var r = radius * ax;
2275
+ var rs = r + fs;
2276
+ var ol = -ax - fs;
2277
+ var or = +ax + fs;
2278
+ var x1 = -ax + r;
2279
+ var x4 = +ax - r;
2280
+ var y0 = -ay - fs;
2281
+ var y1 = -ay + r;
2282
+ var y2 = -ay + d;
2283
+ var y3 = +ay - d;
2284
+ var y4 = +ay - r;
2285
+ var y5 = +ay + fs;
2286
+ var cr = 0 < radius;
2287
+ var ctl = cr && !!(corner & EShapeCorner.TOP_LEFT);
2288
+ var ctr = cr && !!(corner & EShapeCorner.TOP_RIGHT);
2289
+ var cbl = cr && !!(corner & EShapeCorner.BOTTOM_LEFT);
2290
+ var cbr = cr && !!(corner & EShapeCorner.BOTTOM_RIGHT);
2291
+ var lc = 0.5 * Math.PI * r - 2 * r;
2292
+ var lot = ctl ? -r : 0;
2293
+ var lor = lot + 2 * ax + (ctr ? lc : 0);
2294
+ var lob = lor + 2 * ay + (cbr ? lc : 0);
2295
+ var lol = lob + 2 * ax + (cbl ? lc : 0);
2296
+ var iv = 0;
2297
+ var ii = 0;
2298
+ this.writePentaTop(iv, ii, lot, ctl ? x1 : ol, ctl ? y1 : y0, x1, y0, x4, y0, ctr ? x4 : or, ctr ? y1 : y0, 0, y2, fd, s, fx, fy, ax, ay);
2299
+ iv += 5;
2300
+ ii += 9;
2301
+ this.writeHexaRight(iv, ii, lor, ctr ? x4 : or, ctr ? y1 : y0, or, y1, or, y4, cbr ? x4 : or, cbr ? y4 : y5, 0, y3, 0, y2, fd, s, fx, fy, ax, ay);
2302
+ iv += 6;
2303
+ ii += 12;
2304
+ this.writePentaBottom(iv, ii, lob, cbr ? x4 : or, cbr ? y4 : y5, x4, y5, x1, y5, cbl ? x1 : ol, cbl ? y4 : y5, 0, y3, fd, s, fx, fy, ax, ay);
2305
+ iv += 5;
2306
+ ii += 9;
2307
+ this.writeHexaLeft(iv, ii, lol, cbl ? x1 : ol, cbl ? y4 : y5, ol, y4, ol, y1, ctl ? x1 : ol, ctl ? y1 : y0, 0, y2, 0, y3, fd, s, fx, fy, ax, ay);
2308
+ iv += 6;
2309
+ ii += 12;
2310
+ var l = 2 * ax + lot;
2311
+ if (ctr) {
2312
+ this.writeFan(x4, y1, 0, -1, l, iv, ii, n, r, rs, fd, s, fx, fy);
2313
+ iv += 1 + 2 * (n - 1);
2314
+ ii += 3 * (n - 1);
2315
+ l += 2 * ay + lc;
2316
+ }
2317
+ else {
2318
+ l += 2 * ay;
2319
+ }
2320
+ if (cbr) {
2321
+ this.writeFan(x4, y4, 1, 0, l, iv, ii, n, r, rs, fd, s, fx, fy);
2322
+ iv += 1 + 2 * (n - 1);
2323
+ ii += 3 * (n - 1);
2324
+ l += 2 * ax + lc;
2325
+ }
2326
+ else {
2327
+ l += 2 * ax;
2328
+ }
2329
+ if (cbl) {
2330
+ this.writeFan(x1, y4, 0, 1, l, iv, ii, n, r, rs, fd, s, fx, fy);
2331
+ iv += 1 + 2 * (n - 1);
2332
+ ii += 3 * (n - 1);
2333
+ l += 2 * ay + lc;
2334
+ }
2335
+ else {
2336
+ l += 2 * ay;
2337
+ }
2338
+ if (ctl) {
2339
+ this.writeFan(x1, y1, -1, 0, l, iv, ii, n, r, rs, fd, s, fx, fy);
2340
+ iv += 1 + 2 * (n - 1);
2341
+ ii += 3 * (n - 1);
2342
+ }
2343
+ this.pad(iv, ii, nv, ni, fd);
2344
+ };
2345
+ EShapeRectangleRoundedTriangulatedImpl.prototype.writeQuadTop = function (vertex, index, lo, x0, y0, x1, y1, x2, y2, x3, y3, fd, scale, fx, fy, ax, ay) {
2346
+ var index0 = vertex++;
2347
+ var index1 = vertex++;
2348
+ var index2 = vertex++;
2349
+ var index3 = vertex++;
2350
+ this.writeVertexTop(index0, x0, y0, lo, fd, scale, fx, fy, ax, ay);
2351
+ this.writeVertexTop(index1, x1, y1, lo, fd, scale, fx, fy, ax, ay);
2352
+ this.writeVertexTop(index2, x2, y2, lo, fd, scale, fx, fy, ax, ay);
2353
+ this.writeVertexTop(index3, x3, y3, lo, fd, scale, fx, fy, ax, ay);
2354
+ var indices = this._indices;
2355
+ indices[index++] = index0;
2356
+ indices[index++] = index1;
2357
+ indices[index++] = index2;
2358
+ indices[index++] = index0;
2359
+ indices[index++] = index2;
2360
+ indices[index++] = index3;
2361
+ };
2362
+ EShapeRectangleRoundedTriangulatedImpl.prototype.writeQuadRight = function (vertex, index, lo, x0, y0, x1, y1, x2, y2, x3, y3, fd, scale, fx, fy, ax, ay) {
2363
+ var index0 = vertex++;
2364
+ var index1 = vertex++;
2365
+ var index2 = vertex++;
2366
+ var index3 = vertex++;
2367
+ this.writeVertexRight(index0, x0, y0, lo, fd, scale, fx, fy, ax, ay);
2368
+ this.writeVertexRight(index1, x1, y1, lo, fd, scale, fx, fy, ax, ay);
2369
+ this.writeVertexRight(index2, x2, y2, lo, fd, scale, fx, fy, ax, ay);
2370
+ this.writeVertexRight(index3, x3, y3, lo, fd, scale, fx, fy, ax, ay);
2371
+ var indices = this._indices;
2372
+ indices[index++] = index0;
2373
+ indices[index++] = index1;
2374
+ indices[index++] = index2;
2375
+ indices[index++] = index0;
2376
+ indices[index++] = index2;
2377
+ indices[index++] = index3;
2378
+ };
2379
+ EShapeRectangleRoundedTriangulatedImpl.prototype.writeQuadBottom = function (vertex, index, lo, x0, y0, x1, y1, x2, y2, x3, y3, fd, scale, fx, fy, ax, ay) {
2380
+ var index0 = vertex++;
2381
+ var index1 = vertex++;
2382
+ var index2 = vertex++;
2383
+ var index3 = vertex++;
2384
+ this.writeVertexBottom(index0, x0, y0, lo, fd, scale, fx, fy, ax, ay);
2385
+ this.writeVertexBottom(index1, x1, y1, lo, fd, scale, fx, fy, ax, ay);
2386
+ this.writeVertexBottom(index2, x2, y2, lo, fd, scale, fx, fy, ax, ay);
2387
+ this.writeVertexBottom(index3, x3, y3, lo, fd, scale, fx, fy, ax, ay);
2388
+ var indices = this._indices;
2389
+ indices[index++] = index0;
2390
+ indices[index++] = index1;
2391
+ indices[index++] = index2;
2392
+ indices[index++] = index0;
2393
+ indices[index++] = index2;
2394
+ indices[index++] = index3;
2395
+ };
2396
+ EShapeRectangleRoundedTriangulatedImpl.prototype.writeQuadLeft = function (vertex, index, lo, x0, y0, x1, y1, x2, y2, x3, y3, fd, scale, fx, fy, ax, ay) {
2397
+ var index0 = vertex++;
2398
+ var index1 = vertex++;
2399
+ var index2 = vertex++;
2400
+ var index3 = vertex++;
2401
+ this.writeVertexLeft(index0, x0, y0, lo, fd, scale, fx, fy, ax, ay);
2402
+ this.writeVertexLeft(index1, x1, y1, lo, fd, scale, fx, fy, ax, ay);
2403
+ this.writeVertexLeft(index2, x2, y2, lo, fd, scale, fx, fy, ax, ay);
2404
+ this.writeVertexLeft(index3, x3, y3, lo, fd, scale, fx, fy, ax, ay);
2405
+ var indices = this._indices;
2406
+ indices[index++] = index0;
2407
+ indices[index++] = index1;
2408
+ indices[index++] = index2;
2409
+ indices[index++] = index0;
2410
+ indices[index++] = index2;
2411
+ indices[index++] = index3;
2412
+ };
2413
+ EShapeRectangleRoundedTriangulatedImpl.prototype.writePentaTop = function (vertex, index, lo, x0, y0, x1, y1, x2, y2, x3, y3, x4, y4, fd, scale, fx, fy, ax, ay) {
2414
+ var index0 = vertex++;
2415
+ var index1 = vertex++;
2416
+ var index2 = vertex++;
2417
+ var index3 = vertex++;
2418
+ var index4 = vertex++;
2419
+ this.writeVertexTop(index0, x0, y0, lo, fd, scale, fx, fy, ax, ay);
2420
+ this.writeVertexTop(index1, x1, y1, lo, fd, scale, fx, fy, ax, ay);
2421
+ this.writeVertexTop(index2, x2, y2, lo, fd, scale, fx, fy, ax, ay);
2422
+ this.writeVertexTop(index3, x3, y3, lo, fd, scale, fx, fy, ax, ay);
2423
+ this.writeVertexTop(index4, x4, y4, lo, fd, scale, fx, fy, ax, ay);
2424
+ var indices = this._indices;
2425
+ indices[index++] = index0;
2426
+ indices[index++] = index1;
2427
+ indices[index++] = index2;
2428
+ indices[index++] = index0;
2429
+ indices[index++] = index2;
2430
+ indices[index++] = index3;
2431
+ indices[index++] = index0;
2432
+ indices[index++] = index3;
2433
+ indices[index++] = index4;
2434
+ };
2435
+ EShapeRectangleRoundedTriangulatedImpl.prototype.writePentaRight = function (vertex, index, lo, x0, y0, x1, y1, x2, y2, x3, y3, x4, y4, fd, scale, fx, fy, ax, ay) {
2436
+ var index0 = vertex++;
2437
+ var index1 = vertex++;
2438
+ var index2 = vertex++;
2439
+ var index3 = vertex++;
2440
+ var index4 = vertex++;
2441
+ this.writeVertexRight(index0, x0, y0, lo, fd, scale, fx, fy, ax, ay);
2442
+ this.writeVertexRight(index1, x1, y1, lo, fd, scale, fx, fy, ax, ay);
2443
+ this.writeVertexRight(index2, x2, y2, lo, fd, scale, fx, fy, ax, ay);
2444
+ this.writeVertexRight(index3, x3, y3, lo, fd, scale, fx, fy, ax, ay);
2445
+ this.writeVertexRight(index4, x4, y4, lo, fd, scale, fx, fy, ax, ay);
2446
+ var indices = this._indices;
2447
+ indices[index++] = index0;
2448
+ indices[index++] = index1;
2449
+ indices[index++] = index2;
2450
+ indices[index++] = index0;
2451
+ indices[index++] = index2;
2452
+ indices[index++] = index3;
2453
+ indices[index++] = index0;
2454
+ indices[index++] = index3;
2455
+ indices[index++] = index4;
2456
+ };
2457
+ EShapeRectangleRoundedTriangulatedImpl.prototype.writePentaBottom = function (vertex, index, lo, x0, y0, x1, y1, x2, y2, x3, y3, x4, y4, fd, scale, fx, fy, ax, ay) {
2458
+ var index0 = vertex++;
2459
+ var index1 = vertex++;
2460
+ var index2 = vertex++;
2461
+ var index3 = vertex++;
2462
+ var index4 = vertex++;
2463
+ this.writeVertexBottom(index0, x0, y0, lo, fd, scale, fx, fy, ax, ay);
2464
+ this.writeVertexBottom(index1, x1, y1, lo, fd, scale, fx, fy, ax, ay);
2465
+ this.writeVertexBottom(index2, x2, y2, lo, fd, scale, fx, fy, ax, ay);
2466
+ this.writeVertexBottom(index3, x3, y3, lo, fd, scale, fx, fy, ax, ay);
2467
+ this.writeVertexBottom(index4, x4, y4, lo, fd, scale, fx, fy, ax, ay);
2468
+ var indices = this._indices;
2469
+ indices[index++] = index0;
2470
+ indices[index++] = index1;
2471
+ indices[index++] = index2;
2472
+ indices[index++] = index0;
2473
+ indices[index++] = index2;
2474
+ indices[index++] = index3;
2475
+ indices[index++] = index0;
2476
+ indices[index++] = index3;
2477
+ indices[index++] = index4;
2478
+ };
2479
+ EShapeRectangleRoundedTriangulatedImpl.prototype.writePentaLeft = function (vertex, index, lo, x0, y0, x1, y1, x2, y2, x3, y3, x4, y4, fd, scale, fx, fy, ax, ay) {
2480
+ var index0 = vertex++;
2481
+ var index1 = vertex++;
2482
+ var index2 = vertex++;
2483
+ var index3 = vertex++;
2484
+ var index4 = vertex++;
2485
+ this.writeVertexLeft(index0, x0, y0, lo, fd, scale, fx, fy, ax, ay);
2486
+ this.writeVertexLeft(index1, x1, y1, lo, fd, scale, fx, fy, ax, ay);
2487
+ this.writeVertexLeft(index2, x2, y2, lo, fd, scale, fx, fy, ax, ay);
2488
+ this.writeVertexLeft(index3, x3, y3, lo, fd, scale, fx, fy, ax, ay);
2489
+ this.writeVertexLeft(index4, x4, y4, lo, fd, scale, fx, fy, ax, ay);
2490
+ var indices = this._indices;
2491
+ indices[index++] = index0;
2492
+ indices[index++] = index1;
2493
+ indices[index++] = index2;
2494
+ indices[index++] = index0;
2495
+ indices[index++] = index2;
2496
+ indices[index++] = index3;
2497
+ indices[index++] = index0;
2498
+ indices[index++] = index3;
2499
+ indices[index++] = index4;
2500
+ };
2501
+ EShapeRectangleRoundedTriangulatedImpl.prototype.writeHexaTop = function (vertex, index, lo, x0, y0, x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, fd, scale, fx, fy, ax, ay) {
2502
+ var index0 = vertex++;
2503
+ var index1 = vertex++;
2504
+ var index2 = vertex++;
2505
+ var index3 = vertex++;
2506
+ var index4 = vertex++;
2507
+ var index5 = vertex++;
2508
+ this.writeVertexTop(index0, x0, y0, lo, fd, scale, fx, fy, ax, ay);
2509
+ this.writeVertexTop(index1, x1, y1, lo, fd, scale, fx, fy, ax, ay);
2510
+ this.writeVertexTop(index2, x2, y2, lo, fd, scale, fx, fy, ax, ay);
2511
+ this.writeVertexTop(index3, x3, y3, lo, fd, scale, fx, fy, ax, ay);
2512
+ this.writeVertexTop(index4, x4, y4, lo, fd, scale, fx, fy, ax, ay);
2513
+ this.writeVertexTop(index5, x5, y5, lo, fd, scale, fx, fy, ax, ay);
2514
+ var indices = this._indices;
2515
+ indices[index++] = index0;
2516
+ indices[index++] = index1;
2517
+ indices[index++] = index2;
2518
+ indices[index++] = index0;
2519
+ indices[index++] = index2;
2520
+ indices[index++] = index3;
2521
+ indices[index++] = index0;
2522
+ indices[index++] = index3;
2523
+ indices[index++] = index4;
2524
+ indices[index++] = index0;
2525
+ indices[index++] = index4;
2526
+ indices[index++] = index5;
2527
+ };
2528
+ EShapeRectangleRoundedTriangulatedImpl.prototype.writeHexaRight = function (vertex, index, lo, x0, y0, x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, fd, scale, fx, fy, ax, ay) {
2529
+ var index0 = vertex++;
2530
+ var index1 = vertex++;
2531
+ var index2 = vertex++;
2532
+ var index3 = vertex++;
2533
+ var index4 = vertex++;
2534
+ var index5 = vertex++;
2535
+ this.writeVertexRight(index0, x0, y0, lo, fd, scale, fx, fy, ax, ay);
2536
+ this.writeVertexRight(index1, x1, y1, lo, fd, scale, fx, fy, ax, ay);
2537
+ this.writeVertexRight(index2, x2, y2, lo, fd, scale, fx, fy, ax, ay);
2538
+ this.writeVertexRight(index3, x3, y3, lo, fd, scale, fx, fy, ax, ay);
2539
+ this.writeVertexRight(index4, x4, y4, lo, fd, scale, fx, fy, ax, ay);
2540
+ this.writeVertexRight(index5, x5, y5, lo, fd, scale, fx, fy, ax, ay);
2541
+ var indices = this._indices;
2542
+ indices[index++] = index0;
2543
+ indices[index++] = index1;
2544
+ indices[index++] = index2;
2545
+ indices[index++] = index0;
2546
+ indices[index++] = index2;
2547
+ indices[index++] = index3;
2548
+ indices[index++] = index0;
2549
+ indices[index++] = index3;
2550
+ indices[index++] = index4;
2551
+ indices[index++] = index0;
2552
+ indices[index++] = index4;
2553
+ indices[index++] = index5;
2554
+ };
2555
+ EShapeRectangleRoundedTriangulatedImpl.prototype.writeHexaBottom = function (vertex, index, lo, x0, y0, x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, fd, scale, fx, fy, ax, ay) {
2556
+ var index0 = vertex++;
2557
+ var index1 = vertex++;
2558
+ var index2 = vertex++;
2559
+ var index3 = vertex++;
2560
+ var index4 = vertex++;
2561
+ var index5 = vertex++;
2562
+ this.writeVertexBottom(index0, x0, y0, lo, fd, scale, fx, fy, ax, ay);
2563
+ this.writeVertexBottom(index1, x1, y1, lo, fd, scale, fx, fy, ax, ay);
2564
+ this.writeVertexBottom(index2, x2, y2, lo, fd, scale, fx, fy, ax, ay);
2565
+ this.writeVertexBottom(index3, x3, y3, lo, fd, scale, fx, fy, ax, ay);
2566
+ this.writeVertexBottom(index4, x4, y4, lo, fd, scale, fx, fy, ax, ay);
2567
+ this.writeVertexBottom(index5, x5, y5, lo, fd, scale, fx, fy, ax, ay);
2568
+ var indices = this._indices;
2569
+ indices[index++] = index0;
2570
+ indices[index++] = index1;
2571
+ indices[index++] = index2;
2572
+ indices[index++] = index0;
2573
+ indices[index++] = index2;
2574
+ indices[index++] = index3;
2575
+ indices[index++] = index0;
2576
+ indices[index++] = index3;
2577
+ indices[index++] = index4;
2578
+ indices[index++] = index0;
2579
+ indices[index++] = index4;
2580
+ indices[index++] = index5;
2581
+ };
2582
+ EShapeRectangleRoundedTriangulatedImpl.prototype.writeHexaLeft = function (vertex, index, lo, x0, y0, x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, fd, scale, fx, fy, ax, ay) {
2583
+ var index0 = vertex++;
2584
+ var index1 = vertex++;
2585
+ var index2 = vertex++;
2586
+ var index3 = vertex++;
2587
+ var index4 = vertex++;
2588
+ var index5 = vertex++;
2589
+ this.writeVertexLeft(index0, x0, y0, lo, fd, scale, fx, fy, ax, ay);
2590
+ this.writeVertexLeft(index1, x1, y1, lo, fd, scale, fx, fy, ax, ay);
2591
+ this.writeVertexLeft(index2, x2, y2, lo, fd, scale, fx, fy, ax, ay);
2592
+ this.writeVertexLeft(index3, x3, y3, lo, fd, scale, fx, fy, ax, ay);
2593
+ this.writeVertexLeft(index4, x4, y4, lo, fd, scale, fx, fy, ax, ay);
2594
+ this.writeVertexLeft(index5, x5, y5, lo, fd, scale, fx, fy, ax, ay);
2595
+ var indices = this._indices;
2596
+ indices[index++] = index0;
2597
+ indices[index++] = index1;
2598
+ indices[index++] = index2;
2599
+ indices[index++] = index0;
2600
+ indices[index++] = index2;
2601
+ indices[index++] = index3;
2602
+ indices[index++] = index0;
2603
+ indices[index++] = index3;
2604
+ indices[index++] = index4;
2605
+ indices[index++] = index0;
2606
+ indices[index++] = index4;
2607
+ indices[index++] = index5;
2608
+ };
2609
+ EShapeRectangleRoundedTriangulatedImpl.prototype.writeFan = function (cx, cy, cos0, sin0, lo, iv, ii, n, r, rs, fd, scale, fx, fy) {
2610
+ var dangle = (Math.PI * 0.5) / (n - 1);
2611
+ var c = Math.cos(dangle);
2612
+ var s = Math.sin(dangle);
2613
+ var dl = 0.5 * r * dangle;
2614
+ var dx = rs * cos0;
2615
+ var dy = rs * sin0;
2616
+ var iv0 = iv++;
2617
+ var l = lo;
2618
+ this.writeVertex(iv0, cx + dx, cy + dy, fd, lo, scale, fx, fy);
2619
+ var indices = this._indices;
2620
+ var cc = 1 - r * fd;
2621
+ for (var i = 0; i < n - 1; ++i) {
2622
+ var iv1 = iv++;
2623
+ l += dl;
2624
+ this.writeVertex(iv1, cx, cy, fd, l, cc, fx, fy);
2625
+ var iv2 = iv++;
2626
+ l += dl;
2627
+ var ndx = c * dx - s * dy;
2628
+ var ndy = s * dx + c * dy;
2629
+ this.writeVertex(iv2, cx + ndx, cy + ndy, fd, l, scale, fx, fy);
2630
+ dx = ndx;
2631
+ dy = ndy;
2632
+ indices[ii++] = iv1;
2633
+ indices[ii++] = iv0;
2634
+ indices[ii++] = iv2;
2635
+ iv0 = iv2;
2636
+ }
2637
+ };
2638
+ EShapeRectangleRoundedTriangulatedImpl.prototype.writeVertexTop = function (vertex, x, y, lengthOffset, fdistance, scale, fx, fy, ax, ay) {
2639
+ this.writeVertex(vertex, x, y, fdistance, lengthOffset + x + ax, Math.min(scale, (y + ay) * -fdistance + 1), fx, fy);
2640
+ };
2641
+ EShapeRectangleRoundedTriangulatedImpl.prototype.writeVertexRight = function (vertex, x, y, lengthOffset, fdistance, scale, fx, fy, ax, ay) {
2642
+ this.writeVertex(vertex, x, y, fdistance, lengthOffset + y + ay, Math.min(scale, (x - ax) * fdistance + 1), fx, fy);
2643
+ };
2644
+ EShapeRectangleRoundedTriangulatedImpl.prototype.writeVertexBottom = function (vertex, x, y, lengthOffset, fdistance, scale, fx, fy, ax, ay) {
2645
+ this.writeVertex(vertex, x, y, fdistance, lengthOffset + ax - x, Math.min(scale, (y - ay) * fdistance + 1), fx, fy);
2646
+ };
2647
+ EShapeRectangleRoundedTriangulatedImpl.prototype.writeVertexLeft = function (vertex, x, y, lengthOffset, fdistance, scale, fx, fy, ax, ay) {
2648
+ this.writeVertex(vertex, x, y, fdistance, lengthOffset + ay - y, Math.min(scale, (x + ax) * -fdistance + 1), fx, fy);
2649
+ };
2650
+ EShapeRectangleRoundedTriangulatedImpl.prototype.writeVertex = function (iv, x, y, distance, length, clipping, fx, fy) {
2651
+ var iv2 = iv << 1;
2652
+ this._vertices[iv2] = x;
2653
+ this._vertices[iv2 + 1] = y;
2654
+ this._distances[iv] = distance;
2655
+ this._lengths[iv] = length;
2656
+ this._clippings[iv] = clipping;
2657
+ this._uvs[iv2] = 0.5 * (x * fx + 1);
2658
+ this._uvs[iv2 + 1] = 0.5 * (y * fy + 1);
2659
+ };
2660
+ return EShapeRectangleRoundedTriangulatedImpl;
2661
+ }());
2662
+ export { EShapeRectangleRoundedTriangulatedImpl };
2663
+ //# sourceMappingURL=e-shape-rectangle-rounded-triangulated-impl.js.map