@joint/core 4.2.0-alpha.0 → 4.2.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/README.md +3 -1
- package/dist/geometry.js +2 -2
- package/dist/geometry.min.js +3 -3
- package/dist/joint.d.ts +595 -198
- package/dist/joint.js +3895 -1304
- package/dist/joint.min.js +3 -3
- package/dist/joint.nowrap.js +3895 -1304
- package/dist/joint.nowrap.min.js +3 -3
- package/dist/vectorizer.js +21 -8
- package/dist/vectorizer.min.js +3 -3
- package/dist/version.mjs +1 -1
- package/package.json +13 -13
- package/src/V/index.mjs +20 -5
- package/src/alg/Deque.mjs +126 -0
- package/src/cellTools/Boundary.mjs +15 -13
- package/src/cellTools/Button.mjs +7 -5
- package/src/cellTools/Control.mjs +37 -14
- package/src/cellTools/HoverConnect.mjs +5 -1
- package/src/cellTools/helpers.mjs +44 -3
- package/src/config/index.mjs +11 -1
- package/src/dia/Cell.mjs +96 -83
- package/src/dia/CellCollection.mjs +136 -0
- package/src/dia/CellView.mjs +6 -0
- package/src/dia/Element.mjs +6 -5
- package/src/dia/ElementView.mjs +2 -1
- package/src/dia/Graph.mjs +610 -317
- package/src/dia/GraphLayer.mjs +53 -0
- package/src/dia/GraphLayerCollection.mjs +313 -0
- package/src/dia/GraphLayerView.mjs +128 -0
- package/src/dia/GraphLayersController.mjs +166 -0
- package/src/dia/GraphTopologyIndex.mjs +222 -0
- package/src/dia/{layers/GridLayer.mjs → GridLayerView.mjs} +23 -16
- package/src/dia/HighlighterView.mjs +22 -0
- package/src/dia/{PaperLayer.mjs → LayerView.mjs} +52 -17
- package/src/dia/LegacyGraphLayerView.mjs +14 -0
- package/src/dia/LinkView.mjs +118 -98
- package/src/dia/Paper.mjs +1441 -620
- package/src/dia/ToolView.mjs +4 -0
- package/src/dia/ToolsView.mjs +14 -5
- package/src/dia/attributes/text.mjs +4 -2
- package/src/dia/index.mjs +6 -1
- package/src/dia/ports.mjs +213 -84
- package/src/dia/symbols.mjs +24 -0
- package/src/elementTools/HoverConnect.mjs +14 -8
- package/src/env/index.mjs +6 -3
- package/src/layout/ports/port.mjs +30 -15
- package/src/layout/ports/portLabel.mjs +1 -1
- package/src/mvc/Collection.mjs +19 -19
- package/src/mvc/Model.mjs +13 -10
- package/src/mvc/View.mjs +4 -0
- package/src/mvc/ViewBase.mjs +1 -1
- package/types/geometry.d.ts +64 -60
- package/types/joint.d.ts +520 -137
- package/types/vectorizer.d.ts +11 -1
|
@@ -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
|
-
|
package/src/mvc/Collection.mjs
CHANGED
|
@@ -193,7 +193,7 @@ assign(Collection.prototype, Events, {
|
|
|
193
193
|
for (i = 0; i < toAdd.length; i++) {
|
|
194
194
|
if (at != null) options.index = at + i;
|
|
195
195
|
model = toAdd[i];
|
|
196
|
-
model.trigger('add', model, this, options);
|
|
196
|
+
model.trigger(model.eventPrefix + 'add', model, this, options);
|
|
197
197
|
}
|
|
198
198
|
if (sort || orderChanged) this.trigger('sort', this, options);
|
|
199
199
|
if (toAdd.length || toRemove.length || toMerge.length) {
|
|
@@ -257,9 +257,9 @@ assign(Collection.prototype, Events, {
|
|
|
257
257
|
// properties, or an attributes object that is transformed through modelId.
|
|
258
258
|
get: function(obj) {
|
|
259
259
|
if (obj == null) return void 0;
|
|
260
|
-
return this._byId
|
|
261
|
-
|
|
262
|
-
|
|
260
|
+
return this._byId.get(obj) ||
|
|
261
|
+
this._byId.get(this.modelId(this._isModel(obj) ? obj.attributes : obj, obj.idAttribute)) ||
|
|
262
|
+
obj.cid && this._byId.get(obj.cid);
|
|
263
263
|
},
|
|
264
264
|
|
|
265
265
|
// Returns `true` if the model is in the collection.
|
|
@@ -304,7 +304,7 @@ assign(Collection.prototype, Events, {
|
|
|
304
304
|
|
|
305
305
|
// Define how to uniquely identify models in the collection.
|
|
306
306
|
modelId: function(attrs, idAttribute) {
|
|
307
|
-
return attrs[idAttribute || this.model.prototype
|
|
307
|
+
return attrs[idAttribute || this.model.prototype?.idAttribute || 'id'];
|
|
308
308
|
},
|
|
309
309
|
|
|
310
310
|
// Get an iterator of all models in this collection.
|
|
@@ -375,18 +375,18 @@ assign(Collection.prototype, Events, {
|
|
|
375
375
|
_reset: function() {
|
|
376
376
|
this.length = 0;
|
|
377
377
|
this.models = [];
|
|
378
|
-
this._byId =
|
|
378
|
+
this._byId = new Map();
|
|
379
379
|
},
|
|
380
380
|
|
|
381
381
|
// Prepare a hash of attributes (or other model) to be added to this
|
|
382
382
|
// collection.
|
|
383
383
|
_prepareModel: function(attrs, options) {
|
|
384
384
|
if (this._isModel(attrs)) {
|
|
385
|
-
if (!attrs.collection) attrs.collection = this;
|
|
385
|
+
if (!options.dry && !attrs.collection) attrs.collection = this;
|
|
386
386
|
return attrs;
|
|
387
387
|
}
|
|
388
388
|
options = options ? clone(options) : {};
|
|
389
|
-
options.collection = this;
|
|
389
|
+
if (!options.dry) options.collection = this;
|
|
390
390
|
|
|
391
391
|
var model;
|
|
392
392
|
if (this.model.prototype) {
|
|
@@ -414,13 +414,13 @@ assign(Collection.prototype, Events, {
|
|
|
414
414
|
|
|
415
415
|
// Remove references before triggering 'remove' event to prevent an
|
|
416
416
|
// infinite loop. #3693
|
|
417
|
-
|
|
417
|
+
this._byId.delete(model.cid);
|
|
418
418
|
var id = this.modelId(model.attributes, model.idAttribute);
|
|
419
|
-
if (id != null)
|
|
419
|
+
if (id != null)this._byId.delete(id);
|
|
420
420
|
|
|
421
421
|
if (!options.silent) {
|
|
422
422
|
options.index = index;
|
|
423
|
-
model.trigger('remove', model, this, options);
|
|
423
|
+
model.trigger(model.eventPrefix + 'remove', model, this, options);
|
|
424
424
|
}
|
|
425
425
|
|
|
426
426
|
removed.push(model);
|
|
@@ -438,18 +438,18 @@ assign(Collection.prototype, Events, {
|
|
|
438
438
|
|
|
439
439
|
// Internal method to create a model's ties to a collection.
|
|
440
440
|
_addReference: function(model, options) {
|
|
441
|
-
this._byId
|
|
441
|
+
this._byId.set(model.cid, model);
|
|
442
442
|
var id = this.modelId(model.attributes, model.idAttribute);
|
|
443
|
-
if (id != null) this._byId
|
|
443
|
+
if (id != null) this._byId.set(id, model);
|
|
444
444
|
model.on('all', this._onModelEvent, this);
|
|
445
445
|
},
|
|
446
446
|
|
|
447
447
|
// Internal method to sever a model's ties to a collection.
|
|
448
448
|
_removeReference: function(model, options) {
|
|
449
|
-
|
|
449
|
+
this._byId.delete(model.cid);
|
|
450
450
|
var id = this.modelId(model.attributes, model.idAttribute);
|
|
451
|
-
if (id != null)
|
|
452
|
-
if (this === model.collection) delete model.collection;
|
|
451
|
+
if (id != null) this._byId.delete(id);
|
|
452
|
+
if (!options.dry && this === model.collection) delete model.collection;
|
|
453
453
|
model.off('all', this._onModelEvent, this);
|
|
454
454
|
},
|
|
455
455
|
|
|
@@ -459,12 +459,12 @@ assign(Collection.prototype, Events, {
|
|
|
459
459
|
// in other collections are ignored.
|
|
460
460
|
_onModelEvent: function(event, model, collection, options) {
|
|
461
461
|
if (model) {
|
|
462
|
-
if ((event === 'add' || event === 'remove') && collection !== this) return;
|
|
462
|
+
if ((event === model.eventPrefix + 'add' || event === model.eventPrefix + 'remove') && collection !== this) return;
|
|
463
463
|
if (event === 'changeId') {
|
|
464
464
|
var prevId = this.modelId(model.previousAttributes(), model.idAttribute);
|
|
465
465
|
var id = this.modelId(model.attributes, model.idAttribute);
|
|
466
|
-
if (prevId != null)
|
|
467
|
-
if (id != null) this._byId
|
|
466
|
+
if (prevId != null) this._byId.delete(prevId);
|
|
467
|
+
if (id != null) this._byId.set(id, model);
|
|
468
468
|
}
|
|
469
469
|
}
|
|
470
470
|
this.trigger.apply(this, arguments);
|
package/src/mvc/Model.mjs
CHANGED
|
@@ -25,17 +25,12 @@ import {
|
|
|
25
25
|
export var Model = function(attributes, options) {
|
|
26
26
|
var attrs = attributes || {};
|
|
27
27
|
options || (options = {});
|
|
28
|
+
this.eventPrefix = options.eventPrefix || '';
|
|
28
29
|
this.preinitialize.apply(this, arguments);
|
|
29
30
|
this.cid = uniqueId(this.cidPrefix);
|
|
30
31
|
this.attributes = {};
|
|
31
32
|
if (options.collection) this.collection = options.collection;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
// Just _.defaults would work fine, but the additional _.extends
|
|
35
|
-
// is in there for historical reasons. See #3843.
|
|
36
|
-
attrs = defaults(assign({}, attributeDefaults, attrs), attributeDefaults);
|
|
37
|
-
|
|
38
|
-
this.set(attrs, options);
|
|
33
|
+
this._setDefaults(attrs, options);
|
|
39
34
|
this.changed = {};
|
|
40
35
|
this.initialize.apply(this, arguments);
|
|
41
36
|
};
|
|
@@ -137,14 +132,14 @@ assign(Model.prototype, Events, {
|
|
|
137
132
|
if (this.idAttribute in attrs) {
|
|
138
133
|
var prevId = this.id;
|
|
139
134
|
this.id = this.get(this.idAttribute);
|
|
140
|
-
this.trigger('changeId', this, prevId, options);
|
|
135
|
+
this.trigger(this.eventPrefix + 'changeId', this, prevId, options);
|
|
141
136
|
}
|
|
142
137
|
|
|
143
138
|
// Trigger all relevant attribute changes.
|
|
144
139
|
if (!silent) {
|
|
145
140
|
if (changes.length) this._pending = options;
|
|
146
141
|
for (var i = 0; i < changes.length; i++) {
|
|
147
|
-
this.trigger('change:' + changes[i], this, current[changes[i]], options);
|
|
142
|
+
this.trigger(this.eventPrefix + 'change:' + changes[i], this, current[changes[i]], options);
|
|
148
143
|
}
|
|
149
144
|
}
|
|
150
145
|
|
|
@@ -155,7 +150,7 @@ assign(Model.prototype, Events, {
|
|
|
155
150
|
while (this._pending) {
|
|
156
151
|
options = this._pending;
|
|
157
152
|
this._pending = false;
|
|
158
|
-
this.trigger('change', this, options);
|
|
153
|
+
this.trigger(this.eventPrefix + 'change', this, options);
|
|
159
154
|
}
|
|
160
155
|
}
|
|
161
156
|
this._pending = false;
|
|
@@ -235,6 +230,14 @@ assign(Model.prototype, Events, {
|
|
|
235
230
|
if (!error) return true;
|
|
236
231
|
this.trigger('invalid', this, error, assign(options, { validationError: error }));
|
|
237
232
|
return false;
|
|
233
|
+
},
|
|
234
|
+
|
|
235
|
+
_setDefaults: function(ctorAttributes, options) {
|
|
236
|
+
const attributeDefaults = result(this, 'defaults');
|
|
237
|
+
// Just _.defaults would work fine, but the additional _.extends
|
|
238
|
+
// is in there for historical reasons. See #3843.
|
|
239
|
+
const attributes = defaults(assign({}, attributeDefaults, ctorAttributes), attributeDefaults);
|
|
240
|
+
this.set(attributes, options);
|
|
238
241
|
}
|
|
239
242
|
|
|
240
243
|
});
|
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/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,7 +679,7 @@ export namespace g {
|
|
|
675
679
|
|
|
676
680
|
moveAndExpand(r: PlainRect): this;
|
|
677
681
|
|
|
678
|
-
moveAroundPoint(origin: PlainPoint
|
|
682
|
+
moveAroundPoint(origin: PlainPoint, angle: number): this;
|
|
679
683
|
|
|
680
684
|
normalize(): this;
|
|
681
685
|
|
|
@@ -684,7 +688,7 @@ export namespace g {
|
|
|
684
688
|
|
|
685
689
|
origin(): Point;
|
|
686
690
|
|
|
687
|
-
pointNearestToPoint(point:
|
|
691
|
+
pointNearestToPoint(point: PointInit): Point;
|
|
688
692
|
|
|
689
693
|
rightLine(): Line;
|
|
690
694
|
|
|
@@ -692,9 +696,9 @@ export namespace g {
|
|
|
692
696
|
|
|
693
697
|
round(precision?: number): this;
|
|
694
698
|
|
|
695
|
-
scale(sx: number, sy: number, origin?:
|
|
699
|
+
scale(sx: number, sy: number, origin?: PointInit): this;
|
|
696
700
|
|
|
697
|
-
sideNearestToPoint(point:
|
|
701
|
+
sideNearestToPoint(point: PointInit): RectangleSide;
|
|
698
702
|
|
|
699
703
|
snapToGrid(gx: number, gy?: number): this;
|
|
700
704
|
|
|
@@ -734,24 +738,24 @@ export namespace g {
|
|
|
734
738
|
p3: Point;
|
|
735
739
|
}
|
|
736
740
|
|
|
737
|
-
export function curveThroughPoints(points: PlainPoint[]
|
|
741
|
+
export function curveThroughPoints(points: PlainPoint[]): string[];
|
|
738
742
|
|
|
739
|
-
export function getCurveControlPoints(points: PlainPoint[]
|
|
743
|
+
export function getCurveControlPoints(points: PlainPoint[]): [Point[], Point[]];
|
|
740
744
|
|
|
741
745
|
export function getCurveDivider(
|
|
742
|
-
p0:
|
|
743
|
-
p1:
|
|
744
|
-
p2:
|
|
745
|
-
p3:
|
|
746
|
+
p0: PointInit,
|
|
747
|
+
p1: PointInit,
|
|
748
|
+
p2: PointInit,
|
|
749
|
+
p3: PointInit
|
|
746
750
|
): (t: number) => [IBezierCurve, IBezierCurve];
|
|
747
751
|
|
|
748
752
|
export function getFirstControlPoints(rhs: number[]): number[];
|
|
749
753
|
|
|
750
754
|
export function getInversionSolver(
|
|
751
|
-
p0:
|
|
752
|
-
p1:
|
|
753
|
-
p2:
|
|
754
|
-
p3:
|
|
755
|
+
p0: PointInit,
|
|
756
|
+
p1: PointInit,
|
|
757
|
+
p2: PointInit,
|
|
758
|
+
p3: PointInit
|
|
755
759
|
): (p: PlainPoint) => number;
|
|
756
760
|
}
|
|
757
761
|
|