dgeoutils 2.3.0 → 2.3.4
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/README.md +7 -0
- package/dist/cjs/DLine.d.ts +2 -1
- package/dist/cjs/DLine.js +16 -8
- package/dist/cjs/DPolygon.d.ts +1 -1
- package/dist/cjs/DPolygon.js +30 -30
- package/dist/cjs/TraceMatrix.d.ts +1 -2
- package/dist/cjs/index.d.ts +1 -4
- package/dist/cjs/index.js +1 -3
- package/dist/cjs/utils.d.ts +3 -0
- package/dist/cjs/utils.js +6 -4
- package/dist/es2015/DLine.js +13 -5
- package/dist/es2015/DPolygon.js +30 -30
- package/dist/es2015/index.js +1 -4
- package/dist/es2015/utils.js +3 -1
- package/dist/esm/DLine.js +16 -8
- package/dist/esm/DPolygon.js +30 -30
- package/dist/esm/index.js +1 -4
- package/dist/esm/utils.js +3 -1
- package/dist/umd/dgeoutils.js +50 -43
- package/dist/umd/dgeoutils.min.js +1 -1
- package/dist/umd/dgeoutils.min.js.map +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -19,6 +19,13 @@
|
|
|
19
19
|
|
|
20
20
|
[ESLint Report](https://edejin.github.io/DGeoUtils/media/eslit.html)
|
|
21
21
|
|
|
22
|
+
```html
|
|
23
|
+
<script src="https://unpkg.com/jsts@latest/dist/jsts.js"></script>
|
|
24
|
+
<script src="https://unpkg.com/dgeoutils@latest/dist/umd/dgeoutils.js"></script>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
[Sandbox](https://jsbin.com/yaxaqif/edit?js,output)
|
|
28
|
+
|
|
22
29
|
### For new release
|
|
23
30
|
```
|
|
24
31
|
npm run release-fix
|
package/dist/cjs/DLine.d.ts
CHANGED
|
@@ -30,7 +30,8 @@ export declare class DLine {
|
|
|
30
30
|
get points(): [DPoint, DPoint];
|
|
31
31
|
getFi(): number;
|
|
32
32
|
toWKT(): string;
|
|
33
|
-
movePoint(
|
|
33
|
+
movePoint(point: DPoint, distance: number): DPoint;
|
|
34
|
+
movePoint(points: DPoint[], distances: number[]): DPoint[];
|
|
34
35
|
findFi({ a, b }: DLine, delta?: number): number;
|
|
35
36
|
vectorProduct({ a, b, c }: DLine): DLine;
|
|
36
37
|
}
|
package/dist/cjs/DLine.js
CHANGED
|
@@ -262,20 +262,28 @@ var DLine = (function () {
|
|
|
262
262
|
var _a = this, _b = _a.begin, x1 = _b.x, y1 = _b.y, _c = _a.end, x2 = _c.x, y2 = _c.y;
|
|
263
263
|
return "LINESTRING (" + x1 + " " + y1 + ", " + x2 + " " + y2 + ")";
|
|
264
264
|
};
|
|
265
|
-
DLine.prototype.movePoint = function (
|
|
265
|
+
DLine.prototype.movePoint = function (i, k) {
|
|
266
|
+
var p = Array.isArray(i) ? i : [i];
|
|
267
|
+
var d = Array.isArray(k) ? k : [k];
|
|
266
268
|
var fi = this.findFi(new DLine(1, 0, 0));
|
|
267
269
|
var td = this.x(new DPoint_1.DPoint(1, 1)).distance(this.x(new DPoint_1.DPoint(2, 2))) / 2;
|
|
268
270
|
var sinCos = new DPoint_1.DPoint(Math.sin(fi), Math.cos(fi));
|
|
269
271
|
var dt = sinCos.clone().scale(td);
|
|
270
|
-
var p1T = p.clone().move(dt.clone().minus());
|
|
271
|
-
var p2T = p.clone().move(dt);
|
|
272
|
+
var p1T = p[0].clone().move(dt.clone().minus());
|
|
273
|
+
var p2T = p[0].clone().move(dt);
|
|
274
|
+
var res = [];
|
|
272
275
|
if (DNumbers_1.DNumbers.like(this.y(p1T).y, p1T.y) || DNumbers_1.DNumbers.like(this.y(p2T).y, p2T.y)) {
|
|
273
|
-
|
|
276
|
+
res = p.map(function (t, index) { return t.clone().move(sinCos.scale(d[index])); });
|
|
274
277
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
278
|
+
else {
|
|
279
|
+
res = p.map(function (t, index) { return t.clone()
|
|
280
|
+
.move(sinCos.scale(d[index])
|
|
281
|
+
.setX(function (_a) {
|
|
282
|
+
var x = _a.x;
|
|
283
|
+
return -x;
|
|
284
|
+
})); });
|
|
285
|
+
}
|
|
286
|
+
return res.length === 1 ? res[0] : res;
|
|
279
287
|
};
|
|
280
288
|
DLine.prototype.findFi = function (_a, delta) {
|
|
281
289
|
var a = _a.a, b = _a.b;
|
package/dist/cjs/DPolygon.d.ts
CHANGED
|
@@ -87,7 +87,7 @@ export declare class DPolygon {
|
|
|
87
87
|
removePart(index: number, count: number): DPoint[];
|
|
88
88
|
hasSimpleIntersection(p: DPolygon): boolean;
|
|
89
89
|
simpleInclude(p: DPoint): boolean;
|
|
90
|
-
drawPolygonOnCanvas(canvas: HTMLCanvasElement | OffscreenCanvas, fillColor?: string, strokeColor?: string, shadowColor?: string, lineWidth?: number, steps?: number):
|
|
90
|
+
drawPolygonOnCanvas(canvas: HTMLCanvasElement | OffscreenCanvas, fillColor?: string, strokeColor?: string, shadowColor?: string, lineWidth?: number, steps?: number): DPolygon;
|
|
91
91
|
clearPolygonOnCanvas(canvas: HTMLCanvasElement | OffscreenCanvas): void;
|
|
92
92
|
contain(p: DPoint, isBorderInside?: boolean): boolean;
|
|
93
93
|
onBorder(p: DPoint): boolean;
|
package/dist/cjs/DPolygon.js
CHANGED
|
@@ -827,36 +827,36 @@ var DPolygon = (function () {
|
|
|
827
827
|
DPolygon.prototype.drawPolygonOnCanvas = function (canvas, fillColor, strokeColor, shadowColor, lineWidth, steps) {
|
|
828
828
|
if (lineWidth === void 0) { lineWidth = 1; }
|
|
829
829
|
if (steps === void 0) { steps = this.length - 1; }
|
|
830
|
-
if (this.length
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
ctx.
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
ctx.stroke();
|
|
830
|
+
if (this.length > 1) {
|
|
831
|
+
var ctx = canvas.getContext('2d');
|
|
832
|
+
if (fillColor) {
|
|
833
|
+
ctx.fillStyle = fillColor;
|
|
834
|
+
}
|
|
835
|
+
if (strokeColor) {
|
|
836
|
+
ctx.strokeStyle = strokeColor;
|
|
837
|
+
}
|
|
838
|
+
if (lineWidth) {
|
|
839
|
+
ctx.lineWidth = lineWidth;
|
|
840
|
+
}
|
|
841
|
+
if (fillColor || strokeColor) {
|
|
842
|
+
ctx.beginPath();
|
|
843
|
+
}
|
|
844
|
+
this.goByPath(ctx, steps % this.length);
|
|
845
|
+
if (shadowColor) {
|
|
846
|
+
ctx.shadowColor = shadowColor;
|
|
847
|
+
ctx.shadowBlur = 0;
|
|
848
|
+
ctx.shadowOffsetX = 1;
|
|
849
|
+
ctx.shadowOffsetY = 1;
|
|
850
|
+
}
|
|
851
|
+
if (fillColor) {
|
|
852
|
+
ctx.closePath();
|
|
853
|
+
ctx.fill();
|
|
854
|
+
}
|
|
855
|
+
if (strokeColor) {
|
|
856
|
+
ctx.stroke();
|
|
857
|
+
}
|
|
859
858
|
}
|
|
859
|
+
return this;
|
|
860
860
|
};
|
|
861
861
|
DPolygon.prototype.clearPolygonOnCanvas = function (canvas) {
|
|
862
862
|
var ctx = canvas.getContext('2d');
|
|
@@ -1299,7 +1299,7 @@ var DPolygon = (function () {
|
|
|
1299
1299
|
var toPoint = Math.max(Math.min(start0, start1), Math.min(end0, end1));
|
|
1300
1300
|
var linePart = new DPolygon(buffer.removePart(fromPoint - 1, toPoint - fromPoint + 1));
|
|
1301
1301
|
buffer.unshift(buffer.pop());
|
|
1302
|
-
return [linePart, buffer];
|
|
1302
|
+
return [linePart.reverse(), buffer];
|
|
1303
1303
|
};
|
|
1304
1304
|
DPolygon.prototype.bezier = function (step) {
|
|
1305
1305
|
if (step === void 0) { step = 0.1; }
|
|
@@ -4,7 +4,7 @@ export declare enum TraceMatrixValues {
|
|
|
4
4
|
f = 0,
|
|
5
5
|
t = 1
|
|
6
6
|
}
|
|
7
|
-
declare type SimpleMatrix = TraceMatrixValues[][];
|
|
7
|
+
export declare type SimpleMatrix = TraceMatrixValues[][];
|
|
8
8
|
export declare class TraceMatrix {
|
|
9
9
|
private readonly size;
|
|
10
10
|
private readonly m;
|
|
@@ -19,4 +19,3 @@ export declare class TraceMatrix {
|
|
|
19
19
|
private createHoleMatrix;
|
|
20
20
|
static createMatrix(size: DPoint, f?: (pos: DPoint) => TraceMatrixValues): SimpleMatrix;
|
|
21
21
|
}
|
|
22
|
-
export {};
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -7,7 +7,4 @@ export * from './FastSearch';
|
|
|
7
7
|
export * from './TraceMatrix';
|
|
8
8
|
export * from './DPolygonLoop';
|
|
9
9
|
export * from './DPlane';
|
|
10
|
-
export { gaussianElimination, createCanvas, createArray, createMatrix, isDefAndNotNull } from './utils';
|
|
11
|
-
export declare const DGeo: {
|
|
12
|
-
DEBUG: boolean;
|
|
13
|
-
};
|
|
10
|
+
export { gaussianElimination, createCanvas, createArray, createMatrix, isDefAndNotNull, DGeo } from './utils';
|
package/dist/cjs/index.js
CHANGED
|
@@ -26,6 +26,4 @@ Object.defineProperty(exports, "createCanvas", { enumerable: true, get: function
|
|
|
26
26
|
Object.defineProperty(exports, "createArray", { enumerable: true, get: function () { return utils_1.createArray; } });
|
|
27
27
|
Object.defineProperty(exports, "createMatrix", { enumerable: true, get: function () { return utils_1.createMatrix; } });
|
|
28
28
|
Object.defineProperty(exports, "isDefAndNotNull", { enumerable: true, get: function () { return utils_1.isDefAndNotNull; } });
|
|
29
|
-
exports.DGeo
|
|
30
|
-
DEBUG: false
|
|
31
|
-
};
|
|
29
|
+
Object.defineProperty(exports, "DGeo", { enumerable: true, get: function () { return utils_1.DGeo; } });
|
package/dist/cjs/utils.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/// <reference types="offscreencanvas" />
|
|
2
2
|
import { DPoint } from './DPoint';
|
|
3
|
+
export declare const DGeo: {
|
|
4
|
+
DEBUG: boolean;
|
|
5
|
+
};
|
|
3
6
|
export declare const warn: (...args: any[]) => void;
|
|
4
7
|
export declare const isDefAndNotNull: (a: any) => boolean;
|
|
5
8
|
declare type CheckFunc = (p: DPoint) => CheckFunction;
|
package/dist/cjs/utils.js
CHANGED
|
@@ -25,15 +25,17 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
25
25
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
26
26
|
};
|
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.createCanvas = exports.gaussianElimination = exports.createMatrix = exports.createArray = exports.checkFunction = exports.isDefAndNotNull = exports.warn = void 0;
|
|
29
|
-
var index_1 = require("./index");
|
|
28
|
+
exports.createCanvas = exports.gaussianElimination = exports.createMatrix = exports.createArray = exports.checkFunction = exports.isDefAndNotNull = exports.warn = exports.DGeo = void 0;
|
|
30
29
|
var DPoint_1 = require("./DPoint");
|
|
30
|
+
exports.DGeo = {
|
|
31
|
+
DEBUG: false
|
|
32
|
+
};
|
|
31
33
|
var warn = function () {
|
|
32
34
|
var args = [];
|
|
33
35
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
34
36
|
args[_i] = arguments[_i];
|
|
35
37
|
}
|
|
36
|
-
if (
|
|
38
|
+
if (exports.DGeo.DEBUG) {
|
|
37
39
|
console.warn.apply(console, __spreadArray([], __read(args), false));
|
|
38
40
|
}
|
|
39
41
|
};
|
|
@@ -81,7 +83,7 @@ var shouldBeMeters = function (scope, funcName, argName) { return function (p) {
|
|
|
81
83
|
}; };
|
|
82
84
|
var checkFunction = function (funcName) { return ({
|
|
83
85
|
checkArgument: function (argName) {
|
|
84
|
-
if (!
|
|
86
|
+
if (!exports.DGeo.DEBUG) {
|
|
85
87
|
return {
|
|
86
88
|
shouldBeDegree: hook(this),
|
|
87
89
|
shouldBeMeters: hook(this),
|
package/dist/es2015/DLine.js
CHANGED
|
@@ -217,17 +217,25 @@ export class DLine {
|
|
|
217
217
|
const { begin: { x: x1, y: y1 }, end: { x: x2, y: y2 } } = this;
|
|
218
218
|
return `LINESTRING (${x1} ${y1}, ${x2} ${y2})`;
|
|
219
219
|
}
|
|
220
|
-
movePoint(
|
|
220
|
+
movePoint(i, k) {
|
|
221
|
+
const p = Array.isArray(i) ? i : [i];
|
|
222
|
+
const d = Array.isArray(k) ? k : [k];
|
|
221
223
|
const fi = this.findFi(new DLine(1, 0, 0));
|
|
222
224
|
const td = this.x(new DPoint(1, 1)).distance(this.x(new DPoint(2, 2))) / 2;
|
|
223
225
|
const sinCos = new DPoint(Math.sin(fi), Math.cos(fi));
|
|
224
226
|
const dt = sinCos.clone().scale(td);
|
|
225
|
-
const p1T = p.clone().move(dt.clone().minus());
|
|
226
|
-
const p2T = p.clone().move(dt);
|
|
227
|
+
const p1T = p[0].clone().move(dt.clone().minus());
|
|
228
|
+
const p2T = p[0].clone().move(dt);
|
|
229
|
+
let res = [];
|
|
227
230
|
if (DNumbers.like(this.y(p1T).y, p1T.y) || DNumbers.like(this.y(p2T).y, p2T.y)) {
|
|
228
|
-
|
|
231
|
+
res = p.map((t, index) => t.clone().move(sinCos.scale(d[index])));
|
|
229
232
|
}
|
|
230
|
-
|
|
233
|
+
else {
|
|
234
|
+
res = p.map((t, index) => t.clone()
|
|
235
|
+
.move(sinCos.scale(d[index])
|
|
236
|
+
.setX(({ x }) => -x)));
|
|
237
|
+
}
|
|
238
|
+
return res.length === 1 ? res[0] : res;
|
|
231
239
|
}
|
|
232
240
|
findFi({ a, b }, delta = 1.0001) {
|
|
233
241
|
const { a: q, b: w } = this;
|
package/dist/es2015/DPolygon.js
CHANGED
|
@@ -513,36 +513,36 @@ export class DPolygon {
|
|
|
513
513
|
return this.simpleIncludeX(p) && this.simpleIncludeY(p);
|
|
514
514
|
}
|
|
515
515
|
drawPolygonOnCanvas(canvas, fillColor, strokeColor, shadowColor, lineWidth = 1, steps = this.length - 1) {
|
|
516
|
-
if (this.length
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
ctx.
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
ctx.stroke();
|
|
516
|
+
if (this.length > 1) {
|
|
517
|
+
const ctx = canvas.getContext('2d');
|
|
518
|
+
if (fillColor) {
|
|
519
|
+
ctx.fillStyle = fillColor;
|
|
520
|
+
}
|
|
521
|
+
if (strokeColor) {
|
|
522
|
+
ctx.strokeStyle = strokeColor;
|
|
523
|
+
}
|
|
524
|
+
if (lineWidth) {
|
|
525
|
+
ctx.lineWidth = lineWidth;
|
|
526
|
+
}
|
|
527
|
+
if (fillColor || strokeColor) {
|
|
528
|
+
ctx.beginPath();
|
|
529
|
+
}
|
|
530
|
+
this.goByPath(ctx, steps % this.length);
|
|
531
|
+
if (shadowColor) {
|
|
532
|
+
ctx.shadowColor = shadowColor;
|
|
533
|
+
ctx.shadowBlur = 0;
|
|
534
|
+
ctx.shadowOffsetX = 1;
|
|
535
|
+
ctx.shadowOffsetY = 1;
|
|
536
|
+
}
|
|
537
|
+
if (fillColor) {
|
|
538
|
+
ctx.closePath();
|
|
539
|
+
ctx.fill();
|
|
540
|
+
}
|
|
541
|
+
if (strokeColor) {
|
|
542
|
+
ctx.stroke();
|
|
543
|
+
}
|
|
545
544
|
}
|
|
545
|
+
return this;
|
|
546
546
|
}
|
|
547
547
|
clearPolygonOnCanvas(canvas) {
|
|
548
548
|
const ctx = canvas.getContext('2d');
|
|
@@ -864,7 +864,7 @@ export class DPolygon {
|
|
|
864
864
|
const toPoint = Math.max(Math.min(start0, start1), Math.min(end0, end1));
|
|
865
865
|
const linePart = new DPolygon(buffer.removePart(fromPoint - 1, toPoint - fromPoint + 1));
|
|
866
866
|
buffer.unshift(buffer.pop());
|
|
867
|
-
return [linePart, buffer];
|
|
867
|
+
return [linePart.reverse(), buffer];
|
|
868
868
|
}
|
|
869
869
|
bezier(step = 0.1) {
|
|
870
870
|
const res = new DPolygon();
|
package/dist/es2015/index.js
CHANGED
|
@@ -7,7 +7,4 @@ export * from './FastSearch';
|
|
|
7
7
|
export * from './TraceMatrix';
|
|
8
8
|
export * from './DPolygonLoop';
|
|
9
9
|
export * from './DPlane';
|
|
10
|
-
export { gaussianElimination, createCanvas, createArray, createMatrix, isDefAndNotNull } from './utils';
|
|
11
|
-
export const DGeo = {
|
|
12
|
-
DEBUG: false
|
|
13
|
-
};
|
|
10
|
+
export { gaussianElimination, createCanvas, createArray, createMatrix, isDefAndNotNull, DGeo } from './utils';
|
package/dist/es2015/utils.js
CHANGED
package/dist/esm/DLine.js
CHANGED
|
@@ -259,20 +259,28 @@ var DLine = (function () {
|
|
|
259
259
|
var _a = this, _b = _a.begin, x1 = _b.x, y1 = _b.y, _c = _a.end, x2 = _c.x, y2 = _c.y;
|
|
260
260
|
return "LINESTRING (" + x1 + " " + y1 + ", " + x2 + " " + y2 + ")";
|
|
261
261
|
};
|
|
262
|
-
DLine.prototype.movePoint = function (
|
|
262
|
+
DLine.prototype.movePoint = function (i, k) {
|
|
263
|
+
var p = Array.isArray(i) ? i : [i];
|
|
264
|
+
var d = Array.isArray(k) ? k : [k];
|
|
263
265
|
var fi = this.findFi(new DLine(1, 0, 0));
|
|
264
266
|
var td = this.x(new DPoint(1, 1)).distance(this.x(new DPoint(2, 2))) / 2;
|
|
265
267
|
var sinCos = new DPoint(Math.sin(fi), Math.cos(fi));
|
|
266
268
|
var dt = sinCos.clone().scale(td);
|
|
267
|
-
var p1T = p.clone().move(dt.clone().minus());
|
|
268
|
-
var p2T = p.clone().move(dt);
|
|
269
|
+
var p1T = p[0].clone().move(dt.clone().minus());
|
|
270
|
+
var p2T = p[0].clone().move(dt);
|
|
271
|
+
var res = [];
|
|
269
272
|
if (DNumbers.like(this.y(p1T).y, p1T.y) || DNumbers.like(this.y(p2T).y, p2T.y)) {
|
|
270
|
-
|
|
273
|
+
res = p.map(function (t, index) { return t.clone().move(sinCos.scale(d[index])); });
|
|
271
274
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
275
|
+
else {
|
|
276
|
+
res = p.map(function (t, index) { return t.clone()
|
|
277
|
+
.move(sinCos.scale(d[index])
|
|
278
|
+
.setX(function (_a) {
|
|
279
|
+
var x = _a.x;
|
|
280
|
+
return -x;
|
|
281
|
+
})); });
|
|
282
|
+
}
|
|
283
|
+
return res.length === 1 ? res[0] : res;
|
|
276
284
|
};
|
|
277
285
|
DLine.prototype.findFi = function (_a, delta) {
|
|
278
286
|
var a = _a.a, b = _a.b;
|
package/dist/esm/DPolygon.js
CHANGED
|
@@ -824,36 +824,36 @@ var DPolygon = (function () {
|
|
|
824
824
|
DPolygon.prototype.drawPolygonOnCanvas = function (canvas, fillColor, strokeColor, shadowColor, lineWidth, steps) {
|
|
825
825
|
if (lineWidth === void 0) { lineWidth = 1; }
|
|
826
826
|
if (steps === void 0) { steps = this.length - 1; }
|
|
827
|
-
if (this.length
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
ctx.
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
ctx.stroke();
|
|
827
|
+
if (this.length > 1) {
|
|
828
|
+
var ctx = canvas.getContext('2d');
|
|
829
|
+
if (fillColor) {
|
|
830
|
+
ctx.fillStyle = fillColor;
|
|
831
|
+
}
|
|
832
|
+
if (strokeColor) {
|
|
833
|
+
ctx.strokeStyle = strokeColor;
|
|
834
|
+
}
|
|
835
|
+
if (lineWidth) {
|
|
836
|
+
ctx.lineWidth = lineWidth;
|
|
837
|
+
}
|
|
838
|
+
if (fillColor || strokeColor) {
|
|
839
|
+
ctx.beginPath();
|
|
840
|
+
}
|
|
841
|
+
this.goByPath(ctx, steps % this.length);
|
|
842
|
+
if (shadowColor) {
|
|
843
|
+
ctx.shadowColor = shadowColor;
|
|
844
|
+
ctx.shadowBlur = 0;
|
|
845
|
+
ctx.shadowOffsetX = 1;
|
|
846
|
+
ctx.shadowOffsetY = 1;
|
|
847
|
+
}
|
|
848
|
+
if (fillColor) {
|
|
849
|
+
ctx.closePath();
|
|
850
|
+
ctx.fill();
|
|
851
|
+
}
|
|
852
|
+
if (strokeColor) {
|
|
853
|
+
ctx.stroke();
|
|
854
|
+
}
|
|
856
855
|
}
|
|
856
|
+
return this;
|
|
857
857
|
};
|
|
858
858
|
DPolygon.prototype.clearPolygonOnCanvas = function (canvas) {
|
|
859
859
|
var ctx = canvas.getContext('2d');
|
|
@@ -1296,7 +1296,7 @@ var DPolygon = (function () {
|
|
|
1296
1296
|
var toPoint = Math.max(Math.min(start0, start1), Math.min(end0, end1));
|
|
1297
1297
|
var linePart = new DPolygon(buffer.removePart(fromPoint - 1, toPoint - fromPoint + 1));
|
|
1298
1298
|
buffer.unshift(buffer.pop());
|
|
1299
|
-
return [linePart, buffer];
|
|
1299
|
+
return [linePart.reverse(), buffer];
|
|
1300
1300
|
};
|
|
1301
1301
|
DPolygon.prototype.bezier = function (step) {
|
|
1302
1302
|
if (step === void 0) { step = 0.1; }
|
package/dist/esm/index.js
CHANGED
|
@@ -7,7 +7,4 @@ export * from './FastSearch';
|
|
|
7
7
|
export * from './TraceMatrix';
|
|
8
8
|
export * from './DPolygonLoop';
|
|
9
9
|
export * from './DPlane';
|
|
10
|
-
export { gaussianElimination, createCanvas, createArray, createMatrix, isDefAndNotNull } from './utils';
|
|
11
|
-
export var DGeo = {
|
|
12
|
-
DEBUG: false
|
|
13
|
-
};
|
|
10
|
+
export { gaussianElimination, createCanvas, createArray, createMatrix, isDefAndNotNull, DGeo } from './utils';
|
package/dist/esm/utils.js
CHANGED
|
@@ -23,8 +23,10 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
23
23
|
}
|
|
24
24
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
25
25
|
};
|
|
26
|
-
import { DGeo } from './index';
|
|
27
26
|
import { DPoint } from './DPoint';
|
|
27
|
+
export var DGeo = {
|
|
28
|
+
DEBUG: false
|
|
29
|
+
};
|
|
28
30
|
export var warn = function () {
|
|
29
31
|
var args = [];
|
|
30
32
|
for (var _i = 0; _i < arguments.length; _i++) {
|