@joint/core 4.1.3 → 4.2.0-alpha.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/README.md +4 -2
- package/dist/geometry.js +129 -124
- package/dist/geometry.min.js +4 -3
- package/dist/joint.d.ts +352 -160
- package/dist/joint.js +3654 -2191
- package/dist/joint.min.js +4 -3
- package/dist/joint.nowrap.js +3653 -2188
- package/dist/joint.nowrap.min.js +4 -3
- package/dist/vectorizer.js +489 -279
- package/dist/vectorizer.min.js +4 -3
- package/dist/version.mjs +1 -1
- package/package.json +33 -27
- package/src/V/create.mjs +51 -0
- package/src/V/index.mjs +89 -159
- package/src/V/namespace.mjs +9 -0
- package/src/V/transform.mjs +183 -0
- package/src/V/traverse.mjs +16 -0
- package/src/alg/Deque.mjs +126 -0
- package/src/anchors/index.mjs +140 -33
- package/src/cellTools/Boundary.mjs +15 -13
- package/src/cellTools/Button.mjs +7 -5
- package/src/cellTools/Control.mjs +38 -15
- package/src/cellTools/HoverConnect.mjs +5 -1
- package/src/cellTools/helpers.mjs +44 -3
- package/src/config/index.mjs +8 -0
- package/src/connectionPoints/index.mjs +24 -9
- package/src/connectionStrategies/index.mjs +1 -1
- package/src/connectors/jumpover.mjs +1 -1
- package/src/dia/Cell.mjs +32 -12
- package/src/dia/CellView.mjs +53 -38
- package/src/dia/Element.mjs +81 -35
- package/src/dia/ElementView.mjs +2 -1
- package/src/dia/HighlighterView.mjs +54 -11
- package/src/dia/LinkView.mjs +118 -98
- package/src/dia/Paper.mjs +831 -231
- package/src/dia/PaperLayer.mjs +9 -2
- package/src/dia/ToolView.mjs +4 -0
- package/src/dia/ToolsView.mjs +12 -3
- package/src/dia/attributes/text.mjs +16 -5
- package/src/dia/layers/GridLayer.mjs +5 -0
- package/src/dia/ports.mjs +344 -111
- package/src/elementTools/HoverConnect.mjs +14 -8
- package/src/env/index.mjs +7 -4
- package/src/g/rect.mjs +7 -0
- package/src/highlighters/stroke.mjs +1 -1
- package/src/layout/ports/port.mjs +30 -15
- package/src/layout/ports/portLabel.mjs +1 -1
- package/src/linkAnchors/index.mjs +2 -2
- package/src/linkTools/Anchor.mjs +2 -2
- package/src/linkTools/Vertices.mjs +4 -6
- package/src/mvc/View.mjs +4 -0
- package/src/mvc/ViewBase.mjs +1 -1
- package/src/util/util.mjs +1 -1
- package/src/util/utilHelpers.mjs +2 -0
- package/types/geometry.d.ts +65 -59
- package/types/joint.d.ts +278 -102
- package/types/vectorizer.d.ts +11 -1
- package/src/V/annotation.mjs +0 -0
package/src/g/rect.mjs
CHANGED
|
@@ -369,6 +369,13 @@ Rect.prototype = {
|
|
|
369
369
|
return this;
|
|
370
370
|
},
|
|
371
371
|
|
|
372
|
+
moveAroundPoint: function(origin, angle) {
|
|
373
|
+
const newCenter = this.center().rotate(origin, angle);
|
|
374
|
+
this.x = newCenter.x - this.width / 2;
|
|
375
|
+
this.y = newCenter.y - this.height / 2;
|
|
376
|
+
return this;
|
|
377
|
+
},
|
|
378
|
+
|
|
372
379
|
// Normalize the rectangle; i.e., make it so that it has a non-negative width and height.
|
|
373
380
|
// If width < 0 the function swaps the left and right corners,
|
|
374
381
|
// and it swaps the top and bottom corners if height < 0
|
|
@@ -35,7 +35,7 @@ export const stroke = HighlighterView.extend({
|
|
|
35
35
|
d = d.substr(0, secondSubpathIndex);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
} catch
|
|
38
|
+
} catch {
|
|
39
39
|
// Failed to get path data from magnet element.
|
|
40
40
|
// Draw a rectangle around the node instead.
|
|
41
41
|
const nodeBBox = cellView.getNodeBoundingRect(node);
|
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
import * as g from '../../g/index.mjs';
|
|
2
2
|
import * as util from '../../util/index.mjs';
|
|
3
3
|
|
|
4
|
+
function parseCoordinate(coordinate, dimension, bbox, value) {
|
|
5
|
+
|
|
6
|
+
if (util.isPercentage(value)) {
|
|
7
|
+
return parseFloat(value) / 100 * bbox[dimension];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
if (util.isCalcExpression(value)) {
|
|
11
|
+
return Number(util.evalCalcExpression(value, bbox));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (typeof value === 'string') {
|
|
15
|
+
const num = Number(value);
|
|
16
|
+
if (isNaN(num)) {
|
|
17
|
+
throw new TypeError(
|
|
18
|
+
`Cannot convert port coordinate ${coordinate}: "${value}" to a number`
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
return num;
|
|
22
|
+
}
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
|
|
4
26
|
function portTransformAttrs(point, angle, opt) {
|
|
5
27
|
|
|
6
28
|
var trans = point.toJSON();
|
|
@@ -52,20 +74,14 @@ function ellipseLayout(ports, elBBox, startAngle, stepFn) {
|
|
|
52
74
|
});
|
|
53
75
|
}
|
|
54
76
|
|
|
55
|
-
|
|
56
77
|
function argTransform(bbox, args) {
|
|
57
78
|
let { x, y, angle } = args;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
y = parseFloat(y) / 100 * bbox.height;
|
|
65
|
-
} else if (util.isCalcExpression(y)) {
|
|
66
|
-
y = Number(util.evalCalcExpression(y, bbox));
|
|
67
|
-
}
|
|
68
|
-
return { x, y, angle };
|
|
79
|
+
|
|
80
|
+
return {
|
|
81
|
+
x: parseCoordinate('x', 'width', bbox, x),
|
|
82
|
+
y: parseCoordinate('y', 'height', bbox, y),
|
|
83
|
+
angle
|
|
84
|
+
};
|
|
69
85
|
}
|
|
70
86
|
|
|
71
87
|
// Creates a point stored in arguments
|
|
@@ -74,14 +90,13 @@ function argPoint(bbox, args) {
|
|
|
74
90
|
return new g.Point(x || 0, y || 0);
|
|
75
91
|
}
|
|
76
92
|
|
|
77
|
-
|
|
78
93
|
/**
|
|
79
94
|
* @param {Array<Object>} ports
|
|
80
95
|
* @param {g.Rect} elBBox
|
|
81
96
|
* @param {Object=} opt opt Group options
|
|
82
97
|
* @returns {Array<g.Point>}
|
|
83
98
|
*/
|
|
84
|
-
export const absolute = function(ports, elBBox) {
|
|
99
|
+
export const absolute = function(ports, elBBox, opt) {
|
|
85
100
|
return ports.map(port => {
|
|
86
101
|
const transformation = argPoint(elBBox, port).round().toJSON();
|
|
87
102
|
transformation.angle = port.angle || 0;
|
|
@@ -90,6 +105,7 @@ export const absolute = function(ports, elBBox) {
|
|
|
90
105
|
};
|
|
91
106
|
|
|
92
107
|
/**
|
|
108
|
+
* @deprecated
|
|
93
109
|
* @param {Array<Object>} ports
|
|
94
110
|
* @param {g.Rect} elBBox
|
|
95
111
|
* @param {Object=} opt opt Group options
|
|
@@ -184,4 +200,3 @@ export const ellipse = function(ports, elBBox, opt) {
|
|
|
184
200
|
return (index + 0.5 - count / 2) * stepAngle;
|
|
185
201
|
});
|
|
186
202
|
};
|
|
187
|
-
|
|
@@ -40,7 +40,7 @@ function _connectionClosest(view, _magnet, refPoint, _opt) {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
export function resolveRef(fn) {
|
|
43
|
-
return function(view, magnet, ref, opt) {
|
|
43
|
+
return function(view, magnet, ref, opt, endType, linkView) {
|
|
44
44
|
if (ref instanceof Element) {
|
|
45
45
|
var refView = this.paper.findView(ref);
|
|
46
46
|
var refPoint;
|
|
@@ -55,7 +55,7 @@ export function resolveRef(fn) {
|
|
|
55
55
|
// Something went wrong
|
|
56
56
|
refPoint = new Point();
|
|
57
57
|
}
|
|
58
|
-
return fn.call(this, view, magnet, refPoint, opt);
|
|
58
|
+
return fn.call(this, view, magnet, refPoint, opt, endType, linkView);
|
|
59
59
|
}
|
|
60
60
|
return fn.apply(this, arguments);
|
|
61
61
|
};
|
package/src/linkTools/Anchor.mjs
CHANGED
|
@@ -118,7 +118,7 @@ const Anchor = ToolView.extend({
|
|
|
118
118
|
bbox = view.getNodeUnrotatedBBox(magnet);
|
|
119
119
|
angle = model.angle();
|
|
120
120
|
center = bbox.center();
|
|
121
|
-
if (angle) center.rotate(model.
|
|
121
|
+
if (angle) center.rotate(model.getCenter(), -angle);
|
|
122
122
|
// TODO: get the link's magnet rotation into account
|
|
123
123
|
}
|
|
124
124
|
bbox.inflate(padding);
|
|
@@ -185,7 +185,7 @@ const Anchor = ToolView.extend({
|
|
|
185
185
|
// snap coords within node bbox
|
|
186
186
|
var bbox = view.getNodeUnrotatedBBox(magnet);
|
|
187
187
|
var angle = model.angle();
|
|
188
|
-
var origin = model.
|
|
188
|
+
var origin = model.getCenter();
|
|
189
189
|
var rotatedCoords = coords.clone().rotate(origin, angle);
|
|
190
190
|
if (!bbox.containsPoint(rotatedCoords)) {
|
|
191
191
|
coords = bbox.pointNearestToPoint(rotatedCoords).rotate(origin, -angle);
|
|
@@ -221,18 +221,16 @@ export const Vertices = ToolView.extend({
|
|
|
221
221
|
onHandleChanged: function(_handle, evt) {
|
|
222
222
|
const { options, relatedView: linkView } = this;
|
|
223
223
|
if (options.vertexAdding) this.updatePath();
|
|
224
|
-
if (
|
|
225
|
-
linkView.
|
|
226
|
-
|
|
224
|
+
if (options.redundancyRemoval) {
|
|
225
|
+
const verticesRemoved = linkView.removeRedundantLinearVertices({ ui: true, tool: this.cid });
|
|
226
|
+
if (verticesRemoved) this.render();
|
|
227
227
|
}
|
|
228
|
-
var verticesRemoved = linkView.removeRedundantLinearVertices({ ui: true, tool: this.cid });
|
|
229
|
-
if (verticesRemoved) this.render();
|
|
230
228
|
this.blur();
|
|
231
229
|
linkView.model.stopBatch('vertex-move', { ui: true, tool: this.cid });
|
|
232
230
|
if (this.eventData(evt).vertexAdded) {
|
|
233
231
|
linkView.model.stopBatch('vertex-add', { ui: true, tool: this.cid });
|
|
234
232
|
}
|
|
235
|
-
|
|
233
|
+
const [normalizedEvt, x, y] = linkView.paper.getPointerArgs(evt);
|
|
236
234
|
if (!options.stopPropagation) linkView.notifyPointerup(normalizedEvt, x, y);
|
|
237
235
|
linkView.checkMouseleave(normalizedEvt);
|
|
238
236
|
},
|
package/src/mvc/View.mjs
CHANGED
|
@@ -18,8 +18,12 @@ export const View = ViewBase.extend({
|
|
|
18
18
|
|
|
19
19
|
DETACHABLE: true,
|
|
20
20
|
UPDATE_PRIORITY: 2,
|
|
21
|
+
|
|
22
|
+
/** @deprecated is no longer used (moved to Paper) */
|
|
21
23
|
FLAG_INSERT: 1<<30,
|
|
24
|
+
/** @deprecated is no longer used */
|
|
22
25
|
FLAG_REMOVE: 1<<29,
|
|
26
|
+
/** @deprecated is no longer used */
|
|
23
27
|
FLAG_INIT: 1<<28,
|
|
24
28
|
|
|
25
29
|
constructor: function(options) {
|
package/src/mvc/ViewBase.mjs
CHANGED
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
// Creating a ViewBase creates its initial element outside of the DOM,
|
|
25
25
|
// if an existing element is not provided...
|
|
26
26
|
export var ViewBase = function(options) {
|
|
27
|
-
this.cid = uniqueId('view');
|
|
27
|
+
this.cid = (options && options.cid) || uniqueId('view');
|
|
28
28
|
this.preinitialize.apply(this, arguments);
|
|
29
29
|
assign(this, pick(options, viewOptions));
|
|
30
30
|
this._ensureElement();
|
package/src/util/util.mjs
CHANGED
|
@@ -821,7 +821,7 @@ export const sanitizeHTML = function(html) {
|
|
|
821
821
|
const value = node.getAttribute(name);
|
|
822
822
|
// Remove attribute names that start with "on" (e.g. onload, onerror...).
|
|
823
823
|
// Remove attribute values that start with "javascript:" pseudo protocol (e.g. `href="javascript:alert(1)"`).
|
|
824
|
-
if (name.startsWith('on') || value.startsWith('javascript:' || value.startsWith('data:') || value.startsWith('vbscript:'))
|
|
824
|
+
if (name.startsWith('on') || value.startsWith('javascript:') || value.startsWith('data:') || value.startsWith('vbscript:')) {
|
|
825
825
|
node.removeAttribute(name);
|
|
826
826
|
}
|
|
827
827
|
});
|
package/src/util/utilHelpers.mjs
CHANGED
|
@@ -105,6 +105,7 @@ const rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])';
|
|
|
105
105
|
const rsSeq = rsOptVar + reOptMod + rsOptJoin;
|
|
106
106
|
const rsEmoji = `(?:${[rsDingbat, rsRegional, rsSurrPair].join('|')})${rsSeq}`;
|
|
107
107
|
|
|
108
|
+
// eslint-disable-next-line no-misleading-character-class
|
|
108
109
|
const reUnicodeWords = RegExp([
|
|
109
110
|
`${rsUpper}?${rsLower}+${rsOptContrLower}(?=${[rsBreak, rsUpper, '$'].join('|')})`,
|
|
110
111
|
`${rsMiscUpper}+${rsOptContrUpper}(?=${[rsBreak, rsUpper + rsMiscLower, '$'].join('|')})`,
|
|
@@ -130,6 +131,7 @@ const rsNonAstralCombo = `${rsNonAstral}${rsCombo}?`;
|
|
|
130
131
|
const rsSymbol = `(?:${[rsNonAstralCombo, rsCombo, rsRegional, rsSurrPair, rsAstral].join('|')})`;
|
|
131
132
|
|
|
132
133
|
// Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode)
|
|
134
|
+
// eslint-disable-next-line no-misleading-character-class
|
|
133
135
|
const reUnicode = RegExp(`${rsFitz}(?=${rsFitz})|${rsSymbol + rsSeq}`, 'g');
|
|
134
136
|
|
|
135
137
|
const reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/;
|
package/types/geometry.d.ts
CHANGED
|
@@ -12,12 +12,16 @@ export namespace g {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export type Shape = Path | Point | Line | Polyline | Polygon | Rect | Ellipse;
|
|
15
|
+
|
|
15
16
|
export interface PlainPoint {
|
|
16
17
|
|
|
17
18
|
x: number;
|
|
18
19
|
y: number;
|
|
19
20
|
}
|
|
20
21
|
|
|
22
|
+
/** Can be understood by `g.Point` constructor */
|
|
23
|
+
export type PointInit = Partial<PlainPoint> | string;
|
|
24
|
+
|
|
21
25
|
export interface PlainRect {
|
|
22
26
|
|
|
23
27
|
x: number;
|
|
@@ -77,15 +81,15 @@ export namespace g {
|
|
|
77
81
|
|
|
78
82
|
clone(): Segment;
|
|
79
83
|
|
|
80
|
-
closestPoint(p:
|
|
84
|
+
closestPoint(p: PlainPoint, opt?: SubdivisionsOpt): Point;
|
|
81
85
|
|
|
82
|
-
closestPointLength(p:
|
|
86
|
+
closestPointLength(p: PlainPoint, opt?: SubdivisionsOpt): number;
|
|
83
87
|
|
|
84
|
-
closestPointNormalizedLength(p:
|
|
88
|
+
closestPointNormalizedLength(p: PlainPoint, opt?: SubdivisionsOpt): number;
|
|
85
89
|
|
|
86
|
-
closestPointT(p:
|
|
90
|
+
closestPointT(p: PlainPoint): number;
|
|
87
91
|
|
|
88
|
-
closestPointTangent(p:
|
|
92
|
+
closestPointTangent(p: PlainPoint): Line | null;
|
|
89
93
|
|
|
90
94
|
divideAt(ratio: number, opt?: SubdivisionsOpt): [Segment, Segment];
|
|
91
95
|
|
|
@@ -111,7 +115,7 @@ export namespace g {
|
|
|
111
115
|
|
|
112
116
|
round(precision?: number): this;
|
|
113
117
|
|
|
114
|
-
scale(sx: number, sy: number, origin?:
|
|
118
|
+
scale(sx: number, sy: number, origin?: PointInit): this;
|
|
115
119
|
|
|
116
120
|
tangentAt(ratio: number): Line | null;
|
|
117
121
|
|
|
@@ -168,7 +172,7 @@ export namespace g {
|
|
|
168
172
|
end: Point;
|
|
169
173
|
type: types.Curve;
|
|
170
174
|
|
|
171
|
-
constructor(p1:
|
|
175
|
+
constructor(p1: PointInit, p2: PointInit, p3: PointInit, p4: PointInit);
|
|
172
176
|
constructor(curve: Curve);
|
|
173
177
|
|
|
174
178
|
bbox(): Rect;
|
|
@@ -216,7 +220,7 @@ export namespace g {
|
|
|
216
220
|
|
|
217
221
|
round(precision?: number): this;
|
|
218
222
|
|
|
219
|
-
scale(sx: number, sy: number, origin?:
|
|
223
|
+
scale(sx: number, sy: number, origin?: PointInit): this;
|
|
220
224
|
|
|
221
225
|
tangentAt(ratio: number, opt?: SubdivisionsOpt): Line | null;
|
|
222
226
|
|
|
@@ -248,7 +252,7 @@ export namespace g {
|
|
|
248
252
|
b: number;
|
|
249
253
|
type: types.Ellipse;
|
|
250
254
|
|
|
251
|
-
constructor(center:
|
|
255
|
+
constructor(center: PointInit, a: number, b: number);
|
|
252
256
|
constructor(ellipse: Ellipse);
|
|
253
257
|
|
|
254
258
|
bbox(): Rect;
|
|
@@ -265,7 +269,7 @@ export namespace g {
|
|
|
265
269
|
|
|
266
270
|
intersectionWithLine(l: Line): Point[] | null;
|
|
267
271
|
|
|
268
|
-
intersectionWithLineFromCenterToPoint(p:
|
|
272
|
+
intersectionWithLineFromCenterToPoint(p: PointInit, angle?: number): Point;
|
|
269
273
|
|
|
270
274
|
normalizedDistance(point: PlainPoint): number;
|
|
271
275
|
|
|
@@ -284,7 +288,7 @@ export namespace g {
|
|
|
284
288
|
end: Point;
|
|
285
289
|
type: types.Line;
|
|
286
290
|
|
|
287
|
-
constructor(p1:
|
|
291
|
+
constructor(p1: PointInit, p2: PointInit);
|
|
288
292
|
constructor(line: Line);
|
|
289
293
|
constructor();
|
|
290
294
|
|
|
@@ -298,13 +302,13 @@ export namespace g {
|
|
|
298
302
|
|
|
299
303
|
parallel(distance: number): Line;
|
|
300
304
|
|
|
301
|
-
closestPoint(p:
|
|
305
|
+
closestPoint(p: PointInit): Point;
|
|
302
306
|
|
|
303
|
-
closestPointLength(p:
|
|
307
|
+
closestPointLength(p: PointInit): number;
|
|
304
308
|
|
|
305
|
-
closestPointNormalizedLength(p:
|
|
309
|
+
closestPointNormalizedLength(p: PointInit): number;
|
|
306
310
|
|
|
307
|
-
closestPointTangent(p:
|
|
311
|
+
closestPointTangent(p: PointInit): Line | null;
|
|
308
312
|
|
|
309
313
|
containsPoint(p: PlainPoint): boolean;
|
|
310
314
|
|
|
@@ -332,13 +336,13 @@ export namespace g {
|
|
|
332
336
|
|
|
333
337
|
pointAtLength(length: number): Point;
|
|
334
338
|
|
|
335
|
-
pointOffset(p:
|
|
339
|
+
pointOffset(p: PointInit): number;
|
|
336
340
|
|
|
337
341
|
rotate(origin: PlainPoint, angle: number): this;
|
|
338
342
|
|
|
339
343
|
round(precision?: number): this;
|
|
340
344
|
|
|
341
|
-
scale(sx: number, sy: number, origin?:
|
|
345
|
+
scale(sx: number, sy: number, origin?: PointInit): this;
|
|
342
346
|
|
|
343
347
|
setLength(length: number): this;
|
|
344
348
|
|
|
@@ -377,13 +381,13 @@ export namespace g {
|
|
|
377
381
|
|
|
378
382
|
clone(): Path;
|
|
379
383
|
|
|
380
|
-
closestPoint(p:
|
|
384
|
+
closestPoint(p: PlainPoint, opt?: SegmentSubdivisionsOpt): Point | null;
|
|
381
385
|
|
|
382
|
-
closestPointLength(p:
|
|
386
|
+
closestPointLength(p: PlainPoint, opt?: SegmentSubdivisionsOpt): number;
|
|
383
387
|
|
|
384
|
-
closestPointNormalizedLength(p:
|
|
388
|
+
closestPointNormalizedLength(p: PlainPoint, opt?: SegmentSubdivisionsOpt): number;
|
|
385
389
|
|
|
386
|
-
closestPointTangent(p:
|
|
390
|
+
closestPointTangent(p: PlainPoint, opt?: SegmentSubdivisionsOpt): Line | null;
|
|
387
391
|
|
|
388
392
|
containsPoint(p: PlainPoint, opt?: SegmentSubdivisionsOpt): boolean;
|
|
389
393
|
|
|
@@ -419,7 +423,7 @@ export namespace g {
|
|
|
419
423
|
|
|
420
424
|
round(precision?: number): this;
|
|
421
425
|
|
|
422
|
-
scale(sx: number, sy: number, origin?:
|
|
426
|
+
scale(sx: number, sy: number, origin?: PointInit): this;
|
|
423
427
|
|
|
424
428
|
segmentAt(ratio: number, opt?: SegmentSubdivisionsOpt): Segment | null;
|
|
425
429
|
|
|
@@ -446,7 +450,7 @@ export namespace g {
|
|
|
446
450
|
|
|
447
451
|
validate(): this;
|
|
448
452
|
|
|
449
|
-
private closestPointT(p:
|
|
453
|
+
private closestPointT(p: PlainPoint, opt?: SegmentSubdivisionsOpt): PathT | null;
|
|
450
454
|
|
|
451
455
|
private lengthAtT(t: PathT, opt?: SegmentSubdivisionsOpt): number;
|
|
452
456
|
|
|
@@ -474,17 +478,17 @@ export namespace g {
|
|
|
474
478
|
type: types.Point;
|
|
475
479
|
|
|
476
480
|
constructor(x?: number, y?: number);
|
|
477
|
-
constructor(p:
|
|
481
|
+
constructor(p: PointInit);
|
|
478
482
|
|
|
479
|
-
chooseClosest(points:
|
|
483
|
+
chooseClosest(points: PointInit[]): Point | null;
|
|
480
484
|
|
|
481
485
|
adhereToRect(r: Rect): this;
|
|
482
486
|
|
|
483
487
|
angleBetween(p1: PlainPoint, p2: PlainPoint): number;
|
|
484
488
|
|
|
485
|
-
bearing(p:
|
|
489
|
+
bearing(p: PlainPoint): CardinalDirection;
|
|
486
490
|
|
|
487
|
-
changeInAngle(dx: number, dy: number, ref:
|
|
491
|
+
changeInAngle(dx: number, dy: number, ref: PointInit): number;
|
|
488
492
|
|
|
489
493
|
clone(): Point;
|
|
490
494
|
|
|
@@ -493,42 +497,42 @@ export namespace g {
|
|
|
493
497
|
difference(dx?: number, dy?: number): Point;
|
|
494
498
|
difference(p: PlainPoint): Point;
|
|
495
499
|
|
|
496
|
-
distance(p: PlainPoint
|
|
500
|
+
distance(p: PlainPoint): number;
|
|
497
501
|
|
|
498
502
|
dot(p: PlainPoint): number;
|
|
499
503
|
|
|
500
|
-
equals(p:
|
|
504
|
+
equals(p: PlainPoint): boolean;
|
|
501
505
|
|
|
502
|
-
lerp(p:
|
|
506
|
+
lerp(p: PlainPoint, t: number): Point;
|
|
503
507
|
|
|
504
508
|
magnitude(): number;
|
|
505
509
|
|
|
506
510
|
manhattanDistance(p: PlainPoint): number;
|
|
507
511
|
|
|
508
|
-
move(ref:
|
|
512
|
+
move(ref: PointInit, distance: number): this;
|
|
509
513
|
|
|
510
514
|
normalize(length: number): this;
|
|
511
515
|
|
|
512
516
|
offset(dx?: number, dy?: number): this;
|
|
513
517
|
offset(p: PlainPoint): this;
|
|
514
518
|
|
|
515
|
-
reflection(ref:
|
|
519
|
+
reflection(ref: PointInit): Point;
|
|
516
520
|
|
|
517
|
-
rotate(origin: PlainPoint
|
|
521
|
+
rotate(origin: PlainPoint, angle: number): this;
|
|
518
522
|
|
|
519
523
|
round(precision?: number): this;
|
|
520
524
|
|
|
521
|
-
scale(sx: number, sy: number, origin?:
|
|
525
|
+
scale(sx: number, sy: number, origin?: PointInit): this;
|
|
522
526
|
|
|
523
527
|
snapToGrid(gx: number, gy?: number): this;
|
|
524
528
|
|
|
525
|
-
squaredDistance(p: PlainPoint
|
|
529
|
+
squaredDistance(p: PlainPoint): number;
|
|
526
530
|
|
|
527
|
-
theta(p:
|
|
531
|
+
theta(p: PointInit): number;
|
|
528
532
|
|
|
529
533
|
toJSON(): PlainPoint;
|
|
530
534
|
|
|
531
|
-
toPolar(origin?:
|
|
535
|
+
toPolar(origin?: PointInit): this;
|
|
532
536
|
|
|
533
537
|
toString(): string;
|
|
534
538
|
|
|
@@ -542,7 +546,7 @@ export namespace g {
|
|
|
542
546
|
|
|
543
547
|
vectorAngle(p: PlainPoint): number;
|
|
544
548
|
|
|
545
|
-
static fromPolar(distance: number, angle: number, origin?:
|
|
549
|
+
static fromPolar(distance: number, angle: number, origin?: PointInit): Point;
|
|
546
550
|
|
|
547
551
|
static random(x1: number, x2: number, y1: number, y2: number): Point;
|
|
548
552
|
}
|
|
@@ -554,17 +558,17 @@ export namespace g {
|
|
|
554
558
|
|
|
555
559
|
constructor();
|
|
556
560
|
constructor(svgString: string);
|
|
557
|
-
constructor(points:
|
|
561
|
+
constructor(points: PointInit[]);
|
|
558
562
|
|
|
559
563
|
bbox(): Rect | null;
|
|
560
564
|
|
|
561
|
-
closestPoint(p: PlainPoint
|
|
565
|
+
closestPoint(p: PlainPoint): Point | null;
|
|
562
566
|
|
|
563
|
-
closestPointLength(p: PlainPoint
|
|
567
|
+
closestPointLength(p: PlainPoint): number;
|
|
564
568
|
|
|
565
|
-
closestPointNormalizedLength(p: PlainPoint
|
|
569
|
+
closestPointNormalizedLength(p: PlainPoint): number;
|
|
566
570
|
|
|
567
|
-
closestPointTangent(p: PlainPoint
|
|
571
|
+
closestPointTangent(p: PlainPoint): Line | null;
|
|
568
572
|
|
|
569
573
|
containsPoint(p: PlainPoint): boolean;
|
|
570
574
|
|
|
@@ -584,7 +588,7 @@ export namespace g {
|
|
|
584
588
|
|
|
585
589
|
round(precision?: number): this;
|
|
586
590
|
|
|
587
|
-
scale(sx: number, sy: number, origin?:
|
|
591
|
+
scale(sx: number, sy: number, origin?: PointInit): this;
|
|
588
592
|
|
|
589
593
|
simplify(opt?: { threshold?: number }): this;
|
|
590
594
|
|
|
@@ -649,7 +653,7 @@ export namespace g {
|
|
|
649
653
|
|
|
650
654
|
clone(): Rect;
|
|
651
655
|
|
|
652
|
-
containsPoint(p:
|
|
656
|
+
containsPoint(p: PointInit, opt?: StrictOpt): boolean;
|
|
653
657
|
|
|
654
658
|
containsRect(r: PlainRect): boolean;
|
|
655
659
|
|
|
@@ -663,7 +667,7 @@ export namespace g {
|
|
|
663
667
|
|
|
664
668
|
intersectionWithLine(l: Line): Point[] | null;
|
|
665
669
|
|
|
666
|
-
intersectionWithLineFromCenterToPoint(p:
|
|
670
|
+
intersectionWithLineFromCenterToPoint(p: PointInit, angle?: number): Point;
|
|
667
671
|
|
|
668
672
|
leftLine(): Line;
|
|
669
673
|
|
|
@@ -675,6 +679,8 @@ export namespace g {
|
|
|
675
679
|
|
|
676
680
|
moveAndExpand(r: PlainRect): this;
|
|
677
681
|
|
|
682
|
+
moveAroundPoint(origin: PlainPoint, angle: number): this;
|
|
683
|
+
|
|
678
684
|
normalize(): this;
|
|
679
685
|
|
|
680
686
|
offset(dx?: number, dy?: number): this;
|
|
@@ -682,7 +688,7 @@ export namespace g {
|
|
|
682
688
|
|
|
683
689
|
origin(): Point;
|
|
684
690
|
|
|
685
|
-
pointNearestToPoint(point:
|
|
691
|
+
pointNearestToPoint(point: PointInit): Point;
|
|
686
692
|
|
|
687
693
|
rightLine(): Line;
|
|
688
694
|
|
|
@@ -690,9 +696,9 @@ export namespace g {
|
|
|
690
696
|
|
|
691
697
|
round(precision?: number): this;
|
|
692
698
|
|
|
693
|
-
scale(sx: number, sy: number, origin?:
|
|
699
|
+
scale(sx: number, sy: number, origin?: PointInit): this;
|
|
694
700
|
|
|
695
|
-
sideNearestToPoint(point:
|
|
701
|
+
sideNearestToPoint(point: PointInit): RectangleSide;
|
|
696
702
|
|
|
697
703
|
snapToGrid(gx: number, gy?: number): this;
|
|
698
704
|
|
|
@@ -732,24 +738,24 @@ export namespace g {
|
|
|
732
738
|
p3: Point;
|
|
733
739
|
}
|
|
734
740
|
|
|
735
|
-
export function curveThroughPoints(points: PlainPoint[]
|
|
741
|
+
export function curveThroughPoints(points: PlainPoint[]): string[];
|
|
736
742
|
|
|
737
|
-
export function getCurveControlPoints(points: PlainPoint[]
|
|
743
|
+
export function getCurveControlPoints(points: PlainPoint[]): [Point[], Point[]];
|
|
738
744
|
|
|
739
745
|
export function getCurveDivider(
|
|
740
|
-
p0:
|
|
741
|
-
p1:
|
|
742
|
-
p2:
|
|
743
|
-
p3:
|
|
746
|
+
p0: PointInit,
|
|
747
|
+
p1: PointInit,
|
|
748
|
+
p2: PointInit,
|
|
749
|
+
p3: PointInit
|
|
744
750
|
): (t: number) => [IBezierCurve, IBezierCurve];
|
|
745
751
|
|
|
746
752
|
export function getFirstControlPoints(rhs: number[]): number[];
|
|
747
753
|
|
|
748
754
|
export function getInversionSolver(
|
|
749
|
-
p0:
|
|
750
|
-
p1:
|
|
751
|
-
p2:
|
|
752
|
-
p3:
|
|
755
|
+
p0: PointInit,
|
|
756
|
+
p1: PointInit,
|
|
757
|
+
p2: PointInit,
|
|
758
|
+
p3: PointInit
|
|
753
759
|
): (p: PlainPoint) => number;
|
|
754
760
|
}
|
|
755
761
|
|