@wcardinal/wcardinal-ui 0.466.1 → 0.466.2-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/types/wcardinal/ui/shape/e-shape-transform.d.ts +8 -0
- package/dist/types/wcardinal/ui/shape/e-shape-type.d.ts +1 -0
- package/dist/types/wcardinal/ui/shape/load/index.d.ts +1 -0
- package/dist/types/wcardinal/ui/shape/load/load-shape-triangle-legacy.d.ts +1 -0
- package/dist/types/wcardinal/ui/shape/variant/build-triangle-legacy.d.ts +9 -0
- package/dist/types/wcardinal/ui/shape/variant/build-triangle.d.ts +1 -9
- package/dist/types/wcardinal/ui/shape/variant/builder-triangle-legacy.d.ts +9 -0
- package/dist/types/wcardinal/ui/shape/variant/builder-triangle.d.ts +1 -9
- package/dist/types/wcardinal/ui/shape/variant/create-triangle-legacy-uploaded.d.ts +4 -0
- package/dist/types/wcardinal/ui/shape/variant/create-triangle-uploaded.d.ts +1 -4
- package/dist/types/wcardinal/ui/shape/variant/deserialize-triangle-legacy.d.ts +4 -0
- package/dist/types/wcardinal/ui/shape/variant/e-shape-rectangle-triangulated-impl.d.ts +2 -2
- package/dist/types/wcardinal/ui/shape/variant/e-shape-triangle-legacy.d.ts +7 -0
- package/dist/types/wcardinal/ui/shape/variant/e-shape-triangle-triangulated-impl.d.ts +42 -0
- package/dist/types/wcardinal/ui/shape/variant/e-shape-triangle-triangulated.d.ts +3 -0
- package/dist/types/wcardinal/ui/shape/variant/e-shape-triangle.d.ts +4 -0
- package/dist/types/wcardinal/ui/shape/variant/hit-test-circle.d.ts +1 -0
- package/dist/types/wcardinal/ui/shape/variant/hit-test-rectangle.d.ts +1 -0
- package/dist/types/wcardinal/ui/shape/variant/hit-test-triangle.d.ts +1 -0
- package/dist/types/wcardinal/ui/shape/variant/index.d.ts +7 -0
- package/dist/wcardinal/ui/shape/action/e-shape-action-runtime-transform-move-forward-or-backward.js +1 -3
- package/dist/wcardinal/ui/shape/action/e-shape-action-runtime-transform-move-forward-or-backward.js.map +1 -1
- package/dist/wcardinal/ui/shape/action/e-shape-action-runtime-transform-move-left-or-right.js +1 -3
- package/dist/wcardinal/ui/shape/action/e-shape-action-runtime-transform-move-left-or-right.js.map +1 -1
- package/dist/wcardinal/ui/shape/action/e-shape-action-runtime-transform-resize.js +1 -3
- package/dist/wcardinal/ui/shape/action/e-shape-action-runtime-transform-resize.js.map +1 -1
- package/dist/wcardinal/ui/shape/e-shape-transform.js +28 -0
- package/dist/wcardinal/ui/shape/e-shape-transform.js.map +1 -1
- package/dist/wcardinal/ui/shape/e-shape-type.js +1 -0
- package/dist/wcardinal/ui/shape/e-shape-type.js.map +1 -1
- package/dist/wcardinal/ui/shape/load/index.js +1 -0
- package/dist/wcardinal/ui/shape/load/index.js.map +1 -1
- package/dist/wcardinal/ui/shape/load/load-shape-all.js +2 -0
- package/dist/wcardinal/ui/shape/load/load-shape-all.js.map +1 -1
- package/dist/wcardinal/ui/shape/load/load-shape-triangle-legacy.js +14 -0
- package/dist/wcardinal/ui/shape/load/load-shape-triangle-legacy.js.map +1 -0
- package/dist/wcardinal/ui/shape/load/load-shape-triangle-rounded.js +1 -1
- package/dist/wcardinal/ui/shape/load/load-shape-triangle-rounded.js.map +1 -1
- package/dist/wcardinal/ui/shape/load/load-shape-triangle.js +2 -2
- package/dist/wcardinal/ui/shape/load/load-shape-triangle.js.map +1 -1
- package/dist/wcardinal/ui/shape/variant/build-triangle-legacy.js +160 -0
- package/dist/wcardinal/ui/shape/variant/build-triangle-legacy.js.map +1 -0
- package/dist/wcardinal/ui/shape/variant/build-triangle.js +5 -159
- package/dist/wcardinal/ui/shape/variant/build-triangle.js.map +1 -1
- package/dist/wcardinal/ui/shape/variant/builder-line-of-triangles.js +16 -16
- package/dist/wcardinal/ui/shape/variant/builder-line-of-triangles.js.map +1 -1
- package/dist/wcardinal/ui/shape/variant/builder-marker-triangle.js +6 -6
- package/dist/wcardinal/ui/shape/variant/builder-marker-triangle.js.map +1 -1
- package/dist/wcardinal/ui/shape/variant/builder-triangle-legacy.js +71 -0
- package/dist/wcardinal/ui/shape/variant/builder-triangle-legacy.js.map +1 -0
- package/dist/wcardinal/ui/shape/variant/builder-triangle.js +1 -66
- package/dist/wcardinal/ui/shape/variant/builder-triangle.js.map +1 -1
- package/dist/wcardinal/ui/shape/variant/create-line-of-triangles-uploaded.js +2 -2
- package/dist/wcardinal/ui/shape/variant/create-line-of-triangles-uploaded.js.map +1 -1
- package/dist/wcardinal/ui/shape/variant/create-line-uploaded.js +3 -3
- package/dist/wcardinal/ui/shape/variant/create-line-uploaded.js.map +1 -1
- package/dist/wcardinal/ui/shape/variant/create-triangle-legacy-uploaded.js +24 -0
- package/dist/wcardinal/ui/shape/variant/create-triangle-legacy-uploaded.js.map +1 -0
- package/dist/wcardinal/ui/shape/variant/create-triangle-uploaded.js +1 -19
- package/dist/wcardinal/ui/shape/variant/create-triangle-uploaded.js.map +1 -1
- package/dist/wcardinal/ui/shape/variant/deserialize-triangle-legacy.js +10 -0
- package/dist/wcardinal/ui/shape/variant/deserialize-triangle-legacy.js.map +1 -0
- package/dist/wcardinal/ui/shape/variant/e-shape-circle-legacy.js +2 -2
- package/dist/wcardinal/ui/shape/variant/e-shape-circle-legacy.js.map +1 -1
- package/dist/wcardinal/ui/shape/variant/e-shape-line-base.js +6 -6
- package/dist/wcardinal/ui/shape/variant/e-shape-line-base.js.map +1 -1
- package/dist/wcardinal/ui/shape/variant/e-shape-line-of-circles.js +2 -2
- package/dist/wcardinal/ui/shape/variant/e-shape-line-of-circles.js.map +1 -1
- package/dist/wcardinal/ui/shape/variant/e-shape-rectangle-legacy.js +2 -2
- package/dist/wcardinal/ui/shape/variant/e-shape-rectangle-legacy.js.map +1 -1
- package/dist/wcardinal/ui/shape/variant/e-shape-rectangle-triangulated-impl.js.map +1 -1
- package/dist/wcardinal/ui/shape/variant/e-shape-triangle-legacy.js +27 -0
- package/dist/wcardinal/ui/shape/variant/e-shape-triangle-legacy.js.map +1 -0
- package/dist/wcardinal/ui/shape/variant/e-shape-triangle-triangulated-impl.js +264 -0
- package/dist/wcardinal/ui/shape/variant/e-shape-triangle-triangulated-impl.js.map +1 -0
- package/dist/wcardinal/ui/shape/variant/e-shape-triangle-triangulated.js +6 -0
- package/dist/wcardinal/ui/shape/variant/e-shape-triangle-triangulated.js.map +1 -0
- package/dist/wcardinal/ui/shape/variant/e-shape-triangle.js +14 -1
- package/dist/wcardinal/ui/shape/variant/e-shape-triangle.js.map +1 -1
- package/dist/wcardinal/ui/shape/variant/hit-test-circle.js +54 -20
- package/dist/wcardinal/ui/shape/variant/hit-test-circle.js.map +1 -1
- package/dist/wcardinal/ui/shape/variant/hit-test-rectangle.js +82 -42
- package/dist/wcardinal/ui/shape/variant/hit-test-rectangle.js.map +1 -1
- package/dist/wcardinal/ui/shape/variant/hit-test-semicircle.js +2 -2
- package/dist/wcardinal/ui/shape/variant/hit-test-semicircle.js.map +1 -1
- package/dist/wcardinal/ui/shape/variant/hit-test-triangle.js +53 -12
- package/dist/wcardinal/ui/shape/variant/hit-test-triangle.js.map +1 -1
- package/dist/wcardinal/ui/shape/variant/index.js +7 -0
- package/dist/wcardinal/ui/shape/variant/index.js.map +1 -1
- package/dist/wcardinal-ui-theme-dark-en-us.js +1 -1
- package/dist/wcardinal-ui-theme-dark-en-us.min.js +1 -1
- package/dist/wcardinal-ui-theme-dark-ja-jp.js +1 -1
- package/dist/wcardinal-ui-theme-dark-ja-jp.min.js +1 -1
- package/dist/wcardinal-ui-theme-dark.js +1 -1
- package/dist/wcardinal-ui-theme-dark.min.js +1 -1
- package/dist/wcardinal-ui-theme-white-en-us.js +1 -1
- package/dist/wcardinal-ui-theme-white-en-us.min.js +1 -1
- package/dist/wcardinal-ui-theme-white-ja-jp.js +1 -1
- package/dist/wcardinal-ui-theme-white-ja-jp.min.js +1 -1
- package/dist/wcardinal-ui-theme-white.js +1 -1
- package/dist/wcardinal-ui-theme-white.min.js +1 -1
- package/dist/wcardinal-ui.cjs.js +802 -335
- package/dist/wcardinal-ui.js +802 -335
- package/dist/wcardinal-ui.min.js +2 -2
- package/dist/wcardinal-ui.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2019-2026 Toshiba Corporation
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
var EShapeTriangleTriangulatedImpl = /** @class */ (function () {
|
|
6
|
+
function EShapeTriangleTriangulatedImpl(parent) {
|
|
7
|
+
this._id = 0;
|
|
8
|
+
this._parent = parent;
|
|
9
|
+
this._width = 0;
|
|
10
|
+
this._height = 0;
|
|
11
|
+
this._strokeAlign = 0;
|
|
12
|
+
this._strokeWidth = 0;
|
|
13
|
+
this._sizeX = 0;
|
|
14
|
+
this._sizeY = 0;
|
|
15
|
+
this._vertices = [];
|
|
16
|
+
this._nvertices = 0;
|
|
17
|
+
this._distances = [];
|
|
18
|
+
this._lengths = [];
|
|
19
|
+
this._clippings = [];
|
|
20
|
+
this._uvs = [];
|
|
21
|
+
this._indices = [];
|
|
22
|
+
this._nindices = 0;
|
|
23
|
+
this._boundary = [0, 0, 0, 0];
|
|
24
|
+
}
|
|
25
|
+
Object.defineProperty(EShapeTriangleTriangulatedImpl.prototype, "id", {
|
|
26
|
+
get: function () {
|
|
27
|
+
this.triangulate();
|
|
28
|
+
return this._id;
|
|
29
|
+
},
|
|
30
|
+
enumerable: false,
|
|
31
|
+
configurable: true
|
|
32
|
+
});
|
|
33
|
+
Object.defineProperty(EShapeTriangleTriangulatedImpl.prototype, "vertices", {
|
|
34
|
+
get: function () {
|
|
35
|
+
this.triangulate();
|
|
36
|
+
return this._vertices;
|
|
37
|
+
},
|
|
38
|
+
enumerable: false,
|
|
39
|
+
configurable: true
|
|
40
|
+
});
|
|
41
|
+
Object.defineProperty(EShapeTriangleTriangulatedImpl.prototype, "nvertices", {
|
|
42
|
+
get: function () {
|
|
43
|
+
this.triangulate();
|
|
44
|
+
return this._nvertices;
|
|
45
|
+
},
|
|
46
|
+
enumerable: false,
|
|
47
|
+
configurable: true
|
|
48
|
+
});
|
|
49
|
+
Object.defineProperty(EShapeTriangleTriangulatedImpl.prototype, "distances", {
|
|
50
|
+
get: function () {
|
|
51
|
+
this.triangulate();
|
|
52
|
+
return this._distances;
|
|
53
|
+
},
|
|
54
|
+
enumerable: false,
|
|
55
|
+
configurable: true
|
|
56
|
+
});
|
|
57
|
+
Object.defineProperty(EShapeTriangleTriangulatedImpl.prototype, "lengths", {
|
|
58
|
+
get: function () {
|
|
59
|
+
this.triangulate();
|
|
60
|
+
return this._lengths;
|
|
61
|
+
},
|
|
62
|
+
enumerable: false,
|
|
63
|
+
configurable: true
|
|
64
|
+
});
|
|
65
|
+
Object.defineProperty(EShapeTriangleTriangulatedImpl.prototype, "clippings", {
|
|
66
|
+
get: function () {
|
|
67
|
+
this.triangulate();
|
|
68
|
+
return this._clippings;
|
|
69
|
+
},
|
|
70
|
+
enumerable: false,
|
|
71
|
+
configurable: true
|
|
72
|
+
});
|
|
73
|
+
Object.defineProperty(EShapeTriangleTriangulatedImpl.prototype, "uvs", {
|
|
74
|
+
get: function () {
|
|
75
|
+
this.triangulate();
|
|
76
|
+
return this._uvs;
|
|
77
|
+
},
|
|
78
|
+
enumerable: false,
|
|
79
|
+
configurable: true
|
|
80
|
+
});
|
|
81
|
+
Object.defineProperty(EShapeTriangleTriangulatedImpl.prototype, "indices", {
|
|
82
|
+
get: function () {
|
|
83
|
+
this.triangulate();
|
|
84
|
+
return this._indices;
|
|
85
|
+
},
|
|
86
|
+
enumerable: false,
|
|
87
|
+
configurable: true
|
|
88
|
+
});
|
|
89
|
+
Object.defineProperty(EShapeTriangleTriangulatedImpl.prototype, "nindices", {
|
|
90
|
+
get: function () {
|
|
91
|
+
this.triangulate();
|
|
92
|
+
return this._nindices;
|
|
93
|
+
},
|
|
94
|
+
enumerable: false,
|
|
95
|
+
configurable: true
|
|
96
|
+
});
|
|
97
|
+
Object.defineProperty(EShapeTriangleTriangulatedImpl.prototype, "boundary", {
|
|
98
|
+
get: function () {
|
|
99
|
+
this.triangulate();
|
|
100
|
+
return this._boundary;
|
|
101
|
+
},
|
|
102
|
+
enumerable: false,
|
|
103
|
+
configurable: true
|
|
104
|
+
});
|
|
105
|
+
EShapeTriangleTriangulatedImpl.prototype.triangulate = function () {
|
|
106
|
+
var isNotInitialized = this._id === 0;
|
|
107
|
+
var parent = this._parent;
|
|
108
|
+
var size = parent.size;
|
|
109
|
+
var width = size.x;
|
|
110
|
+
var height = size.y;
|
|
111
|
+
var isRectChanged = this._width !== width || this._height !== height;
|
|
112
|
+
var stroke = parent.stroke;
|
|
113
|
+
var strokeAlign = stroke.align;
|
|
114
|
+
var strokeWidth = stroke.enable ? stroke.width : 0;
|
|
115
|
+
var isStrokeChanged = this._strokeAlign !== strokeAlign || this._strokeWidth !== strokeWidth;
|
|
116
|
+
var isSizeChanged = false;
|
|
117
|
+
var sizeX = this._sizeX;
|
|
118
|
+
var sizeY = this._sizeY;
|
|
119
|
+
if (isRectChanged || isStrokeChanged) {
|
|
120
|
+
this._width = width;
|
|
121
|
+
this._height = height;
|
|
122
|
+
this._strokeAlign = strokeAlign;
|
|
123
|
+
this._strokeWidth = strokeWidth;
|
|
124
|
+
var s = strokeAlign * strokeWidth;
|
|
125
|
+
sizeX = width * 0.5 + (0 <= width ? +s : -s);
|
|
126
|
+
sizeY = height * 0.5 + (0 <= height ? +s : -s);
|
|
127
|
+
isSizeChanged = this._sizeX !== sizeX || this._sizeY !== sizeY;
|
|
128
|
+
}
|
|
129
|
+
if (isNotInitialized || isSizeChanged || isStrokeChanged) {
|
|
130
|
+
this._sizeX = sizeX;
|
|
131
|
+
this._sizeY = sizeY;
|
|
132
|
+
this.update(sizeX, sizeY, 1.1);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
EShapeTriangleTriangulatedImpl.prototype.update = function (sizeX, sizeY, scale) {
|
|
136
|
+
// Boundary
|
|
137
|
+
var ax = Math.abs(sizeX);
|
|
138
|
+
var ay = Math.abs(sizeY);
|
|
139
|
+
var boundary = this._boundary;
|
|
140
|
+
boundary[0] = -ax;
|
|
141
|
+
boundary[1] = -ay;
|
|
142
|
+
boundary[2] = +ax;
|
|
143
|
+
boundary[3] = +ay;
|
|
144
|
+
// # of vertices and # of indices
|
|
145
|
+
var nv = 7;
|
|
146
|
+
var ni = 3;
|
|
147
|
+
this._nvertices = nv;
|
|
148
|
+
this._nindices = ni;
|
|
149
|
+
// ID
|
|
150
|
+
this._id += 1;
|
|
151
|
+
//
|
|
152
|
+
if (sizeX === 0 || sizeY === 0) {
|
|
153
|
+
this.pad(0, 0, nv, ni, 0);
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
this.updateAll(sizeX, sizeY, scale);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* Fills the unused tail with degenerated triangles and trims the arrays
|
|
161
|
+
* so that the buffers always hold exactly `nv` vertices and `ni` triangles.
|
|
162
|
+
*/
|
|
163
|
+
EShapeTriangleTriangulatedImpl.prototype.pad = function (iv, ii, nv, ni, fd) {
|
|
164
|
+
var vertices = this._vertices;
|
|
165
|
+
var distances = this._distances;
|
|
166
|
+
var lengths = this._lengths;
|
|
167
|
+
var clippings = this._clippings;
|
|
168
|
+
var uvs = this._uvs;
|
|
169
|
+
var indices = this._indices;
|
|
170
|
+
for (var i = iv; i < nv; ++i) {
|
|
171
|
+
var i2 = i << 1;
|
|
172
|
+
vertices[i2] = 0;
|
|
173
|
+
vertices[i2 + 1] = 0;
|
|
174
|
+
distances[i] = fd;
|
|
175
|
+
lengths[i] = 0;
|
|
176
|
+
clippings[i] = 0;
|
|
177
|
+
uvs[i2] = 0.5;
|
|
178
|
+
uvs[i2 + 1] = 0.5;
|
|
179
|
+
}
|
|
180
|
+
for (var i = ii, imax = ni * 3; i < imax; ++i) {
|
|
181
|
+
indices[i] = 0;
|
|
182
|
+
}
|
|
183
|
+
var nv2 = nv << 1;
|
|
184
|
+
vertices.length = nv2;
|
|
185
|
+
distances.length = nv;
|
|
186
|
+
lengths.length = nv;
|
|
187
|
+
clippings.length = nv;
|
|
188
|
+
uvs.length = nv2;
|
|
189
|
+
indices.length = ni * 3;
|
|
190
|
+
};
|
|
191
|
+
EShapeTriangleTriangulatedImpl.prototype.updateAll = function (sx, sy, scale) {
|
|
192
|
+
var fx = 1 / sx;
|
|
193
|
+
var fy = 1 / sy;
|
|
194
|
+
var ax = Math.abs(sx);
|
|
195
|
+
var ay = Math.abs(sy);
|
|
196
|
+
// The triangle is defined by the apex (0, -sy) and the two base
|
|
197
|
+
// vertices (-sx, sy) and (sx, sy). The signs of sx and
|
|
198
|
+
// sy intentionally preserve horizontal and vertical reflections.
|
|
199
|
+
// The sloped edge spans ax horizontally and 2 * ay vertically.
|
|
200
|
+
var side = Math.sqrt(ax * ax + 4 * ay * ay);
|
|
201
|
+
// The base is horizontal, so its length is twice the half-width.
|
|
202
|
+
var base = 2 * ax;
|
|
203
|
+
// Length values are measured along the triangle perimeter.
|
|
204
|
+
var perimeter = 2 * side + base;
|
|
205
|
+
// The incenter lies on the vertical center line. This is its y-coordinate.
|
|
206
|
+
// Along the median, the distances from the top vertex to the incenter and
|
|
207
|
+
// from the incenter to the base are in the ratio 2 * side : base.
|
|
208
|
+
// Thus, (ay + cy) : (ay - cy) = 2 * side : base.
|
|
209
|
+
// 2 side (ay - cy) = base * (ay + cy)
|
|
210
|
+
// 2 side ay - 2 side cy = base ay + base cy
|
|
211
|
+
// (base + 2 side) cy = ay (2 side - base)
|
|
212
|
+
// cy = ay (2 side - base) / (2 side + base)
|
|
213
|
+
// cy = ay (2 side - 2 ax) / (2 side + 2 ax)
|
|
214
|
+
// cy = ay (side - ax) / (side + ax)
|
|
215
|
+
var cx = 0;
|
|
216
|
+
var cy = (sy * (side - ax)) / (side + ax);
|
|
217
|
+
// The distance from the incenter to every edge is the inradius.
|
|
218
|
+
// Since 0 <= (side - ax) / (side + ax) <= 1, the incenter remains
|
|
219
|
+
// between the apex and the base even when sy is negative.
|
|
220
|
+
var distance = Math.abs(sy - cy);
|
|
221
|
+
var fdistance = 1 / distance;
|
|
222
|
+
// Expand the triangle around its incenter for anti-aliasing and strokes.
|
|
223
|
+
// The outer vertices are shared where their interpolated attributes match.
|
|
224
|
+
var x0 = 0;
|
|
225
|
+
var y0 = cy + scale * (-sy - cy);
|
|
226
|
+
var x1 = scale * sx;
|
|
227
|
+
var y1 = cy + scale * (sy - cy);
|
|
228
|
+
var x2 = -x1;
|
|
229
|
+
var y2 = y1;
|
|
230
|
+
// Top-to-right edge cell. The inner vertex carries the fill attributes.
|
|
231
|
+
this.updateVertex(0, x0, y0, fdistance, 0, scale, fx, fy);
|
|
232
|
+
this.updateVertex(1, x1, y1, fdistance, side, scale, fx, fy);
|
|
233
|
+
this.updateVertex(2, cx, cy, fdistance, side - ax, 0, fx, fy);
|
|
234
|
+
var indices = this._indices;
|
|
235
|
+
indices[0] = 0;
|
|
236
|
+
indices[1] = 1;
|
|
237
|
+
indices[2] = 2;
|
|
238
|
+
// Right-to-left base edge cell. The right and left outer vertices are reused.
|
|
239
|
+
this.updateVertex(3, x2, y2, fdistance, side + base, scale, fx, fy);
|
|
240
|
+
this.updateVertex(4, cx, cy, fdistance, side + ax, 0, fx, fy);
|
|
241
|
+
indices[3] = 1;
|
|
242
|
+
indices[4] = 3;
|
|
243
|
+
indices[5] = 4;
|
|
244
|
+
// Left-to-top edge cell. The top vertex is duplicated for the perimeter seam.
|
|
245
|
+
this.updateVertex(5, x0, y0, fdistance, perimeter, scale, fx, fy);
|
|
246
|
+
this.updateVertex(6, cx, cy, fdistance, perimeter - (side - ax), 0, fx, fy);
|
|
247
|
+
indices[6] = 3;
|
|
248
|
+
indices[7] = 5;
|
|
249
|
+
indices[8] = 6;
|
|
250
|
+
};
|
|
251
|
+
EShapeTriangleTriangulatedImpl.prototype.updateVertex = function (vertex, x, y, distance, length, clipping, fx, fy) {
|
|
252
|
+
var vertex2 = vertex << 1;
|
|
253
|
+
this._vertices[vertex2] = x;
|
|
254
|
+
this._vertices[vertex2 + 1] = y;
|
|
255
|
+
this._distances[vertex] = distance;
|
|
256
|
+
this._lengths[vertex] = length;
|
|
257
|
+
this._clippings[vertex] = clipping;
|
|
258
|
+
this._uvs[vertex2] = 0.5 * (x * fx + 1);
|
|
259
|
+
this._uvs[vertex2 + 1] = 0.5 * (y * fy + 1);
|
|
260
|
+
};
|
|
261
|
+
return EShapeTriangleTriangulatedImpl;
|
|
262
|
+
}());
|
|
263
|
+
export { EShapeTriangleTriangulatedImpl };
|
|
264
|
+
//# sourceMappingURL=e-shape-triangle-triangulated-impl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"e-shape-triangle-triangulated-impl.js","sourceRoot":"","sources":["../../../../../src/main/typescript/wcardinal/ui/shape/variant/e-shape-triangle-triangulated-impl.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH;IAmBC,wCAAY,MAAsB;QACjC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC;QACb,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAChB,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;QACjB,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC;QACtB,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC;QACtB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAChB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAChB,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACpB,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;QACnB,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QACrB,IAAI,CAAC,IAAI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AC,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,CAAC,SAAS,CAAC,OAAO,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;QAChC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC;QACnC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;QAC/B,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC;QACnC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;QACxC,IAAI,CAAC,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IAC7C,CAAC;IACF,qCAAC;AAAD,CAAC,AA/QD,IA+QC","sourcesContent":["/*\n * Copyright (C) 2019-2026 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { EShapeBoundary } from \"../e-shape-boundary\";\nimport type { EShapeTriangle } from \"./e-shape-triangle\";\nimport { EShapeTriangleTriangulated } from \"./e-shape-triangle-triangulated\";\n\nexport class EShapeTriangleTriangulatedImpl implements EShapeTriangleTriangulated {\n\tprotected _id: number;\n\tprotected _parent: EShapeTriangle;\n\tprotected _width: number;\n\tprotected _height: number;\n\tprotected _strokeAlign: number;\n\tprotected _strokeWidth: number;\n\tprotected _sizeX: number;\n\tprotected _sizeY: number;\n\tprotected _vertices: number[];\n\tprotected _nvertices: number;\n\tprotected _distances: number[];\n\tprotected _lengths: number[];\n\tprotected _clippings: number[];\n\tprotected _uvs: number[];\n\tprotected _indices: number[];\n\tprotected _nindices: number;\n\tprotected _boundary: EShapeBoundary;\n\n\tconstructor(parent: EShapeTriangle) {\n\t\tthis._id = 0;\n\t\tthis._parent = parent;\n\t\tthis._width = 0;\n\t\tthis._height = 0;\n\t\tthis._strokeAlign = 0;\n\t\tthis._strokeWidth = 0;\n\t\tthis._sizeX = 0;\n\t\tthis._sizeY = 0;\n\t\tthis._vertices = [];\n\t\tthis._nvertices = 0;\n\t\tthis._distances = [];\n\t\tthis._lengths = [];\n\t\tthis._clippings = [];\n\t\tthis._uvs = [];\n\t\tthis._indices = [];\n\t\tthis._nindices = 0;\n\t\tthis._boundary = [0, 0, 0, 0];\n\t}\n\n\tget id(): number {\n\t\tthis.triangulate();\n\t\treturn this._id;\n\t}\n\n\tget vertices(): number[] {\n\t\tthis.triangulate();\n\t\treturn this._vertices;\n\t}\n\n\tget nvertices(): number {\n\t\tthis.triangulate();\n\t\treturn this._nvertices;\n\t}\n\n\tget distances(): number[] {\n\t\tthis.triangulate();\n\t\treturn this._distances;\n\t}\n\n\tget lengths(): number[] {\n\t\tthis.triangulate();\n\t\treturn this._lengths;\n\t}\n\n\tget clippings(): number[] {\n\t\tthis.triangulate();\n\t\treturn this._clippings;\n\t}\n\n\tget uvs(): number[] {\n\t\tthis.triangulate();\n\t\treturn this._uvs;\n\t}\n\n\tget indices(): number[] {\n\t\tthis.triangulate();\n\t\treturn this._indices;\n\t}\n\n\tget nindices(): number {\n\t\tthis.triangulate();\n\t\treturn this._nindices;\n\t}\n\n\tget boundary(): EShapeBoundary {\n\t\tthis.triangulate();\n\t\treturn this._boundary;\n\t}\n\n\tprotected triangulate(): void {\n\t\tconst isNotInitialized = this._id === 0;\n\n\t\tconst parent = this._parent;\n\t\tconst size = parent.size;\n\t\tconst width = size.x;\n\t\tconst height = size.y;\n\t\tconst isRectChanged = this._width !== width || this._height !== height;\n\n\t\tconst stroke = parent.stroke;\n\t\tconst strokeAlign = stroke.align;\n\t\tconst strokeWidth = stroke.enable ? stroke.width : 0;\n\t\tconst isStrokeChanged =\n\t\t\tthis._strokeAlign !== strokeAlign || this._strokeWidth !== strokeWidth;\n\n\t\tlet isSizeChanged = false;\n\t\tlet sizeX = this._sizeX;\n\t\tlet sizeY = this._sizeY;\n\t\tif (isRectChanged || isStrokeChanged) {\n\t\t\tthis._width = width;\n\t\t\tthis._height = height;\n\t\t\tthis._strokeAlign = strokeAlign;\n\t\t\tthis._strokeWidth = strokeWidth;\n\n\t\t\tconst s = strokeAlign * strokeWidth;\n\t\t\tsizeX = width * 0.5 + (0 <= width ? +s : -s);\n\t\t\tsizeY = height * 0.5 + (0 <= height ? +s : -s);\n\t\t\tisSizeChanged = this._sizeX !== sizeX || this._sizeY !== sizeY;\n\t\t}\n\n\t\tif (isNotInitialized || isSizeChanged || isStrokeChanged) {\n\t\t\tthis._sizeX = sizeX;\n\t\t\tthis._sizeY = sizeY;\n\t\t\tthis.update(sizeX, sizeY, 1.1);\n\t\t}\n\t}\n\n\tprotected update(sizeX: number, sizeY: number, scale: number): void {\n\t\t// Boundary\n\t\tconst ax = Math.abs(sizeX);\n\t\tconst ay = Math.abs(sizeY);\n\t\tconst boundary = this._boundary;\n\t\tboundary[0] = -ax;\n\t\tboundary[1] = -ay;\n\t\tboundary[2] = +ax;\n\t\tboundary[3] = +ay;\n\n\t\t// # of vertices and # of indices\n\t\tconst nv = 7;\n\t\tconst ni = 3;\n\t\tthis._nvertices = nv;\n\t\tthis._nindices = ni;\n\n\t\t// ID\n\t\tthis._id += 1;\n\n\t\t//\n\t\tif (sizeX === 0 || sizeY === 0) {\n\t\t\tthis.pad(0, 0, nv, ni, 0);\n\t\t} else {\n\t\t\tthis.updateAll(sizeX, sizeY, scale);\n\t\t}\n\t}\n\n\t/**\n\t * Fills the unused tail with degenerated triangles and trims the arrays\n\t * so that the buffers always hold exactly `nv` vertices and `ni` triangles.\n\t */\n\tprotected pad(iv: number, ii: number, nv: number, ni: number, fd: number): void {\n\t\tconst vertices = this._vertices;\n\t\tconst distances = this._distances;\n\t\tconst lengths = this._lengths;\n\t\tconst clippings = this._clippings;\n\t\tconst uvs = this._uvs;\n\t\tconst indices = this._indices;\n\n\t\tfor (let i = iv; i < nv; ++i) {\n\t\t\tconst i2 = i << 1;\n\t\t\tvertices[i2] = 0;\n\t\t\tvertices[i2 + 1] = 0;\n\t\t\tdistances[i] = fd;\n\t\t\tlengths[i] = 0;\n\t\t\tclippings[i] = 0;\n\t\t\tuvs[i2] = 0.5;\n\t\t\tuvs[i2 + 1] = 0.5;\n\t\t}\n\t\tfor (let i = ii, imax = ni * 3; i < imax; ++i) {\n\t\t\tindices[i] = 0;\n\t\t}\n\n\t\tconst nv2 = nv << 1;\n\t\tvertices.length = nv2;\n\t\tdistances.length = nv;\n\t\tlengths.length = nv;\n\t\tclippings.length = nv;\n\t\tuvs.length = nv2;\n\t\tindices.length = ni * 3;\n\t}\n\n\tprotected updateAll(sx: number, sy: number, scale: number): void {\n\t\tconst fx = 1 / sx;\n\t\tconst fy = 1 / sy;\n\t\tconst ax = Math.abs(sx);\n\t\tconst ay = Math.abs(sy);\n\t\t// The triangle is defined by the apex (0, -sy) and the two base\n\t\t// vertices (-sx, sy) and (sx, sy). The signs of sx and\n\t\t// sy intentionally preserve horizontal and vertical reflections.\n\t\t// The sloped edge spans ax horizontally and 2 * ay vertically.\n\t\tconst side = Math.sqrt(ax * ax + 4 * ay * ay);\n\t\t// The base is horizontal, so its length is twice the half-width.\n\t\tconst base = 2 * ax;\n\t\t// Length values are measured along the triangle perimeter.\n\t\tconst perimeter = 2 * side + base;\n\t\t// The incenter lies on the vertical center line. This is its y-coordinate.\n\t\t// Along the median, the distances from the top vertex to the incenter and\n\t\t// from the incenter to the base are in the ratio 2 * side : base.\n\t\t// Thus, (ay + cy) : (ay - cy) = 2 * side : base.\n\t\t// 2 side (ay - cy) = base * (ay + cy)\n\t\t// 2 side ay - 2 side cy = base ay + base cy\n\t\t// (base + 2 side) cy = ay (2 side - base)\n\t\t// cy = ay (2 side - base) / (2 side + base)\n\t\t// cy = ay (2 side - 2 ax) / (2 side + 2 ax)\n\t\t// cy = ay (side - ax) / (side + ax)\n\t\tconst cx = 0;\n\t\tconst cy = (sy * (side - ax)) / (side + ax);\n\t\t// The distance from the incenter to every edge is the inradius.\n\t\t// Since 0 <= (side - ax) / (side + ax) <= 1, the incenter remains\n\t\t// between the apex and the base even when sy is negative.\n\t\tconst distance = Math.abs(sy - cy);\n\t\tconst fdistance = 1 / distance;\n\t\t// Expand the triangle around its incenter for anti-aliasing and strokes.\n\t\t// The outer vertices are shared where their interpolated attributes match.\n\t\tconst x0 = 0;\n\t\tconst y0 = cy + scale * (-sy - cy);\n\t\tconst x1 = scale * sx;\n\t\tconst y1 = cy + scale * (sy - cy);\n\t\tconst x2 = -x1;\n\t\tconst y2 = y1;\n\n\t\t// Top-to-right edge cell. The inner vertex carries the fill attributes.\n\t\tthis.updateVertex(0, x0, y0, fdistance, 0, scale, fx, fy);\n\t\tthis.updateVertex(1, x1, y1, fdistance, side, scale, fx, fy);\n\t\tthis.updateVertex(2, cx, cy, fdistance, side - ax, 0, fx, fy);\n\t\tconst indices = this._indices;\n\t\tindices[0] = 0;\n\t\tindices[1] = 1;\n\t\tindices[2] = 2;\n\n\t\t// Right-to-left base edge cell. The right and left outer vertices are reused.\n\t\tthis.updateVertex(3, x2, y2, fdistance, side + base, scale, fx, fy);\n\t\tthis.updateVertex(4, cx, cy, fdistance, side + ax, 0, fx, fy);\n\t\tindices[3] = 1;\n\t\tindices[4] = 3;\n\t\tindices[5] = 4;\n\n\t\t// Left-to-top edge cell. The top vertex is duplicated for the perimeter seam.\n\t\tthis.updateVertex(5, x0, y0, fdistance, perimeter, scale, fx, fy);\n\t\tthis.updateVertex(6, cx, cy, fdistance, perimeter - (side - ax), 0, fx, fy);\n\t\tindices[6] = 3;\n\t\tindices[7] = 5;\n\t\tindices[8] = 6;\n\t}\n\n\tprotected updateVertex(\n\t\tvertex: number,\n\t\tx: number,\n\t\ty: number,\n\t\tdistance: number,\n\t\tlength: number,\n\t\tclipping: number,\n\t\tfx: number,\n\t\tfy: number\n\t): void {\n\t\tconst vertex2 = vertex << 1;\n\t\tthis._vertices[vertex2] = x;\n\t\tthis._vertices[vertex2 + 1] = y;\n\t\tthis._distances[vertex] = distance;\n\t\tthis._lengths[vertex] = length;\n\t\tthis._clippings[vertex] = clipping;\n\t\tthis._uvs[vertex2] = 0.5 * (x * fx + 1);\n\t\tthis._uvs[vertex2 + 1] = 0.5 * (y * fy + 1);\n\t}\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"e-shape-triangle-triangulated.js","sourceRoot":"","sources":["../../../../../src/main/typescript/wcardinal/ui/shape/variant/e-shape-triangle-triangulated.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*\n * Copyright (C) 2019-2026 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { EShapePolygonTriangulatedLike } from \"./e-shape-polygon-triangulated-like\";\n\nexport interface EShapeTriangleTriangulated extends EShapePolygonTriangulatedLike {}\n"]}
|
|
@@ -5,13 +5,26 @@
|
|
|
5
5
|
import { __extends } from "tslib";
|
|
6
6
|
import { EShapeType } from "../e-shape-type";
|
|
7
7
|
import { EShapePrimitive } from "./e-shape-primitive";
|
|
8
|
+
import { EShapeTriangleTriangulatedImpl } from "./e-shape-triangle-triangulated-impl";
|
|
8
9
|
import { hitTestTriangle } from "./hit-test-triangle";
|
|
9
10
|
var EShapeTriangle = /** @class */ (function (_super) {
|
|
10
11
|
__extends(EShapeTriangle, _super);
|
|
11
12
|
function EShapeTriangle(type) {
|
|
12
13
|
if (type === void 0) { type = EShapeType.TRIANGLE; }
|
|
13
|
-
|
|
14
|
+
var _this = _super.call(this, type) || this;
|
|
15
|
+
_this._triangulated = _this.newTriangulated();
|
|
16
|
+
return _this;
|
|
14
17
|
}
|
|
18
|
+
EShapeTriangle.prototype.newTriangulated = function () {
|
|
19
|
+
return new EShapeTriangleTriangulatedImpl(this);
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(EShapeTriangle.prototype, "triangulated", {
|
|
22
|
+
get: function () {
|
|
23
|
+
return this._triangulated;
|
|
24
|
+
},
|
|
25
|
+
enumerable: false,
|
|
26
|
+
configurable: true
|
|
27
|
+
});
|
|
15
28
|
EShapeTriangle.prototype.clone = function () {
|
|
16
29
|
return new EShapeTriangle(this.type).copy(this);
|
|
17
30
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"e-shape-triangle.js","sourceRoot":"","sources":["../../../../../src/main/typescript/wcardinal/ui/shape/variant/e-shape-triangle.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"e-shape-triangle.js","sourceRoot":"","sources":["../../../../../src/main/typescript/wcardinal/ui/shape/variant/e-shape-triangle.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,8BAA8B,EAAE,MAAM,sCAAsC,CAAC;AACtF,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD;IAAoC,kCAAe;IAGlD,wBAAY,IAAsC;QAAtC,qBAAA,EAAA,OAAmB,UAAU,CAAC,QAAQ;QACjD,YAAA,MAAK,YAAC,IAAI,CAAC,SAAC;QACZ,KAAI,CAAC,aAAa,GAAG,KAAI,CAAC,eAAe,EAAE,CAAC;;IAC7C,CAAC;IAES,wCAAe,GAAzB;QACC,OAAO,IAAI,8BAA8B,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC;IAED,sBAAI,wCAAY;aAAhB;YACC,OAAO,IAAI,CAAC,aAAa,CAAC;QAC3B,CAAC;;;OAAA;IAED,8BAAK,GAAL;QACC,OAAO,IAAI,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC;IAED,oCAAW,GAAX,UACC,CAAS,EACT,CAAS,EACT,EAAU,EACV,EAAU,EACV,EAAU,EACV,EAAU,EACV,EAAU;QAEV,IAAI,gBAAK,CAAC,eAAe,YAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC;YACzC,OAAO,eAAe,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;QACpD,CAAC;QACD,OAAO,KAAK,CAAC;IACd,CAAC;IACF,qBAAC;AAAD,CAAC,AAlCD,CAAoC,eAAe,GAkClD","sourcesContent":["/*\n * Copyright (C) 2019 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { EShapeType } from \"../e-shape-type\";\nimport { EShapePrimitive } from \"./e-shape-primitive\";\nimport { EShapeTriangleTriangulated } from \"./e-shape-triangle-triangulated\";\nimport { EShapeTriangleTriangulatedImpl } from \"./e-shape-triangle-triangulated-impl\";\nimport { hitTestTriangle } from \"./hit-test-triangle\";\n\nexport class EShapeTriangle extends EShapePrimitive {\n\tprotected readonly _triangulated: EShapeTriangleTriangulated;\n\n\tconstructor(type: EShapeType = EShapeType.TRIANGLE) {\n\t\tsuper(type);\n\t\tthis._triangulated = this.newTriangulated();\n\t}\n\n\tprotected newTriangulated(): EShapeTriangleTriangulated {\n\t\treturn new EShapeTriangleTriangulatedImpl(this);\n\t}\n\n\tget triangulated(): EShapeTriangleTriangulated {\n\t\treturn this._triangulated;\n\t}\n\n\tclone(): EShapeTriangle {\n\t\treturn new EShapeTriangle(this.type).copy(this);\n\t}\n\n\tcontainsAbs(\n\t\tx: number,\n\t\ty: number,\n\t\tax: number,\n\t\tay: number,\n\t\tsw: number,\n\t\tss: number,\n\t\tsa: number\n\t): boolean {\n\t\tif (super.containsAbsBBox(x, y, ax, ay)) {\n\t\t\treturn hitTestTriangle(this, x, y, ax, ay, sw, ss);\n\t\t}\n\t\treturn false;\n\t}\n}\n"]}
|
|
@@ -2,35 +2,69 @@
|
|
|
2
2
|
* Copyright (C) 2019 Toshiba Corporation
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
|
-
|
|
5
|
+
import { EShapeFillDirection } from "../e-shape-fill-direction";
|
|
6
|
+
export var hitTestCircleLegacy = function (shape, x, y, ax, ay, sw, ss) {
|
|
6
7
|
var fill = shape.fill;
|
|
7
8
|
if (fill.enable) {
|
|
9
|
+
return hitTestCircleFilled(x, y, ax, ay);
|
|
10
|
+
}
|
|
11
|
+
return hitTestCircleStroke(x, y, ax, ay, sw, ss);
|
|
12
|
+
};
|
|
13
|
+
var hitTestCircleFilled = function (x, y, ax, ay) {
|
|
14
|
+
var x2 = x * x;
|
|
15
|
+
var y2 = y * y;
|
|
16
|
+
var ax2 = ax * ax;
|
|
17
|
+
var ay2 = ay * ay;
|
|
18
|
+
return x2 * ay2 + y2 * ax2 <= ax2 * ay2;
|
|
19
|
+
};
|
|
20
|
+
var hitTestCircleStroke = function (x, y, ax, ay, sw, ss) {
|
|
21
|
+
if (0 < sw) {
|
|
22
|
+
var s = sw * ss;
|
|
8
23
|
var x2 = x * x;
|
|
9
24
|
var y2 = y * y;
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
25
|
+
var wx = Math.max(0.0, ax - s);
|
|
26
|
+
var wy = Math.max(0.0, ay - s);
|
|
27
|
+
var wx2 = wx * wx;
|
|
28
|
+
var wy2 = wy * wy;
|
|
29
|
+
if (wx2 * wy2 <= x2 * wy2 + y2 * wx2) {
|
|
30
|
+
return hitTestCircleFilled(x, y, ax, ay);
|
|
14
31
|
}
|
|
15
32
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
33
|
+
return false;
|
|
34
|
+
};
|
|
35
|
+
export var hitTestCircle = function (shape, x, y, ax, ay, sw, ss) {
|
|
36
|
+
if (!hitTestCircleFilled(x, y, ax, ay)) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
var fill = shape.fill;
|
|
40
|
+
if (fill.enable) {
|
|
41
|
+
var percent = Math.max(0, Math.min(1, fill.percent));
|
|
42
|
+
if (1 <= percent) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
switch (fill.direction) {
|
|
46
|
+
case EShapeFillDirection.TOP:
|
|
47
|
+
if (y + ay <= percent * (2 * ay)) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
break;
|
|
51
|
+
case EShapeFillDirection.RIGHT:
|
|
52
|
+
if ((1 - percent) * (2 * ax) <= x + ax) {
|
|
29
53
|
return true;
|
|
30
54
|
}
|
|
31
|
-
|
|
55
|
+
break;
|
|
56
|
+
case EShapeFillDirection.BOTTOM:
|
|
57
|
+
if ((1 - percent) * (2 * ay) <= y + ay) {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
break;
|
|
61
|
+
case EShapeFillDirection.LEFT:
|
|
62
|
+
if (x + ax <= percent * (2 * ax)) {
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
break;
|
|
32
66
|
}
|
|
33
67
|
}
|
|
34
|
-
return
|
|
68
|
+
return hitTestCircleStroke(x, y, ax, ay, sw, ss);
|
|
35
69
|
};
|
|
36
70
|
//# sourceMappingURL=hit-test-circle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hit-test-circle.js","sourceRoot":"","sources":["../../../../../src/main/typescript/wcardinal/ui/shape/variant/hit-test-circle.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"hit-test-circle.js","sourceRoot":"","sources":["../../../../../src/main/typescript/wcardinal/ui/shape/variant/hit-test-circle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAG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,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;oBACxC,OAAO,IAAI,CAAC;gBACb,CAAC;gBACD,MAAM;YACP,KAAK,mBAAmB,CAAC,MAAM;gBAC9B,IAAI,CAAC,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;oBACxC,OAAO,IAAI,CAAC;gBACb,CAAC;gBACD,MAAM;YACP,KAAK,mBAAmB,CAAC,IAAI;gBAC5B,IAAI,CAAC,GAAG,EAAE,IAAI,OAAO,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC;oBAClC,OAAO,IAAI,CAAC;gBACb,CAAC;gBACD,MAAM;QACR,CAAC;IACF,CAAC;IAED,OAAO,mBAAmB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;AAClD,CAAC,CAAC","sourcesContent":["/*\n * Copyright (C) 2019 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { EShape } from \"../e-shape\";\nimport { EShapeFillDirection } from \"../e-shape-fill-direction\";\n\nexport const hitTestCircleLegacy = (\n\tshape: EShape,\n\tx: number,\n\ty: number,\n\tax: number,\n\tay: number,\n\tsw: number,\n\tss: number\n): boolean => {\n\tconst fill = shape.fill;\n\tif (fill.enable) {\n\t\treturn hitTestCircleFilled(x, y, ax, ay);\n\t}\n\treturn hitTestCircleStroke(x, y, ax, ay, sw, ss);\n};\n\nconst hitTestCircleFilled = (x: number, y: number, ax: number, ay: number): boolean => {\n\tconst x2 = x * x;\n\tconst y2 = y * y;\n\tconst ax2 = ax * ax;\n\tconst ay2 = ay * ay;\n\treturn x2 * ay2 + y2 * ax2 <= ax2 * ay2;\n};\n\nconst hitTestCircleStroke = (\n\tx: number,\n\ty: number,\n\tax: number,\n\tay: number,\n\tsw: number,\n\tss: number\n): boolean => {\n\tif (0 < sw) {\n\t\tconst s = sw * ss;\n\t\tconst x2 = x * x;\n\t\tconst y2 = y * y;\n\t\tconst wx = Math.max(0.0, ax - s);\n\t\tconst wy = Math.max(0.0, ay - s);\n\t\tconst wx2 = wx * wx;\n\t\tconst wy2 = wy * wy;\n\t\tif (wx2 * wy2 <= x2 * wy2 + y2 * wx2) {\n\t\t\treturn hitTestCircleFilled(x, y, ax, ay);\n\t\t}\n\t}\n\treturn false;\n};\n\nexport const hitTestCircle = (\n\tshape: EShape,\n\tx: number,\n\ty: number,\n\tax: number,\n\tay: number,\n\tsw: number,\n\tss: number\n): boolean => {\n\tif (!hitTestCircleFilled(x, y, ax, ay)) {\n\t\treturn false;\n\t}\n\n\tconst fill = shape.fill;\n\tif (fill.enable) {\n\t\tconst percent = Math.max(0, Math.min(1, fill.percent));\n\t\tif (1 <= percent) {\n\t\t\treturn true;\n\t\t}\n\n\t\tswitch (fill.direction) {\n\t\t\tcase EShapeFillDirection.TOP:\n\t\t\t\tif (y + ay <= percent * (2 * ay)) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase EShapeFillDirection.RIGHT:\n\t\t\t\tif ((1 - percent) * (2 * ax) <= x + ax) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase EShapeFillDirection.BOTTOM:\n\t\t\t\tif ((1 - percent) * (2 * ay) <= y + ay) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase EShapeFillDirection.LEFT:\n\t\t\t\tif (x + ax <= percent * (2 * ax)) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn hitTestCircleStroke(x, y, ax, ay, sw, ss);\n};\n"]}
|
|
@@ -2,58 +2,63 @@
|
|
|
2
2
|
* Copyright (C) 2019 Toshiba Corporation
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
|
+
import { EShapeFillDirection } from "../e-shape-fill-direction";
|
|
5
6
|
import { EShapeStrokeSide } from "../e-shape-stroke-side";
|
|
6
7
|
import { hitTestBBox } from "./hit-test-bbox";
|
|
7
|
-
export var
|
|
8
|
+
export var hitTestRectangleLegacy = function (shape, x, y, ax, ay, sw, ss) {
|
|
8
9
|
if (hitTestBBox(x, y, ax, ay)) {
|
|
9
10
|
var fill = shape.fill;
|
|
10
11
|
if (fill.enable) {
|
|
11
12
|
return true;
|
|
12
13
|
}
|
|
13
14
|
else {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
return hitTestRectangleStroke(shape, x, y, ax, ay, sw, ss);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
};
|
|
20
|
+
var hitTestRectangleStroke = function (shape, x, y, ax, ay, sw, ss) {
|
|
21
|
+
var strokeSide = shape.stroke.side;
|
|
22
|
+
if (0 < sw && strokeSide !== EShapeStrokeSide.NONE) {
|
|
23
|
+
var s = sw * ss;
|
|
24
|
+
var wx = Math.max(0.0, ax - s);
|
|
25
|
+
var wy = Math.max(0.0, ay - s);
|
|
26
|
+
if (!hitTestBBox(x, y, wx, wy)) {
|
|
27
|
+
if (strokeSide === EShapeStrokeSide.ALL) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
if (x <= -wx) {
|
|
32
|
+
if (y <= -wy) {
|
|
33
|
+
return !!(strokeSide & EShapeStrokeSide.TOP_OR_LEFT);
|
|
34
|
+
}
|
|
35
|
+
else if (+wy <= y) {
|
|
36
|
+
return !!(strokeSide & EShapeStrokeSide.BOTTOM_OR_LEFT);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
return !!(strokeSide & EShapeStrokeSide.LEFT);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
else if (+wx <= x) {
|
|
43
|
+
if (y <= -wy) {
|
|
44
|
+
return !!(strokeSide & EShapeStrokeSide.TOP_OR_RIGHT);
|
|
45
|
+
}
|
|
46
|
+
else if (+wy <= y) {
|
|
47
|
+
return !!(strokeSide & EShapeStrokeSide.BOTTOM_OR_RIGHT);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
return !!(strokeSide & EShapeStrokeSide.RIGHT);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
if (y <= -wy) {
|
|
55
|
+
return !!(strokeSide & EShapeStrokeSide.TOP);
|
|
56
|
+
}
|
|
57
|
+
else if (+wy <= y) {
|
|
58
|
+
return !!(strokeSide & EShapeStrokeSide.BOTTOM);
|
|
22
59
|
}
|
|
23
60
|
else {
|
|
24
|
-
|
|
25
|
-
if (y <= -wy) {
|
|
26
|
-
return !!(strokeSide & EShapeStrokeSide.TOP_OR_LEFT);
|
|
27
|
-
}
|
|
28
|
-
else if (+wy <= y) {
|
|
29
|
-
return !!(strokeSide & EShapeStrokeSide.BOTTOM_OR_LEFT);
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
return !!(strokeSide & EShapeStrokeSide.LEFT);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
else if (+wx <= x) {
|
|
36
|
-
if (y <= -wy) {
|
|
37
|
-
return !!(strokeSide & EShapeStrokeSide.TOP_OR_RIGHT);
|
|
38
|
-
}
|
|
39
|
-
else if (+wy <= y) {
|
|
40
|
-
return !!(strokeSide & EShapeStrokeSide.BOTTOM_OR_RIGHT);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
return !!(strokeSide & EShapeStrokeSide.RIGHT);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
if (y <= -wy) {
|
|
48
|
-
return !!(strokeSide & EShapeStrokeSide.TOP);
|
|
49
|
-
}
|
|
50
|
-
else if (+wy <= y) {
|
|
51
|
-
return !!(strokeSide & EShapeStrokeSide.BOTTOM);
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
61
|
+
return false;
|
|
57
62
|
}
|
|
58
63
|
}
|
|
59
64
|
}
|
|
@@ -61,4 +66,39 @@ export var hitTestRectangle = function (shape, x, y, ax, ay, sw, ss) {
|
|
|
61
66
|
}
|
|
62
67
|
return false;
|
|
63
68
|
};
|
|
69
|
+
export var hitTestRectangle = function (shape, x, y, ax, ay, sw, ss) {
|
|
70
|
+
if (!hitTestBBox(x, y, ax, ay)) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
var fill = shape.fill;
|
|
74
|
+
if (fill.enable) {
|
|
75
|
+
var percent = Math.max(0, Math.min(1, fill.percent));
|
|
76
|
+
if (1 <= percent) {
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
switch (fill.direction) {
|
|
80
|
+
case EShapeFillDirection.TOP:
|
|
81
|
+
if (y + ay <= percent * (2 * ay)) {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
break;
|
|
85
|
+
case EShapeFillDirection.RIGHT:
|
|
86
|
+
if ((1 - percent) * (2 * ax) <= x + ax) {
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
break;
|
|
90
|
+
case EShapeFillDirection.BOTTOM:
|
|
91
|
+
if ((1 - percent) * (2 * ay) <= y + ay) {
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
break;
|
|
95
|
+
case EShapeFillDirection.LEFT:
|
|
96
|
+
if (x + ax <= percent * (2 * ax)) {
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return hitTestRectangleStroke(shape, x, y, ax, ay, sw, ss);
|
|
103
|
+
};
|
|
64
104
|
//# sourceMappingURL=hit-test-rectangle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hit-test-rectangle.js","sourceRoot":"","sources":["../../../../../src/main/typescript/wcardinal/ui/shape/variant/hit-test-rectangle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,MAAM,CAAC,IAAM,
|
|
1
|
+
{"version":3,"file":"hit-test-rectangle.js","sourceRoot":"","sources":["../../../../../src/main/typescript/wcardinal/ui/shape/variant/hit-test-rectangle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,MAAM,CAAC,IAAM,sBAAsB,GAAG,UACrC,KAAa,EACb,CAAS,EACT,CAAS,EACT,EAAU,EACV,EAAU,EACV,EAAU,EACV,EAAU;IAEV,IAAI,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC;QAC/B,IAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACxB,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,OAAO,IAAI,CAAC;QACb,CAAC;aAAM,CAAC;YACP,OAAO,sBAAsB,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;QAC5D,CAAC;IACF,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC,CAAC;AAEF,IAAM,sBAAsB,GAAG,UAC9B,KAAa,EACb,CAAS,EACT,CAAS,EACT,EAAU,EACV,EAAU,EACV,EAAU,EACV,EAAU;IAEV,IAAM,UAAU,GAAG,KAAK,CAAC,MA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G,EAAE,IAAI,OAAO,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC;oBAClC,OAAO,IAAI,CAAC;gBACb,CAAC;gBACD,MAAM;YACP,KAAK,mBAAmB,CAAC,KAAK;gBAC7B,IAAI,CAAC,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;oBACxC,OAAO,IAAI,CAAC;gBACb,CAAC;gBACD,MAAM;YACP,KAAK,mBAAmB,CAAC,MAAM;gBAC9B,IAAI,CAAC,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;oBACxC,OAAO,IAAI,CAAC;gBACb,CAAC;gBACD,MAAM;YACP,KAAK,mBAAmB,CAAC,IAAI;gBAC5B,IAAI,CAAC,GAAG,EAAE,IAAI,OAAO,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC;oBAClC,OAAO,IAAI,CAAC;gBACb,CAAC;gBACD,MAAM;QACR,CAAC;IACF,CAAC;IAED,OAAO,sBAAsB,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;AAC5D,CAAC,CAAC","sourcesContent":["/*\n * Copyright (C) 2019 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { EShape } from \"../e-shape\";\nimport { EShapeFillDirection } from \"../e-shape-fill-direction\";\nimport { EShapeStrokeSide } from \"../e-shape-stroke-side\";\nimport { hitTestBBox } from \"./hit-test-bbox\";\n\nexport const hitTestRectangleLegacy = (\n\tshape: EShape,\n\tx: number,\n\ty: number,\n\tax: number,\n\tay: number,\n\tsw: number,\n\tss: number\n): boolean => {\n\tif (hitTestBBox(x, y, ax, ay)) {\n\t\tconst fill = shape.fill;\n\t\tif (fill.enable) {\n\t\t\treturn true;\n\t\t} else {\n\t\t\treturn hitTestRectangleStroke(shape, x, y, ax, ay, sw, ss);\n\t\t}\n\t}\n\treturn false;\n};\n\nconst hitTestRectangleStroke = (\n\tshape: EShape,\n\tx: number,\n\ty: number,\n\tax: number,\n\tay: number,\n\tsw: number,\n\tss: number\n): boolean => {\n\tconst strokeSide = shape.stroke.side;\n\tif (0 < sw && strokeSide !== EShapeStrokeSide.NONE) {\n\t\tconst s = sw * ss;\n\t\tconst wx = Math.max(0.0, ax - s);\n\t\tconst wy = Math.max(0.0, ay - s);\n\t\tif (!hitTestBBox(x, y, wx, wy)) {\n\t\t\tif (strokeSide === EShapeStrokeSide.ALL) {\n\t\t\t\treturn true;\n\t\t\t} else {\n\t\t\t\tif (x <= -wx) {\n\t\t\t\t\tif (y <= -wy) {\n\t\t\t\t\t\treturn !!(strokeSide & EShapeStrokeSide.TOP_OR_LEFT);\n\t\t\t\t\t} else if (+wy <= y) {\n\t\t\t\t\t\treturn !!(strokeSide & EShapeStrokeSide.BOTTOM_OR_LEFT);\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn !!(strokeSide & EShapeStrokeSide.LEFT);\n\t\t\t\t\t}\n\t\t\t\t} else if (+wx <= x) {\n\t\t\t\t\tif (y <= -wy) {\n\t\t\t\t\t\treturn !!(strokeSide & EShapeStrokeSide.TOP_OR_RIGHT);\n\t\t\t\t\t} else if (+wy <= y) {\n\t\t\t\t\t\treturn !!(strokeSide & EShapeStrokeSide.BOTTOM_OR_RIGHT);\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn !!(strokeSide & EShapeStrokeSide.RIGHT);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (y <= -wy) {\n\t\t\t\t\t\treturn !!(strokeSide & EShapeStrokeSide.TOP);\n\t\t\t\t\t} else if (+wy <= y) {\n\t\t\t\t\t\treturn !!(strokeSide & EShapeStrokeSide.BOTTOM);\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn false;\n};\n\nexport const hitTestRectangle = (\n\tshape: EShape,\n\tx: number,\n\ty: number,\n\tax: number,\n\tay: number,\n\tsw: number,\n\tss: number\n): boolean => {\n\tif (!hitTestBBox(x, y, ax, ay)) {\n\t\treturn false;\n\t}\n\n\tconst fill = shape.fill;\n\tif (fill.enable) {\n\t\tconst percent = Math.max(0, Math.min(1, fill.percent));\n\t\tif (1 <= percent) {\n\t\t\treturn true;\n\t\t}\n\n\t\tswitch (fill.direction) {\n\t\t\tcase EShapeFillDirection.TOP:\n\t\t\t\tif (y + ay <= percent * (2 * ay)) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase EShapeFillDirection.RIGHT:\n\t\t\t\tif ((1 - percent) * (2 * ax) <= x + ax) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase EShapeFillDirection.BOTTOM:\n\t\t\t\tif ((1 - percent) * (2 * ay) <= y + ay) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase EShapeFillDirection.LEFT:\n\t\t\t\tif (x + ax <= percent * (2 * ax)) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn hitTestRectangleStroke(shape, x, y, ax, ay, sw, ss);\n};\n"]}
|