@joint/core 4.0.0
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/LICENSE +376 -0
- package/README.md +49 -0
- package/dist/geometry.js +6486 -0
- package/dist/geometry.min.js +8 -0
- package/dist/joint.d.ts +5536 -0
- package/dist/joint.js +39629 -0
- package/dist/joint.min.js +8 -0
- package/dist/joint.nowrap.js +39626 -0
- package/dist/joint.nowrap.min.js +8 -0
- package/dist/vectorizer.js +9135 -0
- package/dist/vectorizer.min.js +8 -0
- package/dist/version.mjs +3 -0
- package/index.js +3 -0
- package/joint.mjs +27 -0
- package/package.json +192 -0
- package/src/V/annotation.mjs +0 -0
- package/src/V/index.mjs +2642 -0
- package/src/anchors/index.mjs +123 -0
- package/src/config/index.mjs +12 -0
- package/src/connectionPoints/index.mjs +202 -0
- package/src/connectionStrategies/index.mjs +73 -0
- package/src/connectors/curve.mjs +553 -0
- package/src/connectors/index.mjs +6 -0
- package/src/connectors/jumpover.mjs +452 -0
- package/src/connectors/normal.mjs +12 -0
- package/src/connectors/rounded.mjs +17 -0
- package/src/connectors/smooth.mjs +44 -0
- package/src/connectors/straight.mjs +110 -0
- package/src/dia/Cell.mjs +945 -0
- package/src/dia/CellView.mjs +1316 -0
- package/src/dia/Element.mjs +519 -0
- package/src/dia/ElementView.mjs +859 -0
- package/src/dia/Graph.mjs +1112 -0
- package/src/dia/HighlighterView.mjs +319 -0
- package/src/dia/Link.mjs +565 -0
- package/src/dia/LinkView.mjs +2207 -0
- package/src/dia/Paper.mjs +3171 -0
- package/src/dia/PaperLayer.mjs +75 -0
- package/src/dia/ToolView.mjs +69 -0
- package/src/dia/ToolsView.mjs +128 -0
- package/src/dia/attributes/calc.mjs +128 -0
- package/src/dia/attributes/connection.mjs +75 -0
- package/src/dia/attributes/defs.mjs +76 -0
- package/src/dia/attributes/eval.mjs +64 -0
- package/src/dia/attributes/index.mjs +69 -0
- package/src/dia/attributes/legacy.mjs +148 -0
- package/src/dia/attributes/offset.mjs +53 -0
- package/src/dia/attributes/props.mjs +30 -0
- package/src/dia/attributes/shape.mjs +92 -0
- package/src/dia/attributes/text.mjs +180 -0
- package/src/dia/index.mjs +13 -0
- package/src/dia/layers/GridLayer.mjs +176 -0
- package/src/dia/ports.mjs +874 -0
- package/src/elementTools/Control.mjs +153 -0
- package/src/elementTools/HoverConnect.mjs +37 -0
- package/src/elementTools/index.mjs +5 -0
- package/src/env/index.mjs +43 -0
- package/src/g/bezier.mjs +175 -0
- package/src/g/curve.mjs +956 -0
- package/src/g/ellipse.mjs +245 -0
- package/src/g/extend.mjs +64 -0
- package/src/g/geometry.helpers.mjs +58 -0
- package/src/g/index.mjs +17 -0
- package/src/g/intersection.mjs +511 -0
- package/src/g/line.bearing.mjs +30 -0
- package/src/g/line.length.mjs +5 -0
- package/src/g/line.mjs +356 -0
- package/src/g/line.squaredLength.mjs +10 -0
- package/src/g/path.mjs +2260 -0
- package/src/g/point.mjs +375 -0
- package/src/g/points.mjs +247 -0
- package/src/g/polygon.mjs +51 -0
- package/src/g/polyline.mjs +523 -0
- package/src/g/rect.mjs +556 -0
- package/src/g/types.mjs +10 -0
- package/src/highlighters/addClass.mjs +27 -0
- package/src/highlighters/index.mjs +5 -0
- package/src/highlighters/list.mjs +111 -0
- package/src/highlighters/mask.mjs +220 -0
- package/src/highlighters/opacity.mjs +17 -0
- package/src/highlighters/stroke.mjs +100 -0
- package/src/layout/index.mjs +4 -0
- package/src/layout/ports/port.mjs +188 -0
- package/src/layout/ports/portLabel.mjs +224 -0
- package/src/linkAnchors/index.mjs +76 -0
- package/src/linkTools/Anchor.mjs +235 -0
- package/src/linkTools/Arrowhead.mjs +103 -0
- package/src/linkTools/Boundary.mjs +48 -0
- package/src/linkTools/Button.mjs +121 -0
- package/src/linkTools/Connect.mjs +85 -0
- package/src/linkTools/HoverConnect.mjs +161 -0
- package/src/linkTools/Segments.mjs +393 -0
- package/src/linkTools/Vertices.mjs +253 -0
- package/src/linkTools/helpers.mjs +33 -0
- package/src/linkTools/index.mjs +8 -0
- package/src/mvc/Collection.mjs +560 -0
- package/src/mvc/Data.mjs +46 -0
- package/src/mvc/Dom/Dom.mjs +587 -0
- package/src/mvc/Dom/Event.mjs +130 -0
- package/src/mvc/Dom/animations.mjs +122 -0
- package/src/mvc/Dom/events.mjs +69 -0
- package/src/mvc/Dom/index.mjs +13 -0
- package/src/mvc/Dom/methods.mjs +392 -0
- package/src/mvc/Dom/props.mjs +77 -0
- package/src/mvc/Dom/vars.mjs +5 -0
- package/src/mvc/Events.mjs +337 -0
- package/src/mvc/Listener.mjs +33 -0
- package/src/mvc/Model.mjs +239 -0
- package/src/mvc/View.mjs +323 -0
- package/src/mvc/ViewBase.mjs +182 -0
- package/src/mvc/index.mjs +9 -0
- package/src/mvc/mvcUtils.mjs +90 -0
- package/src/polyfills/array.js +4 -0
- package/src/polyfills/base64.js +68 -0
- package/src/polyfills/index.mjs +5 -0
- package/src/polyfills/number.js +3 -0
- package/src/polyfills/string.js +3 -0
- package/src/polyfills/typedArray.js +47 -0
- package/src/routers/index.mjs +6 -0
- package/src/routers/manhattan.mjs +856 -0
- package/src/routers/metro.mjs +91 -0
- package/src/routers/normal.mjs +6 -0
- package/src/routers/oneSide.mjs +60 -0
- package/src/routers/orthogonal.mjs +323 -0
- package/src/routers/rightAngle.mjs +1056 -0
- package/src/shapes/index.mjs +3 -0
- package/src/shapes/standard.mjs +755 -0
- package/src/util/cloneCells.mjs +67 -0
- package/src/util/getRectPoint.mjs +65 -0
- package/src/util/index.mjs +5 -0
- package/src/util/svgTagTemplate.mjs +110 -0
- package/src/util/util.mjs +1754 -0
- package/src/util/utilHelpers.mjs +2402 -0
- package/src/util/wrappers.mjs +56 -0
- package/types/geometry.d.ts +815 -0
- package/types/index.d.ts +53 -0
- package/types/joint.d.ts +4391 -0
- package/types/joint.head.d.ts +12 -0
- package/types/vectorizer.d.ts +327 -0
package/src/g/line.mjs
ADDED
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
import { Point } from './point.mjs';
|
|
2
|
+
import { Rect } from './rect.mjs';
|
|
3
|
+
import { bearing } from './line.bearing.mjs';
|
|
4
|
+
import { squaredLength } from './line.squaredLength.mjs';
|
|
5
|
+
import { length } from './line.length.mjs';
|
|
6
|
+
import { types } from './types.mjs';
|
|
7
|
+
|
|
8
|
+
const {
|
|
9
|
+
max,
|
|
10
|
+
min
|
|
11
|
+
} = Math;
|
|
12
|
+
|
|
13
|
+
export const Line = function(p1, p2) {
|
|
14
|
+
|
|
15
|
+
if (!(this instanceof Line)) {
|
|
16
|
+
return new Line(p1, p2);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (p1 instanceof Line) {
|
|
20
|
+
return new Line(p1.start, p1.end);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
this.start = new Point(p1);
|
|
24
|
+
this.end = new Point(p2);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
Line.prototype = {
|
|
28
|
+
|
|
29
|
+
type: types.Line,
|
|
30
|
+
|
|
31
|
+
// @returns the angle of incline of the line.
|
|
32
|
+
angle: function() {
|
|
33
|
+
|
|
34
|
+
var horizontalPoint = new Point(this.start.x + 1, this.start.y);
|
|
35
|
+
return this.start.angleBetween(this.end, horizontalPoint);
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
bbox: function() {
|
|
39
|
+
|
|
40
|
+
var left = min(this.start.x, this.end.x);
|
|
41
|
+
var top = min(this.start.y, this.end.y);
|
|
42
|
+
var right = max(this.start.x, this.end.x);
|
|
43
|
+
var bottom = max(this.start.y, this.end.y);
|
|
44
|
+
|
|
45
|
+
return new Rect(left, top, (right - left), (bottom - top));
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
// @return the bearing (cardinal direction) of the line. For example N, W, or SE.
|
|
49
|
+
// @returns {String} One of the following bearings : NE, E, SE, S, SW, W, NW, N.
|
|
50
|
+
bearing: function() {
|
|
51
|
+
return bearing(this.start, this.end);
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
clone: function() {
|
|
55
|
+
|
|
56
|
+
return new Line(this.start, this.end);
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
// @return {point} the closest point on the line to point `p`
|
|
60
|
+
closestPoint: function(p) {
|
|
61
|
+
|
|
62
|
+
return this.pointAt(this.closestPointNormalizedLength(p));
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
closestPointLength: function(p) {
|
|
66
|
+
|
|
67
|
+
return this.closestPointNormalizedLength(p) * this.length();
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
// @return {number} the normalized length of the closest point on the line to point `p`
|
|
71
|
+
closestPointNormalizedLength: function(p) {
|
|
72
|
+
|
|
73
|
+
var product = this.vector().dot((new Line(this.start, p)).vector());
|
|
74
|
+
var cpNormalizedLength = min(1, max(0, product / this.squaredLength()));
|
|
75
|
+
|
|
76
|
+
// cpNormalizedLength returns `NaN` if this line has zero length
|
|
77
|
+
// we can work with that - if `NaN`, return 0
|
|
78
|
+
if (cpNormalizedLength !== cpNormalizedLength) return 0; // condition evaluates to `true` if and only if cpNormalizedLength is `NaN`
|
|
79
|
+
// (`NaN` is the only value that is not equal to itself)
|
|
80
|
+
|
|
81
|
+
return cpNormalizedLength;
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
closestPointTangent: function(p) {
|
|
85
|
+
|
|
86
|
+
return this.tangentAt(this.closestPointNormalizedLength(p));
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
// Returns `true` if the point lies on the line.
|
|
90
|
+
containsPoint: function(p) {
|
|
91
|
+
|
|
92
|
+
var start = this.start;
|
|
93
|
+
var end = this.end;
|
|
94
|
+
|
|
95
|
+
if (start.cross(p, end) !== 0) return false;
|
|
96
|
+
// else: cross product of 0 indicates that this line and the vector to `p` are collinear
|
|
97
|
+
|
|
98
|
+
var length = this.length();
|
|
99
|
+
if ((new Line(start, p)).length() > length) return false;
|
|
100
|
+
if ((new Line(p, end)).length() > length) return false;
|
|
101
|
+
// else: `p` lies between start and end of the line
|
|
102
|
+
|
|
103
|
+
return true;
|
|
104
|
+
},
|
|
105
|
+
|
|
106
|
+
// Divides the line into two at requested `ratio` between 0 and 1.
|
|
107
|
+
divideAt: function(ratio) {
|
|
108
|
+
|
|
109
|
+
var dividerPoint = this.pointAt(ratio);
|
|
110
|
+
|
|
111
|
+
// return array with two lines
|
|
112
|
+
return [
|
|
113
|
+
new Line(this.start, dividerPoint),
|
|
114
|
+
new Line(dividerPoint, this.end)
|
|
115
|
+
];
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
// Divides the line into two at requested `length`.
|
|
119
|
+
divideAtLength: function(length) {
|
|
120
|
+
|
|
121
|
+
var dividerPoint = this.pointAtLength(length);
|
|
122
|
+
|
|
123
|
+
// return array with two new lines
|
|
124
|
+
return [
|
|
125
|
+
new Line(this.start, dividerPoint),
|
|
126
|
+
new Line(dividerPoint, this.end)
|
|
127
|
+
];
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
equals: function(l) {
|
|
131
|
+
|
|
132
|
+
return !!l &&
|
|
133
|
+
this.start.x === l.start.x &&
|
|
134
|
+
this.start.y === l.start.y &&
|
|
135
|
+
this.end.x === l.end.x &&
|
|
136
|
+
this.end.y === l.end.y;
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
// @return {point} Point where I'm intersecting a line.
|
|
140
|
+
// @return [point] Points where I'm intersecting a rectangle.
|
|
141
|
+
// @see Squeak Smalltalk, LineSegment>>intersectionWith:
|
|
142
|
+
intersect: function(shape, opt) {
|
|
143
|
+
|
|
144
|
+
if (shape && shape.intersectionWithLine) {
|
|
145
|
+
var intersection = shape.intersectionWithLine(this, opt);
|
|
146
|
+
|
|
147
|
+
// Backwards compatibility
|
|
148
|
+
if (intersection && (shape instanceof Line)) {
|
|
149
|
+
intersection = intersection[0];
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return intersection;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return null;
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
intersectionWithLine: function(line) {
|
|
159
|
+
|
|
160
|
+
var pt1Dir = new Point(this.end.x - this.start.x, this.end.y - this.start.y);
|
|
161
|
+
var pt2Dir = new Point(line.end.x - line.start.x, line.end.y - line.start.y);
|
|
162
|
+
var det = (pt1Dir.x * pt2Dir.y) - (pt1Dir.y * pt2Dir.x);
|
|
163
|
+
var deltaPt = new Point(line.start.x - this.start.x, line.start.y - this.start.y);
|
|
164
|
+
var alpha = (deltaPt.x * pt2Dir.y) - (deltaPt.y * pt2Dir.x);
|
|
165
|
+
var beta = (deltaPt.x * pt1Dir.y) - (deltaPt.y * pt1Dir.x);
|
|
166
|
+
|
|
167
|
+
if (det === 0 || alpha * det < 0 || beta * det < 0) {
|
|
168
|
+
// No intersection found.
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (det > 0) {
|
|
173
|
+
if (alpha > det || beta > det) {
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
} else {
|
|
178
|
+
if (alpha < det || beta < det) {
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return [new Point(
|
|
184
|
+
this.start.x + (alpha * pt1Dir.x / det),
|
|
185
|
+
this.start.y + (alpha * pt1Dir.y / det)
|
|
186
|
+
)];
|
|
187
|
+
},
|
|
188
|
+
|
|
189
|
+
isDifferentiable: function() {
|
|
190
|
+
|
|
191
|
+
return !this.start.equals(this.end);
|
|
192
|
+
},
|
|
193
|
+
|
|
194
|
+
// @return {double} length of the line
|
|
195
|
+
length: function() {
|
|
196
|
+
return length(this.start, this.end);
|
|
197
|
+
},
|
|
198
|
+
|
|
199
|
+
// @return {point} my midpoint
|
|
200
|
+
midpoint: function() {
|
|
201
|
+
|
|
202
|
+
return new Point(
|
|
203
|
+
(this.start.x + this.end.x) / 2,
|
|
204
|
+
(this.start.y + this.end.y) / 2
|
|
205
|
+
);
|
|
206
|
+
},
|
|
207
|
+
|
|
208
|
+
parallel: function(distance) {
|
|
209
|
+
const l = this.clone();
|
|
210
|
+
if (!this.isDifferentiable()) return l;
|
|
211
|
+
const { start, end } = l;
|
|
212
|
+
const eRef = start.clone().rotate(end, 270);
|
|
213
|
+
const sRef = end.clone().rotate(start, 90);
|
|
214
|
+
start.move(sRef, distance);
|
|
215
|
+
end.move(eRef, distance);
|
|
216
|
+
return l;
|
|
217
|
+
},
|
|
218
|
+
|
|
219
|
+
// @return {point} my point at 't' <0,1>
|
|
220
|
+
pointAt: function(t) {
|
|
221
|
+
|
|
222
|
+
var start = this.start;
|
|
223
|
+
var end = this.end;
|
|
224
|
+
|
|
225
|
+
if (t <= 0) return start.clone();
|
|
226
|
+
if (t >= 1) return end.clone();
|
|
227
|
+
|
|
228
|
+
return start.lerp(end, t);
|
|
229
|
+
},
|
|
230
|
+
|
|
231
|
+
pointAtLength: function(length) {
|
|
232
|
+
|
|
233
|
+
var start = this.start;
|
|
234
|
+
var end = this.end;
|
|
235
|
+
|
|
236
|
+
var fromStart = true;
|
|
237
|
+
if (length < 0) {
|
|
238
|
+
fromStart = false; // negative lengths mean start calculation from end point
|
|
239
|
+
length = -length; // absolute value
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
var lineLength = this.length();
|
|
243
|
+
if (length >= lineLength) return (fromStart ? end.clone() : start.clone());
|
|
244
|
+
|
|
245
|
+
return this.pointAt((fromStart ? (length) : (lineLength - length)) / lineLength);
|
|
246
|
+
},
|
|
247
|
+
|
|
248
|
+
// @return {number} the offset of the point `p` from the line. + if the point `p` is on the right side of the line, - if on the left and 0 if on the line.
|
|
249
|
+
pointOffset: function(p) {
|
|
250
|
+
|
|
251
|
+
// Find the sign of the determinant of vectors (start,end), where p is the query point.
|
|
252
|
+
p = new Point(p);
|
|
253
|
+
var start = this.start;
|
|
254
|
+
var end = this.end;
|
|
255
|
+
var determinant = ((end.x - start.x) * (p.y - start.y) - (end.y - start.y) * (p.x - start.x));
|
|
256
|
+
|
|
257
|
+
return determinant / this.length();
|
|
258
|
+
},
|
|
259
|
+
|
|
260
|
+
rotate: function(origin, angle) {
|
|
261
|
+
|
|
262
|
+
this.start.rotate(origin, angle);
|
|
263
|
+
this.end.rotate(origin, angle);
|
|
264
|
+
return this;
|
|
265
|
+
},
|
|
266
|
+
|
|
267
|
+
round: function(precision) {
|
|
268
|
+
|
|
269
|
+
this.start.round(precision);
|
|
270
|
+
this.end.round(precision);
|
|
271
|
+
return this;
|
|
272
|
+
},
|
|
273
|
+
|
|
274
|
+
scale: function(sx, sy, origin) {
|
|
275
|
+
|
|
276
|
+
this.start.scale(sx, sy, origin);
|
|
277
|
+
this.end.scale(sx, sy, origin);
|
|
278
|
+
return this;
|
|
279
|
+
},
|
|
280
|
+
|
|
281
|
+
// @return {number} scale the line so that it has the requested length
|
|
282
|
+
setLength: function(length) {
|
|
283
|
+
|
|
284
|
+
var currentLength = this.length();
|
|
285
|
+
if (!currentLength) return this;
|
|
286
|
+
|
|
287
|
+
var scaleFactor = length / currentLength;
|
|
288
|
+
return this.scale(scaleFactor, scaleFactor, this.start);
|
|
289
|
+
},
|
|
290
|
+
|
|
291
|
+
// @return {integer} length without sqrt
|
|
292
|
+
// @note for applications where the exact length is not necessary (e.g. compare only)
|
|
293
|
+
squaredLength: function() {
|
|
294
|
+
return squaredLength(this.start, this.end);
|
|
295
|
+
},
|
|
296
|
+
|
|
297
|
+
tangentAt: function(t) {
|
|
298
|
+
|
|
299
|
+
if (!this.isDifferentiable()) return null;
|
|
300
|
+
|
|
301
|
+
var start = this.start;
|
|
302
|
+
var end = this.end;
|
|
303
|
+
|
|
304
|
+
var tangentStart = this.pointAt(t); // constrains `t` between 0 and 1
|
|
305
|
+
|
|
306
|
+
var tangentLine = new Line(start, end);
|
|
307
|
+
tangentLine.translate(tangentStart.x - start.x, tangentStart.y - start.y); // move so that tangent line starts at the point requested
|
|
308
|
+
|
|
309
|
+
return tangentLine;
|
|
310
|
+
},
|
|
311
|
+
|
|
312
|
+
tangentAtLength: function(length) {
|
|
313
|
+
|
|
314
|
+
if (!this.isDifferentiable()) return null;
|
|
315
|
+
|
|
316
|
+
var start = this.start;
|
|
317
|
+
var end = this.end;
|
|
318
|
+
|
|
319
|
+
var tangentStart = this.pointAtLength(length);
|
|
320
|
+
|
|
321
|
+
var tangentLine = new Line(start, end);
|
|
322
|
+
tangentLine.translate(tangentStart.x - start.x, tangentStart.y - start.y); // move so that tangent line starts at the point requested
|
|
323
|
+
|
|
324
|
+
return tangentLine;
|
|
325
|
+
},
|
|
326
|
+
|
|
327
|
+
toString: function() {
|
|
328
|
+
|
|
329
|
+
return this.start.toString() + ' ' + this.end.toString();
|
|
330
|
+
},
|
|
331
|
+
|
|
332
|
+
serialize: function() {
|
|
333
|
+
|
|
334
|
+
return this.start.serialize() + ' ' + this.end.serialize();
|
|
335
|
+
},
|
|
336
|
+
|
|
337
|
+
translate: function(tx, ty) {
|
|
338
|
+
|
|
339
|
+
this.start.translate(tx, ty);
|
|
340
|
+
this.end.translate(tx, ty);
|
|
341
|
+
return this;
|
|
342
|
+
},
|
|
343
|
+
|
|
344
|
+
// @return vector {point} of the line
|
|
345
|
+
vector: function() {
|
|
346
|
+
|
|
347
|
+
return new Point(this.end.x - this.start.x, this.end.y - this.start.y);
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
// For backwards compatibility:
|
|
352
|
+
Line.prototype.intersection = Line.prototype.intersect;
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
// For backwards compatibility:
|
|
356
|
+
export const line = Line;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// @return {integer} length without sqrt
|
|
2
|
+
// @note for applications where the exact length is not necessary (e.g. compare only)
|
|
3
|
+
export const squaredLength = function(start, end) {
|
|
4
|
+
|
|
5
|
+
var x0 = start.x;
|
|
6
|
+
var y0 = start.y;
|
|
7
|
+
var x1 = end.x;
|
|
8
|
+
var y1 = end.y;
|
|
9
|
+
return (x0 -= x1) * x0 + (y0 -= y1) * y0;
|
|
10
|
+
};
|