dgeoutils 2.2.16 → 2.2.17

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.
@@ -102,6 +102,7 @@ export declare class DPolygon {
102
102
  get closed(): boolean;
103
103
  buffer(v: number, quadrantSegments?: number, type?: number): DPolygon;
104
104
  bezier(step?: number): DPolygon;
105
+ setGrowingHeight(from: number, to: number): DPolygon;
105
106
  private getBezierPoint;
106
107
  private simpleIncludeX;
107
108
  private simpleIncludeY;
package/dist/DPolygon.js CHANGED
@@ -815,6 +815,20 @@ class DPolygon {
815
815
  }
816
816
  return res;
817
817
  }
818
+ setGrowingHeight(from, to) {
819
+ const { fullLength } = this;
820
+ let { first: prevPoint } = this;
821
+ const d = to - from;
822
+ let currentDistance = 0;
823
+ this.loop()
824
+ .setZ((p) => {
825
+ currentDistance += prevPoint.distance(p);
826
+ prevPoint = p;
827
+ return from + currentDistance / fullLength * d;
828
+ })
829
+ .run();
830
+ return this;
831
+ }
818
832
  getBezierPoint(v) {
819
833
  if (this.length === 1) {
820
834
  return this.first;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dgeoutils",
3
- "version": "2.2.16",
3
+ "version": "2.2.17",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build": "node_modules/.bin/tsc",