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