@wcardinal/wcardinal-ui 0.458.0-beta.0 → 0.458.0-beta.1
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/variant/build-polygon.d.ts +3 -4
- package/dist/types/wcardinal/ui/shape/variant/create-polygon.d.ts +1 -1
- package/dist/types/wcardinal/ui/shape/variant/e-shape-polygon-triangulated-impl.d.ts +6 -5
- package/dist/types/wcardinal/ui/shape/variant/e-shape-polygon-triangulated.d.ts +2 -1
- package/dist/types/wcardinal/ui/shape/variant/e-shape-polygon.d.ts +7 -31
- package/dist/types/wcardinal/ui/shape/variant/hit-test-polygon.d.ts +1 -1
- package/dist/types/wcardinal/ui/util/util-polygon.d.ts +1 -3
- package/dist/types/wcardinal/ui/util/util-straight-skeleton.d.ts +1 -1
- package/dist/wcardinal/ui/shape/variant/build-polygon.js +12 -14
- package/dist/wcardinal/ui/shape/variant/build-polygon.js.map +1 -1
- package/dist/wcardinal/ui/shape/variant/builder-polygon.js +8 -15
- package/dist/wcardinal/ui/shape/variant/builder-polygon.js.map +1 -1
- package/dist/wcardinal/ui/shape/variant/create-polygon.js +32 -42
- package/dist/wcardinal/ui/shape/variant/create-polygon.js.map +1 -1
- package/dist/wcardinal/ui/shape/variant/e-shape-line-points.js +2 -6
- package/dist/wcardinal/ui/shape/variant/e-shape-line-points.js.map +1 -1
- package/dist/wcardinal/ui/shape/variant/e-shape-polygon-triangulated-impl.js +66 -59
- package/dist/wcardinal/ui/shape/variant/e-shape-polygon-triangulated-impl.js.map +1 -1
- package/dist/wcardinal/ui/shape/variant/e-shape-polygon-triangulated.js.map +1 -1
- package/dist/wcardinal/ui/shape/variant/e-shape-polygon.js +22 -127
- package/dist/wcardinal/ui/shape/variant/e-shape-polygon.js.map +1 -1
- package/dist/wcardinal/ui/shape/variant/hit-test-polygon.js +21 -27
- package/dist/wcardinal/ui/shape/variant/hit-test-polygon.js.map +1 -1
- package/dist/wcardinal/ui/util/util-polygon.js +5 -9
- package/dist/wcardinal/ui/util/util-polygon.js.map +1 -1
- package/dist/wcardinal/ui/util/util-straight-skeleton-buffer.js +5 -7
- package/dist/wcardinal/ui/util/util-straight-skeleton-buffer.js.map +1 -1
- package/dist/wcardinal/ui/util/util-straight-skeleton.js +2 -4
- package/dist/wcardinal/ui/util/util-straight-skeleton.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 +174 -311
- package/dist/wcardinal-ui.js +174 -311
- package/dist/wcardinal-ui.min.js +2 -2
- package/dist/wcardinal-ui.min.js.map +1 -1
- package/package.json +1 -1
package/dist/wcardinal-ui.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Winter Cardinal UI v0.458.0-beta.
|
|
2
|
+
Winter Cardinal UI v0.458.0-beta.1
|
|
3
3
|
Copyright (C) 2019 Toshiba Corporation
|
|
4
4
|
SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
|
|
@@ -14375,12 +14375,8 @@ var EShapeLinePoints = /** @class */ (function () {
|
|
|
14375
14375
|
});
|
|
14376
14376
|
Object.defineProperty(EShapeLinePoints.prototype, "marker", {
|
|
14377
14377
|
get: function () {
|
|
14378
|
-
var
|
|
14379
|
-
|
|
14380
|
-
result = this.newMarker();
|
|
14381
|
-
this._marker = result;
|
|
14382
|
-
}
|
|
14383
|
-
return result;
|
|
14378
|
+
var _a;
|
|
14379
|
+
return ((_a = this._marker) !== null && _a !== void 0 ? _a : (this._marker = this.newMarker()));
|
|
14384
14380
|
},
|
|
14385
14381
|
enumerable: false,
|
|
14386
14382
|
configurable: true
|
|
@@ -48449,7 +48445,7 @@ var buildPolygonIndex = function (indices, polygonIndices, voffset, ioffset) {
|
|
|
48449
48445
|
* Build vertex buffer for polygons.
|
|
48450
48446
|
* Transforms vertices from relative coordinates [-0.5, +0.5] to world coordinates.
|
|
48451
48447
|
*/
|
|
48452
|
-
var buildPolygonVertex = function (vertices, polygonVertices, voffset,
|
|
48448
|
+
var buildPolygonVertex = function (vertices, polygonVertices, voffset, internalTransform) {
|
|
48453
48449
|
var a = internalTransform.a;
|
|
48454
48450
|
var b = internalTransform.b;
|
|
48455
48451
|
var c = internalTransform.c;
|
|
@@ -48458,8 +48454,8 @@ var buildPolygonVertex = function (vertices, polygonVertices, voffset, sizeX, si
|
|
|
48458
48454
|
var ty = internalTransform.ty;
|
|
48459
48455
|
var iv = (voffset << 1) - 1;
|
|
48460
48456
|
for (var i = 0, n = polygonVertices.length; i < n; i += 2) {
|
|
48461
|
-
var x =
|
|
48462
|
-
var y =
|
|
48457
|
+
var x = polygonVertices[i];
|
|
48458
|
+
var y = polygonVertices[i + 1];
|
|
48463
48459
|
vertices[++iv] = a * x + c * y + tx;
|
|
48464
48460
|
vertices[++iv] = b * x + d * y + ty;
|
|
48465
48461
|
}
|
|
@@ -48468,28 +48464,26 @@ var buildPolygonVertex = function (vertices, polygonVertices, voffset, sizeX, si
|
|
|
48468
48464
|
* Build step buffer for polygons.
|
|
48469
48465
|
* Since this is fill-only, step information is minimal.
|
|
48470
48466
|
*/
|
|
48471
|
-
var buildPolygonStep = function (steps, polygonDistances, polygonClippings, voffset, vertexCount,
|
|
48467
|
+
var buildPolygonStep = function (steps, polygonDistances, polygonClippings, voffset, vertexCount, strokeWidth, strokeSide, strokeStyle) {
|
|
48472
48468
|
var scaleInvariant = toScaleInvariant(strokeStyle);
|
|
48473
48469
|
var w = (strokeSide & EShapeStrokeSide.ALL) === EShapeStrokeSide.ALL ? 1 : 0;
|
|
48474
48470
|
var e = toPackedI4x64(0, scaleInvariant, w, w);
|
|
48475
48471
|
var is = voffset * 6 - 1;
|
|
48476
|
-
for (var i = 0
|
|
48477
|
-
var
|
|
48478
|
-
var dy = sizeY * polygonDistances[j + 1];
|
|
48472
|
+
for (var i = 0; i < vertexCount; i += 1) {
|
|
48473
|
+
var d = polygonDistances[i];
|
|
48479
48474
|
var c = polygonClippings[i];
|
|
48480
48475
|
steps[++is] = strokeWidth;
|
|
48481
48476
|
steps[++is] = e;
|
|
48482
|
-
steps[++is] =
|
|
48483
|
-
steps[++is] =
|
|
48477
|
+
steps[++is] = d;
|
|
48478
|
+
steps[++is] = d;
|
|
48484
48479
|
steps[++is] = toPackedF2x1024(c, c);
|
|
48485
48480
|
steps[++is] = 0;
|
|
48486
48481
|
}
|
|
48487
48482
|
};
|
|
48488
48483
|
/**
|
|
48489
48484
|
* Build UV buffer for polygons.
|
|
48490
|
-
* Transforms vertices from relative coordinates [-0.5, +0.5] to UV coordinates.
|
|
48491
48485
|
*/
|
|
48492
|
-
var buildPolygonUv = function (uvs,
|
|
48486
|
+
var buildPolygonUv = function (uvs, polygonUvs, voffset, textureUvs) {
|
|
48493
48487
|
var x0 = textureUvs.x0;
|
|
48494
48488
|
var x1 = textureUvs.x1;
|
|
48495
48489
|
var y0 = textureUvs.y0;
|
|
@@ -48497,9 +48491,9 @@ var buildPolygonUv = function (uvs, polygonVertices, voffset, textureUvs) {
|
|
|
48497
48491
|
var dx = x1 - x0;
|
|
48498
48492
|
var dy = y3 - y0;
|
|
48499
48493
|
var iuv = (voffset << 1) - 1;
|
|
48500
|
-
for (var i = 0, n =
|
|
48501
|
-
uvs[++iuv] = x0 +
|
|
48502
|
-
uvs[++iuv] = y0 +
|
|
48494
|
+
for (var i = 0, n = polygonUvs.length; i < n; i += 2) {
|
|
48495
|
+
uvs[++iuv] = x0 + polygonUvs[i] * dx;
|
|
48496
|
+
uvs[++iuv] = y0 + polygonUvs[i + 1] * dy;
|
|
48503
48497
|
}
|
|
48504
48498
|
};
|
|
48505
48499
|
|
|
@@ -48897,14 +48891,10 @@ var UtilPolygon = /** @class */ (function () {
|
|
|
48897
48891
|
* Creates an UtilPolygon instance.
|
|
48898
48892
|
*
|
|
48899
48893
|
* @param points points
|
|
48900
|
-
* @param sx the scale along X axis
|
|
48901
|
-
* @param sy the scale along Y axis
|
|
48902
48894
|
* @param epsilon threshold
|
|
48903
48895
|
* @returns a created UtilPolygon instance
|
|
48904
48896
|
*/
|
|
48905
|
-
UtilPolygon.from = function (points,
|
|
48906
|
-
if (sx === void 0) { sx = 1; }
|
|
48907
|
-
if (sy === void 0) { sy = 1; }
|
|
48897
|
+
UtilPolygon.from = function (points, epsilon) {
|
|
48908
48898
|
if (epsilon === void 0) { epsilon = 1e-5; }
|
|
48909
48899
|
var pointsLength = points.length;
|
|
48910
48900
|
if (pointsLength <= 0) {
|
|
@@ -48913,11 +48903,11 @@ var UtilPolygon = /** @class */ (function () {
|
|
|
48913
48903
|
var tmp = new UtilPolygon(epsilon);
|
|
48914
48904
|
var p = tmp.points;
|
|
48915
48905
|
var n = tmp.normals;
|
|
48916
|
-
var npx =
|
|
48917
|
-
var npy =
|
|
48906
|
+
var npx = points[0];
|
|
48907
|
+
var npy = points[1];
|
|
48918
48908
|
for (var i = pointsLength - 2; 0 <= i; i -= 2) {
|
|
48919
|
-
var px =
|
|
48920
|
-
var py =
|
|
48909
|
+
var px = points[i];
|
|
48910
|
+
var py = points[i + 1];
|
|
48921
48911
|
var dx = npx - px;
|
|
48922
48912
|
var dy = npy - py;
|
|
48923
48913
|
if (Math.abs(dx) <= epsilon && Math.abs(dy) < epsilon) {
|
|
@@ -49520,13 +49510,11 @@ var UtilStraightSkeletonWavefront = /** @class */ (function () {
|
|
|
49520
49510
|
var UtilStraightSkeleton = /** @class */ (function () {
|
|
49521
49511
|
function UtilStraightSkeleton() {
|
|
49522
49512
|
}
|
|
49523
|
-
UtilStraightSkeleton.from = function (points,
|
|
49524
|
-
if (sx === void 0) { sx = 1; }
|
|
49525
|
-
if (sy === void 0) { sy = 1; }
|
|
49513
|
+
UtilStraightSkeleton.from = function (points, level, epsilon) {
|
|
49526
49514
|
if (level === void 0) { level = -1; }
|
|
49527
49515
|
if (epsilon === void 0) { epsilon = 1e-5; }
|
|
49528
49516
|
var result = [];
|
|
49529
|
-
var polygons = UtilPolygon.from(points,
|
|
49517
|
+
var polygons = UtilPolygon.from(points, epsilon);
|
|
49530
49518
|
for (var i = 0, imax = polygons.length; i < imax; ++i) {
|
|
49531
49519
|
var wavefront = UtilStraightSkeletonWavefront.from(polygons[i], epsilon);
|
|
49532
49520
|
if (level < 0 || 0 < level) {
|
|
@@ -49596,7 +49584,7 @@ var UtilStraightSkeletonBufferBuilder = /** @class */ (function () {
|
|
|
49596
49584
|
var points = wavefront.points;
|
|
49597
49585
|
vertices.push(points[index], points[index + 1]);
|
|
49598
49586
|
var distance = wavefront.distance;
|
|
49599
|
-
this._distances.push(distance
|
|
49587
|
+
this._distances.push(distance);
|
|
49600
49588
|
return result;
|
|
49601
49589
|
}
|
|
49602
49590
|
else {
|
|
@@ -49610,7 +49598,7 @@ var UtilStraightSkeletonBufferBuilder = /** @class */ (function () {
|
|
|
49610
49598
|
var points = wavefront.points;
|
|
49611
49599
|
vertices.push(points[index], points[index + 1]);
|
|
49612
49600
|
var distance = wavefront.distance;
|
|
49613
|
-
this._distances.push(distance
|
|
49601
|
+
this._distances.push(distance);
|
|
49614
49602
|
return result;
|
|
49615
49603
|
}
|
|
49616
49604
|
};
|
|
@@ -49634,23 +49622,21 @@ var UtilStraightSkeletonBufferBuilder = /** @class */ (function () {
|
|
|
49634
49622
|
return;
|
|
49635
49623
|
}
|
|
49636
49624
|
var mdistance = distances[oldDistancesLength];
|
|
49637
|
-
for (var i = oldDistancesLength + 1; i < newDistancesLength; i
|
|
49625
|
+
for (var i = oldDistancesLength + 1; i < newDistancesLength; ++i) {
|
|
49638
49626
|
mdistance = Math.max(mdistance, distances[i]);
|
|
49639
49627
|
}
|
|
49640
49628
|
var clippings = this._clippings;
|
|
49641
49629
|
if (0 < mdistance) {
|
|
49642
49630
|
var fdistance = 1 / mdistance;
|
|
49643
|
-
for (var i = oldDistancesLength; i < newDistancesLength; i
|
|
49631
|
+
for (var i = oldDistancesLength; i < newDistancesLength; ++i) {
|
|
49644
49632
|
clippings.push(1 - distances[i] * fdistance);
|
|
49645
49633
|
distances[i] = mdistance;
|
|
49646
|
-
distances[i + 1] = mdistance;
|
|
49647
49634
|
}
|
|
49648
49635
|
}
|
|
49649
49636
|
else {
|
|
49650
|
-
for (var i = oldDistancesLength; i < newDistancesLength; i
|
|
49637
|
+
for (var i = oldDistancesLength; i < newDistancesLength; ++i) {
|
|
49651
49638
|
clippings.push(1);
|
|
49652
49639
|
distances[i] = mdistance;
|
|
49653
|
-
distances[i + 1] = mdistance;
|
|
49654
49640
|
}
|
|
49655
49641
|
}
|
|
49656
49642
|
};
|
|
@@ -49783,13 +49769,12 @@ var EShapePolygonTriangulatedImpl = /** @class */ (function () {
|
|
|
49783
49769
|
function EShapePolygonTriangulatedImpl(parent) {
|
|
49784
49770
|
this._id = 0;
|
|
49785
49771
|
this._parent = parent;
|
|
49786
|
-
this.
|
|
49787
|
-
this._parentWidth = -1;
|
|
49788
|
-
this._parentHeight = -1;
|
|
49772
|
+
this._parentPointsId = -1;
|
|
49789
49773
|
this._vertices = [];
|
|
49790
49774
|
this._nvertices = 0;
|
|
49791
49775
|
this._distances = [];
|
|
49792
49776
|
this._clippings = [];
|
|
49777
|
+
this._uvs = [];
|
|
49793
49778
|
this._indices = [];
|
|
49794
49779
|
this._nindices = 0;
|
|
49795
49780
|
}
|
|
@@ -49833,6 +49818,14 @@ var EShapePolygonTriangulatedImpl = /** @class */ (function () {
|
|
|
49833
49818
|
enumerable: false,
|
|
49834
49819
|
configurable: true
|
|
49835
49820
|
});
|
|
49821
|
+
Object.defineProperty(EShapePolygonTriangulatedImpl.prototype, "uvs", {
|
|
49822
|
+
get: function () {
|
|
49823
|
+
this.triangulate();
|
|
49824
|
+
return this._uvs;
|
|
49825
|
+
},
|
|
49826
|
+
enumerable: false,
|
|
49827
|
+
configurable: true
|
|
49828
|
+
});
|
|
49836
49829
|
Object.defineProperty(EShapePolygonTriangulatedImpl.prototype, "indices", {
|
|
49837
49830
|
get: function () {
|
|
49838
49831
|
this.triangulate();
|
|
@@ -49849,20 +49842,11 @@ var EShapePolygonTriangulatedImpl = /** @class */ (function () {
|
|
|
49849
49842
|
enumerable: false,
|
|
49850
49843
|
configurable: true
|
|
49851
49844
|
});
|
|
49852
|
-
EShapePolygonTriangulatedImpl.prototype.set = function (
|
|
49845
|
+
EShapePolygonTriangulatedImpl.prototype.set = function (parentPointsId, vertices, distances, clippings, uvs, indices) {
|
|
49853
49846
|
var isChanged = false;
|
|
49854
49847
|
// Parent Vertex ID
|
|
49855
|
-
if (
|
|
49856
|
-
this.
|
|
49857
|
-
isChanged = true;
|
|
49858
|
-
}
|
|
49859
|
-
// Parent Size
|
|
49860
|
-
if (parentWidth != null) {
|
|
49861
|
-
this._parentWidth = parentWidth;
|
|
49862
|
-
isChanged = true;
|
|
49863
|
-
}
|
|
49864
|
-
if (parentHeight != null) {
|
|
49865
|
-
this._parentHeight = parentHeight;
|
|
49848
|
+
if (parentPointsId != null) {
|
|
49849
|
+
this._parentPointsId = parentPointsId;
|
|
49866
49850
|
isChanged = true;
|
|
49867
49851
|
}
|
|
49868
49852
|
// Vertices
|
|
@@ -49899,6 +49883,17 @@ var EShapePolygonTriangulatedImpl = /** @class */ (function () {
|
|
|
49899
49883
|
}
|
|
49900
49884
|
isChanged = true;
|
|
49901
49885
|
}
|
|
49886
|
+
// UVs
|
|
49887
|
+
if (uvs != null) {
|
|
49888
|
+
var uvsLength = uvs.length;
|
|
49889
|
+
for (var i = 0; i < uvsLength; ++i) {
|
|
49890
|
+
this._uvs[i] = uvs[i];
|
|
49891
|
+
}
|
|
49892
|
+
if (this._uvs.length !== uvsLength) {
|
|
49893
|
+
this._uvs.length = uvsLength;
|
|
49894
|
+
}
|
|
49895
|
+
isChanged = true;
|
|
49896
|
+
}
|
|
49902
49897
|
// Indices
|
|
49903
49898
|
if (indices != null) {
|
|
49904
49899
|
var indicesLength = indices.length;
|
|
@@ -49919,45 +49914,37 @@ var EShapePolygonTriangulatedImpl = /** @class */ (function () {
|
|
|
49919
49914
|
};
|
|
49920
49915
|
EShapePolygonTriangulatedImpl.prototype.triangulate = function () {
|
|
49921
49916
|
var parent = this._parent;
|
|
49922
|
-
var
|
|
49923
|
-
var
|
|
49924
|
-
var
|
|
49925
|
-
|
|
49926
|
-
|
|
49927
|
-
|
|
49928
|
-
|
|
49929
|
-
|
|
49930
|
-
|
|
49931
|
-
this.
|
|
49932
|
-
this.
|
|
49933
|
-
this.
|
|
49934
|
-
|
|
49935
|
-
|
|
49936
|
-
var vertices = buffer.vertices;
|
|
49937
|
-
var verticesLength = vertices.length;
|
|
49938
|
-
var distances = buffer.distances;
|
|
49939
|
-
var fx = 1 / parentWidth;
|
|
49940
|
-
var fy = 1 / parentHeight;
|
|
49941
|
-
for (var i = 0; i < verticesLength; i += 2) {
|
|
49942
|
-
vertices[i] *= fx;
|
|
49943
|
-
vertices[i + 1] *= fy;
|
|
49944
|
-
distances[i] *= fx;
|
|
49945
|
-
distances[i + 1] *= fy;
|
|
49946
|
-
}
|
|
49947
|
-
this._id += 1;
|
|
49948
|
-
this._vertices = vertices;
|
|
49949
|
-
this._nvertices = vertices.length >> 1;
|
|
49950
|
-
this._distances = distances;
|
|
49951
|
-
this._clippings = buffer.clippings;
|
|
49952
|
-
this._indices = buffer.indices;
|
|
49953
|
-
this._nindices = buffer.indices.length / 3;
|
|
49954
|
-
}
|
|
49917
|
+
var parentPoints = parent.points;
|
|
49918
|
+
var parentPointsId = parentPoints.id;
|
|
49919
|
+
var isParentIdChanged = this._parentPointsId !== parentPointsId;
|
|
49920
|
+
if (isParentIdChanged) {
|
|
49921
|
+
this._parentPointsId = parentPointsId;
|
|
49922
|
+
var buffer = UtilStraightSkeletonBuffer.from(UtilStraightSkeleton.from(parentPoints.values));
|
|
49923
|
+
this._id += 1;
|
|
49924
|
+
this._vertices = buffer.vertices;
|
|
49925
|
+
this._nvertices = buffer.vertices.length >> 1;
|
|
49926
|
+
this._distances = buffer.distances;
|
|
49927
|
+
this._clippings = buffer.clippings;
|
|
49928
|
+
this._uvs = this.toUvs(buffer.vertices);
|
|
49929
|
+
this._indices = buffer.indices;
|
|
49930
|
+
this._nindices = buffer.indices.length / 3;
|
|
49955
49931
|
}
|
|
49956
49932
|
};
|
|
49933
|
+
EShapePolygonTriangulatedImpl.prototype.toUvs = function (vertices) {
|
|
49934
|
+
var result = [];
|
|
49935
|
+
var size = this._parent.size;
|
|
49936
|
+
var ax = Math.abs(size.x);
|
|
49937
|
+
var ay = Math.abs(size.y);
|
|
49938
|
+
var fx = 0 < ax ? 1 / ax : 0;
|
|
49939
|
+
var fy = 0 < ay ? 1 / ay : 0;
|
|
49940
|
+
var verticesLength = vertices.length;
|
|
49941
|
+
for (var i = 0; i < verticesLength; i += 2) {
|
|
49942
|
+
result.push(0.5 + vertices[i] * fx, 0.5 + vertices[i + 1] * fy);
|
|
49943
|
+
}
|
|
49944
|
+
return result;
|
|
49945
|
+
};
|
|
49957
49946
|
EShapePolygonTriangulatedImpl.prototype.copy = function (source) {
|
|
49958
|
-
|
|
49959
|
-
var parentSize = parent.size;
|
|
49960
|
-
this.set(parent.vertexId, parentSize.x, parentSize.y, source.vertices, source.distances, source.clippings, source.indices);
|
|
49947
|
+
this.set(this._parent.points.id, source.vertices, source.distances, source.clippings, source.uvs, source.indices);
|
|
49961
49948
|
return this;
|
|
49962
49949
|
};
|
|
49963
49950
|
EShapePolygonTriangulatedImpl.prototype.serialize = function (manager) {
|
|
@@ -49966,6 +49953,7 @@ var EShapePolygonTriangulatedImpl = /** @class */ (function () {
|
|
|
49966
49953
|
manager.addResource(JSON.stringify(this._vertices)),
|
|
49967
49954
|
manager.addResource(JSON.stringify(this._distances)),
|
|
49968
49955
|
manager.addResource(JSON.stringify(this._clippings)),
|
|
49956
|
+
manager.addResource(JSON.stringify(this._uvs)),
|
|
49969
49957
|
manager.addResource(JSON.stringify(this._indices))
|
|
49970
49958
|
];
|
|
49971
49959
|
return manager.addResource(JSON.stringify(serialized));
|
|
@@ -49979,13 +49967,8 @@ var EShapePolygonTriangulatedImpl = /** @class */ (function () {
|
|
|
49979
49967
|
parsed = JSON.parse(resources[resourceId]);
|
|
49980
49968
|
manager.setExtension(resourceId, parsed);
|
|
49981
49969
|
}
|
|
49982
|
-
// Parent
|
|
49983
|
-
|
|
49984
|
-
this._parentVertexId = parent_1.vertexId;
|
|
49985
|
-
// Parent Size
|
|
49986
|
-
var parentSize = parent_1.size;
|
|
49987
|
-
this._parentWidth = parentSize.x;
|
|
49988
|
-
this._parentHeight = parentSize.y;
|
|
49970
|
+
// Parent Points Id
|
|
49971
|
+
this._parentPointsId = this._parent.points.id;
|
|
49989
49972
|
// Vertices
|
|
49990
49973
|
var vertexId = parsed[0];
|
|
49991
49974
|
if (0 <= vertexId && vertexId < resourcesLength) {
|
|
@@ -50017,8 +50000,18 @@ var EShapePolygonTriangulatedImpl = /** @class */ (function () {
|
|
|
50017
50000
|
}
|
|
50018
50001
|
this._clippings = clippings;
|
|
50019
50002
|
}
|
|
50003
|
+
// UVs
|
|
50004
|
+
var uvId = parsed[3];
|
|
50005
|
+
if (0 <= uvId && uvId < resourcesLength) {
|
|
50006
|
+
var uvs = manager.getExtension(uvId);
|
|
50007
|
+
if (uvs == null) {
|
|
50008
|
+
uvs = JSON.parse(resources[uvId]);
|
|
50009
|
+
manager.setExtension(uvId, uvs);
|
|
50010
|
+
}
|
|
50011
|
+
this._uvs = uvs;
|
|
50012
|
+
}
|
|
50020
50013
|
// Indices
|
|
50021
|
-
var indexId = parsed[
|
|
50014
|
+
var indexId = parsed[4];
|
|
50022
50015
|
if (0 <= indexId && indexId < resourcesLength) {
|
|
50023
50016
|
var indices = manager.getExtension(indexId);
|
|
50024
50017
|
if (indices == null) {
|
|
@@ -50048,20 +50041,16 @@ var EShapePolygonTriangulatedImpl = /** @class */ (function () {
|
|
|
50048
50041
|
* @param ay a polygon height
|
|
50049
50042
|
* @returns the minimum squared distance between the given point (x, y) and the polygon edges
|
|
50050
50043
|
*/
|
|
50051
|
-
var calcPolygonSquaredDistance = function (
|
|
50052
|
-
|
|
50053
|
-
var verticesLength = vertices.length;
|
|
50054
|
-
if (verticesLength < 4) {
|
|
50044
|
+
var calcPolygonSquaredDistance = function (values, valuesLength, x, y) {
|
|
50045
|
+
if (valuesLength < 4) {
|
|
50055
50046
|
return Infinity;
|
|
50056
50047
|
}
|
|
50057
50048
|
var result = Infinity;
|
|
50058
|
-
var
|
|
50059
|
-
var
|
|
50060
|
-
var
|
|
50061
|
-
|
|
50062
|
-
|
|
50063
|
-
var vx = vertices[i] * sx;
|
|
50064
|
-
var vy = vertices[i + 1] * sy;
|
|
50049
|
+
var pvx = values[valuesLength - 2];
|
|
50050
|
+
var pvy = values[valuesLength - 1];
|
|
50051
|
+
for (var i = 0; i < valuesLength; i += 2) {
|
|
50052
|
+
var vx = values[i];
|
|
50053
|
+
var vy = values[i + 1];
|
|
50065
50054
|
var dvx = vx - pvx;
|
|
50066
50055
|
var dvy = vy - pvy;
|
|
50067
50056
|
var dv = dvx * dvx + dvy * dvy;
|
|
@@ -50091,31 +50080,29 @@ var hitTestPolygon = function (shape, x, y, ax, ay, sw, ss) {
|
|
|
50091
50080
|
if (!filled && sw <= 0) {
|
|
50092
50081
|
return false;
|
|
50093
50082
|
}
|
|
50094
|
-
var
|
|
50095
|
-
var
|
|
50096
|
-
if (6 <=
|
|
50083
|
+
var values = shape.points.values;
|
|
50084
|
+
var valuesLength = values.length;
|
|
50085
|
+
if (6 <= valuesLength) {
|
|
50097
50086
|
if (0 < ax && 0 < ay) {
|
|
50098
50087
|
var count = 0;
|
|
50099
|
-
var
|
|
50100
|
-
var
|
|
50101
|
-
var
|
|
50102
|
-
var
|
|
50103
|
-
|
|
50104
|
-
|
|
50105
|
-
|
|
50106
|
-
var vy = vertices[i + 1];
|
|
50107
|
-
if ((pvy <= ny && ny < vy) || (ny <= pvy && vy < ny)) {
|
|
50088
|
+
var ppvy = values[valuesLength - 3];
|
|
50089
|
+
var pvx = values[valuesLength - 2];
|
|
50090
|
+
var pvy = values[valuesLength - 1];
|
|
50091
|
+
for (var i = 0; i < valuesLength; i += 2) {
|
|
50092
|
+
var vx = values[i];
|
|
50093
|
+
var vy = values[i + 1];
|
|
50094
|
+
if ((pvy <= y && y < vy) || (y <= pvy && vy < y)) {
|
|
50108
50095
|
var dy = vy - pvy;
|
|
50109
50096
|
var t = 0;
|
|
50110
50097
|
if (0 < Math.abs(dy)) {
|
|
50111
|
-
t = (
|
|
50098
|
+
t = (y - pvy) / dy;
|
|
50112
50099
|
}
|
|
50113
50100
|
var cx = pvx + t * (vx - pvx);
|
|
50114
|
-
if (
|
|
50101
|
+
if (x <= cx) {
|
|
50115
50102
|
if (t <= 0) {
|
|
50116
50103
|
// Since we could be just grazing vertices,
|
|
50117
50104
|
// we need to check if the second-previous vertex is on the opposite side.
|
|
50118
|
-
if ((ppvy <=
|
|
50105
|
+
if ((ppvy <= y && y < vy) || (y <= ppvy && vy < y)) {
|
|
50119
50106
|
count += 1;
|
|
50120
50107
|
}
|
|
50121
50108
|
}
|
|
@@ -50133,7 +50120,7 @@ var hitTestPolygon = function (shape, x, y, ax, ay, sw, ss) {
|
|
|
50133
50120
|
return true;
|
|
50134
50121
|
}
|
|
50135
50122
|
else {
|
|
50136
|
-
return calcPolygonSquaredDistance(
|
|
50123
|
+
return calcPolygonSquaredDistance(values, valuesLength, x, y) <= sw * sw;
|
|
50137
50124
|
}
|
|
50138
50125
|
}
|
|
50139
50126
|
}
|
|
@@ -50147,66 +50134,29 @@ var hitTestPolygon = function (shape, x, y, ax, ay, sw, ss) {
|
|
|
50147
50134
|
*/
|
|
50148
50135
|
var EShapePolygon = /** @class */ (function (_super) {
|
|
50149
50136
|
__extends(EShapePolygon, _super);
|
|
50150
|
-
/**
|
|
50151
|
-
* Please note that the given arrays `vertices`, `distances`, `clippings` and `indices` are used internally.
|
|
50152
|
-
* Because of this, these arrays must not be modified outside of this class after calling this constructor.
|
|
50153
|
-
*/
|
|
50154
50137
|
function EShapePolygon(type) {
|
|
50155
50138
|
if (type === void 0) { type = EShapeType.POLYGON; }
|
|
50156
50139
|
var _this = _super.call(this, type) || this;
|
|
50157
|
-
_this.
|
|
50158
|
-
_this._nvertices = 0;
|
|
50159
|
-
_this._vertexId = 0;
|
|
50140
|
+
_this._points = _this.newPoints();
|
|
50160
50141
|
_this._triangulated = _this.newTriangulated();
|
|
50161
50142
|
return _this;
|
|
50162
50143
|
}
|
|
50144
|
+
Object.defineProperty(EShapePolygon.prototype, "points", {
|
|
50145
|
+
get: function () {
|
|
50146
|
+
return this._points;
|
|
50147
|
+
},
|
|
50148
|
+
enumerable: false,
|
|
50149
|
+
configurable: true
|
|
50150
|
+
});
|
|
50151
|
+
EShapePolygon.prototype.newPoints = function () {
|
|
50152
|
+
return new EShapeLinePoints(this);
|
|
50153
|
+
};
|
|
50163
50154
|
EShapePolygon.prototype.newTriangulated = function () {
|
|
50164
50155
|
return new EShapePolygonTriangulatedImpl(this);
|
|
50165
50156
|
};
|
|
50166
50157
|
EShapePolygon.prototype.newStroke = function () {
|
|
50167
50158
|
return new EShapePolygonStroke(this, true, EShapeDefaults.STROKE_COLOR, EShapeDefaults.STROKE_ALPHA, EShapeDefaults.STROKE_WIDTH, EShapeDefaults.STROKE_ALIGN, EShapeDefaults.STROKE_SIDE, EShapeDefaults.STROKE_STYLE);
|
|
50168
50159
|
};
|
|
50169
|
-
Object.defineProperty(EShapePolygon.prototype, "vertices", {
|
|
50170
|
-
/**
|
|
50171
|
-
* Vertex positions are in [-0.5, +0.5] and relative to the shape position and size.
|
|
50172
|
-
* Therefore, transformed actual vertex positions are calculated as follows:
|
|
50173
|
-
*
|
|
50174
|
-
* ```
|
|
50175
|
-
* const imx = this.transform.internalTransform;
|
|
50176
|
-
* const size = this.size;
|
|
50177
|
-
* const vertices = this._vertices;
|
|
50178
|
-
* const transformedVertices = [];
|
|
50179
|
-
* for (let i = 0; i < vertices.length; i += 2) {
|
|
50180
|
-
* const transformedVertex = imx.apply(
|
|
50181
|
-
* new Point(size.x * vertices[i + 0], size.y * vertices[i + 1])
|
|
50182
|
-
* );
|
|
50183
|
-
* transformedVertices.push(transformedVertex.x, transformedVertex.y);
|
|
50184
|
-
* }
|
|
50185
|
-
* ```
|
|
50186
|
-
*/
|
|
50187
|
-
get: function () {
|
|
50188
|
-
return this._vertices;
|
|
50189
|
-
},
|
|
50190
|
-
set: function (vertices) {
|
|
50191
|
-
this.set(vertices);
|
|
50192
|
-
},
|
|
50193
|
-
enumerable: false,
|
|
50194
|
-
configurable: true
|
|
50195
|
-
});
|
|
50196
|
-
Object.defineProperty(EShapePolygon.prototype, "nvertices", {
|
|
50197
|
-
get: function () {
|
|
50198
|
-
return this._nvertices;
|
|
50199
|
-
},
|
|
50200
|
-
enumerable: false,
|
|
50201
|
-
configurable: true
|
|
50202
|
-
});
|
|
50203
|
-
Object.defineProperty(EShapePolygon.prototype, "vertexId", {
|
|
50204
|
-
get: function () {
|
|
50205
|
-
return this._vertexId;
|
|
50206
|
-
},
|
|
50207
|
-
enumerable: false,
|
|
50208
|
-
configurable: true
|
|
50209
|
-
});
|
|
50210
50160
|
Object.defineProperty(EShapePolygon.prototype, "triangulated", {
|
|
50211
50161
|
get: function () {
|
|
50212
50162
|
return this._triangulated;
|
|
@@ -50214,70 +50164,24 @@ var EShapePolygon = /** @class */ (function (_super) {
|
|
|
50214
50164
|
enumerable: false,
|
|
50215
50165
|
configurable: true
|
|
50216
50166
|
});
|
|
50217
|
-
EShapePolygon.prototype.set = function (vertices) {
|
|
50218
|
-
var isChanged = false;
|
|
50219
|
-
if (vertices != null) {
|
|
50220
|
-
var verticesLength = vertices.length;
|
|
50221
|
-
for (var i = 0; i < verticesLength; ++i) {
|
|
50222
|
-
this._vertices[i] = vertices[i];
|
|
50223
|
-
}
|
|
50224
|
-
if (this._vertices.length !== verticesLength) {
|
|
50225
|
-
this._vertices.length = verticesLength;
|
|
50226
|
-
}
|
|
50227
|
-
this._nvertices = verticesLength >> 1;
|
|
50228
|
-
isChanged = true;
|
|
50229
|
-
}
|
|
50230
|
-
if (isChanged) {
|
|
50231
|
-
this._vertexId += 1;
|
|
50232
|
-
this.updateUploaded();
|
|
50233
|
-
}
|
|
50234
|
-
return this;
|
|
50235
|
-
};
|
|
50236
50167
|
EShapePolygon.prototype.clone = function () {
|
|
50237
50168
|
return new EShapePolygon(this.type).copy(this);
|
|
50238
50169
|
};
|
|
50239
|
-
EShapePolygon.prototype.copy = function (source) {
|
|
50170
|
+
EShapePolygon.prototype.copy = function (source, part) {
|
|
50171
|
+
if (part === void 0) { part = EShapeCopyPart.ALL; }
|
|
50240
50172
|
this.lock(EShapeLockPart.ALL);
|
|
50241
|
-
var result = _super.prototype.copy.call(this, source);
|
|
50242
|
-
if (source instanceof EShapePolygon) {
|
|
50243
|
-
// Vertex ID
|
|
50244
|
-
this._vertexId += 1;
|
|
50245
|
-
// Vertices
|
|
50246
|
-
var sourceVertices = source._vertices;
|
|
50247
|
-
var sourceVerticesLength = sourceVertices.length;
|
|
50248
|
-
var vertices = this._vertices;
|
|
50249
|
-
for (var i = 0; i < sourceVerticesLength; ++i) {
|
|
50250
|
-
vertices[i] = sourceVertices[i];
|
|
50251
|
-
}
|
|
50252
|
-
if (vertices.length !== sourceVerticesLength) {
|
|
50253
|
-
vertices.length = sourceVerticesLength;
|
|
50254
|
-
}
|
|
50255
|
-
// Number of Vertices
|
|
50256
|
-
this._nvertices = sourceVerticesLength >> 1;
|
|
50257
|
-
// Triangulated
|
|
50173
|
+
var result = _super.prototype.copy.call(this, source, part);
|
|
50174
|
+
if (part & EShapeCopyPart.POINTS && source instanceof EShapePolygon) {
|
|
50258
50175
|
this._triangulated.copy(source._triangulated);
|
|
50259
|
-
// Update
|
|
50260
|
-
var uploaded = this.uploaded;
|
|
50261
|
-
if (uploaded) {
|
|
50262
|
-
if (uploaded.isCompatible(this)) {
|
|
50263
|
-
this.updateUploaded();
|
|
50264
|
-
}
|
|
50265
|
-
else {
|
|
50266
|
-
this.toDirty();
|
|
50267
|
-
}
|
|
50268
|
-
}
|
|
50269
|
-
else {
|
|
50270
|
-
this.updateUploaded();
|
|
50271
|
-
}
|
|
50272
50176
|
}
|
|
50273
50177
|
this.unlock(EShapeLockPart.ALL, true);
|
|
50274
50178
|
return result;
|
|
50275
50179
|
};
|
|
50276
50180
|
EShapePolygon.prototype.serialize = function (manager) {
|
|
50277
50181
|
var result = _super.prototype.serialize.call(this, manager);
|
|
50278
|
-
var
|
|
50182
|
+
var pointsId = this._points.serialize(manager);
|
|
50279
50183
|
var triangulatedId = this._triangulated.serialize(manager);
|
|
50280
|
-
var serialized = [
|
|
50184
|
+
var serialized = [pointsId, triangulatedId];
|
|
50281
50185
|
result[15] = manager.addResource(JSON.stringify(serialized));
|
|
50282
50186
|
return result;
|
|
50283
50187
|
};
|
|
@@ -50290,34 +50194,10 @@ var EShapePolygon = /** @class */ (function (_super) {
|
|
|
50290
50194
|
parsed = JSON.parse(resources[resourceId]);
|
|
50291
50195
|
manager.setExtension(resourceId, parsed);
|
|
50292
50196
|
}
|
|
50293
|
-
|
|
50294
|
-
this.
|
|
50295
|
-
// Vertices
|
|
50296
|
-
var verticesId = parsed[0];
|
|
50297
|
-
if (0 <= verticesId && verticesId < resourcesLength) {
|
|
50298
|
-
var vertices = manager.getExtension(verticesId);
|
|
50299
|
-
if (vertices == null) {
|
|
50300
|
-
vertices = JSON.parse(resources[verticesId]);
|
|
50301
|
-
manager.setExtension(verticesId, vertices);
|
|
50302
|
-
}
|
|
50303
|
-
this._vertices = vertices;
|
|
50304
|
-
this._nvertices = vertices.length >> 1;
|
|
50305
|
-
}
|
|
50306
|
-
// Triangulated
|
|
50197
|
+
this.lock(EShapeLockPart.ALL);
|
|
50198
|
+
this._points.deserialize(parsed[0], manager);
|
|
50307
50199
|
this._triangulated.deserialize(parsed[1], manager);
|
|
50308
|
-
|
|
50309
|
-
var uploaded = this.uploaded;
|
|
50310
|
-
if (uploaded) {
|
|
50311
|
-
if (uploaded.isCompatible(this)) {
|
|
50312
|
-
this.updateUploaded();
|
|
50313
|
-
}
|
|
50314
|
-
else {
|
|
50315
|
-
this.toDirty();
|
|
50316
|
-
}
|
|
50317
|
-
}
|
|
50318
|
-
else {
|
|
50319
|
-
this.updateUploaded();
|
|
50320
|
-
}
|
|
50200
|
+
this.unlock(EShapeLockPart.ALL, true);
|
|
50321
50201
|
}
|
|
50322
50202
|
};
|
|
50323
50203
|
EShapePolygon.prototype.containsAbs = function (x, y, ax, ay, sw, ss, sa) {
|
|
@@ -50392,10 +50272,6 @@ var BuilderPolygon = /** @class */ (function (_super) {
|
|
|
50392
50272
|
this.updateColor(buffer, shape);
|
|
50393
50273
|
};
|
|
50394
50274
|
BuilderPolygon.prototype.updateVertexStepUvAndIndex = function (buffer, shape) {
|
|
50395
|
-
var size = shape.size;
|
|
50396
|
-
var sizeX = size.x;
|
|
50397
|
-
var sizeY = size.y;
|
|
50398
|
-
var isSizeChanged = sizeX !== this.sizeX || sizeY !== this.sizeY;
|
|
50399
50275
|
var transformLocalId = toTransformLocalId(shape);
|
|
50400
50276
|
var isTransformChanged = this.transformLocalId !== transformLocalId;
|
|
50401
50277
|
// Check if vertices/distances/clippings/indices changed
|
|
@@ -50412,16 +50288,13 @@ var BuilderPolygon = /** @class */ (function (_super) {
|
|
|
50412
50288
|
var texture = toTexture(shape);
|
|
50413
50289
|
var textureTransformId = toTextureTransformId(texture);
|
|
50414
50290
|
var isTextureChanged = texture !== this.texture || textureTransformId !== this.textureTransformId;
|
|
50415
|
-
var isVertexChanged = isSizeChanged || isTriangulatedIdChanged;
|
|
50416
50291
|
var isNotInited = !(this.inited & BuilderFlag.VERTEX_STEP_UV_AND_INDEX);
|
|
50417
50292
|
if (isNotInited ||
|
|
50418
|
-
|
|
50293
|
+
isTriangulatedIdChanged ||
|
|
50419
50294
|
isTransformChanged ||
|
|
50420
50295
|
isStrokeChanged ||
|
|
50421
50296
|
isTextureChanged) {
|
|
50422
50297
|
this.inited |= BuilderFlag.VERTEX_STEP_UV_AND_INDEX;
|
|
50423
|
-
this.sizeX = sizeX;
|
|
50424
|
-
this.sizeY = sizeY;
|
|
50425
50298
|
this.transformLocalId = transformLocalId;
|
|
50426
50299
|
this.strokeWidth = strokeWidth;
|
|
50427
50300
|
this.strokeSide = strokeSide;
|
|
@@ -50430,25 +50303,25 @@ var BuilderPolygon = /** @class */ (function (_super) {
|
|
|
50430
50303
|
this.textureTransformId = textureTransformId;
|
|
50431
50304
|
this.triangulatedId = triangulatedId;
|
|
50432
50305
|
// Indices
|
|
50433
|
-
if (isNotInited ||
|
|
50306
|
+
if (isNotInited || isTriangulatedIdChanged) {
|
|
50434
50307
|
buffer.updateIndices();
|
|
50435
50308
|
buildPolygonIndex(buffer.indices, triangulated.indices, this.vertexOffset, this.indexOffset);
|
|
50436
50309
|
}
|
|
50437
50310
|
// Vertices
|
|
50438
50311
|
var voffset = this.vertexOffset;
|
|
50439
|
-
if (isNotInited ||
|
|
50312
|
+
if (isNotInited || isTriangulatedIdChanged || isTransformChanged) {
|
|
50440
50313
|
buffer.updateVertices();
|
|
50441
|
-
buildPolygonVertex(buffer.vertices, triangulated.vertices, voffset,
|
|
50314
|
+
buildPolygonVertex(buffer.vertices, triangulated.vertices, voffset, shape.transform.internalTransform);
|
|
50442
50315
|
}
|
|
50443
50316
|
// Steps
|
|
50444
|
-
if (isNotInited ||
|
|
50317
|
+
if (isNotInited || isTriangulatedIdChanged || isStrokeChanged) {
|
|
50445
50318
|
buffer.updateSteps();
|
|
50446
|
-
buildPolygonStep(buffer.steps, triangulated.distances, triangulated.clippings, voffset, this.vertexCount,
|
|
50319
|
+
buildPolygonStep(buffer.steps, triangulated.distances, triangulated.clippings, voffset, this.vertexCount, strokeWidth, strokeSide, strokeStyle);
|
|
50447
50320
|
}
|
|
50448
50321
|
// UVs
|
|
50449
|
-
if (isNotInited ||
|
|
50322
|
+
if (isNotInited || isTriangulatedIdChanged || isTextureChanged) {
|
|
50450
50323
|
buffer.updateUvs();
|
|
50451
|
-
buildPolygonUv(buffer.uvs, triangulated.
|
|
50324
|
+
buildPolygonUv(buffer.uvs, triangulated.uvs, voffset, toTextureUvs(texture));
|
|
50452
50325
|
}
|
|
50453
50326
|
}
|
|
50454
50327
|
};
|
|
@@ -53015,51 +52888,41 @@ var createLine = function (points, segments, strokeWidth, pointsStyle) {
|
|
|
53015
52888
|
return result;
|
|
53016
52889
|
};
|
|
53017
52890
|
|
|
53018
|
-
var createPolygon = function (points) {
|
|
52891
|
+
var createPolygon = function (points, result) {
|
|
52892
|
+
result !== null && result !== void 0 ? result : (result = new EShapePolygon());
|
|
53019
52893
|
var pointsLength = points.length;
|
|
53020
|
-
if (
|
|
53021
|
-
|
|
53022
|
-
|
|
53023
|
-
var ymin = 0;
|
|
53024
|
-
var ymax = 0;
|
|
53025
|
-
xmin = xmax = points[0];
|
|
53026
|
-
ymin = ymax = points[1];
|
|
53027
|
-
for (var i = 2; i < pointsLength; i += 2) {
|
|
53028
|
-
var x = points[i];
|
|
53029
|
-
var y = points[i + 1];
|
|
53030
|
-
xmin = Math.min(xmin, x);
|
|
53031
|
-
xmax = Math.max(xmax, x);
|
|
53032
|
-
ymin = Math.min(ymin, y);
|
|
53033
|
-
ymax = Math.max(ymax, y);
|
|
53034
|
-
}
|
|
53035
|
-
var sx = xmax - xmin;
|
|
53036
|
-
var sy = ymax - ymin;
|
|
53037
|
-
var px = xmin + 0.5 * sx;
|
|
53038
|
-
var py = ymin + 0.5 * sy;
|
|
53039
|
-
if (0 < Math.abs(sx) && 0 < Math.abs(sy)) {
|
|
53040
|
-
var fx = 1 / sx;
|
|
53041
|
-
var fy = 1 / sy;
|
|
53042
|
-
var vertices = [];
|
|
53043
|
-
for (var i = 0; i < pointsLength; i += 2) {
|
|
53044
|
-
vertices.push((points[i] - xmin) * fx - 0.5, (points[i + 1] - ymin) * fy - 0.5);
|
|
53045
|
-
}
|
|
53046
|
-
var result = new EShapePolygon();
|
|
53047
|
-
result.lock(EShapeLockPart.ALL);
|
|
53048
|
-
result.transform.position.set(px, py);
|
|
53049
|
-
result.size.set(sx, sy);
|
|
53050
|
-
result.vertices = vertices;
|
|
53051
|
-
result.unlock(EShapeLockPart.ALL, true);
|
|
53052
|
-
return result;
|
|
53053
|
-
}
|
|
53054
|
-
else {
|
|
53055
|
-
var result = new EShapePolygon();
|
|
53056
|
-
result.transform.position.set(px, py);
|
|
53057
|
-
return result;
|
|
53058
|
-
}
|
|
52894
|
+
if (pointsLength < 2) {
|
|
52895
|
+
result.points.values = [];
|
|
52896
|
+
return result;
|
|
53059
52897
|
}
|
|
53060
|
-
|
|
53061
|
-
|
|
52898
|
+
var xmin = 0;
|
|
52899
|
+
var xmax = 0;
|
|
52900
|
+
var ymin = 0;
|
|
52901
|
+
var ymax = 0;
|
|
52902
|
+
xmin = xmax = points[0];
|
|
52903
|
+
ymin = ymax = points[1];
|
|
52904
|
+
for (var i = 2; i < pointsLength; i += 2) {
|
|
52905
|
+
var x = points[i];
|
|
52906
|
+
var y = points[i + 1];
|
|
52907
|
+
xmin = Math.min(xmin, x);
|
|
52908
|
+
xmax = Math.max(xmax, x);
|
|
52909
|
+
ymin = Math.min(ymin, y);
|
|
52910
|
+
ymax = Math.max(ymax, y);
|
|
52911
|
+
}
|
|
52912
|
+
var sx = xmax - xmin;
|
|
52913
|
+
var sy = ymax - ymin;
|
|
52914
|
+
var px = xmin + 0.5 * sx;
|
|
52915
|
+
var py = ymin + 0.5 * sy;
|
|
52916
|
+
var values = [];
|
|
52917
|
+
for (var i = 0; i < pointsLength; i += 2) {
|
|
52918
|
+
values.push(points[i] - px, points[i + 1] - py);
|
|
53062
52919
|
}
|
|
52920
|
+
result.lock(EShapeLockPart.ALL);
|
|
52921
|
+
result.transform.position.set(px, py);
|
|
52922
|
+
result.size.set(sx, sy);
|
|
52923
|
+
result.points.values = values;
|
|
52924
|
+
result.unlock(EShapeLockPart.ALL, true);
|
|
52925
|
+
return result;
|
|
53063
52926
|
};
|
|
53064
52927
|
|
|
53065
52928
|
/*
|