@tldraw/editor 3.14.0-canary.dbe17bbcfb3d → 3.14.0-canary.e099968e8b09
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/dist-cjs/index.d.ts +51 -46
- package/dist-cjs/index.js +3 -1
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/editor/Editor.js +2 -4
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/managers/FontManager.js +5 -1
- package/dist-cjs/lib/editor/managers/FontManager.js.map +2 -2
- package/dist-cjs/lib/primitives/Box.js +39 -33
- package/dist-cjs/lib/primitives/Box.js.map +2 -2
- package/dist-cjs/lib/primitives/Vec.js +13 -8
- package/dist-cjs/lib/primitives/Vec.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Arc2d.js +41 -21
- package/dist-cjs/lib/primitives/geometry/Arc2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Circle2d.js +11 -11
- package/dist-cjs/lib/primitives/geometry/Circle2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/CubicBezier2d.js +13 -16
- package/dist-cjs/lib/primitives/geometry/CubicBezier2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/CubicSpline2d.js +4 -4
- package/dist-cjs/lib/primitives/geometry/CubicSpline2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Edge2d.js +14 -17
- package/dist-cjs/lib/primitives/geometry/Edge2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Ellipse2d.js +10 -10
- package/dist-cjs/lib/primitives/geometry/Ellipse2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Point2d.js +6 -6
- package/dist-cjs/lib/primitives/geometry/Point2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Polygon2d.js +3 -0
- package/dist-cjs/lib/primitives/geometry/Polygon2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Polyline2d.js +8 -5
- package/dist-cjs/lib/primitives/geometry/Polyline2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Rectangle2d.js +22 -11
- package/dist-cjs/lib/primitives/geometry/Rectangle2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Stadium2d.js +22 -22
- package/dist-cjs/lib/primitives/geometry/Stadium2d.js.map +2 -2
- package/dist-cjs/lib/utils/areShapesContentEqual.js +1 -1
- package/dist-cjs/lib/utils/areShapesContentEqual.js.map +2 -2
- package/dist-cjs/version.js +3 -3
- package/dist-cjs/version.js.map +1 -1
- package/dist-esm/index.d.mts +51 -46
- package/dist-esm/index.mjs +3 -1
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +2 -4
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/FontManager.mjs +5 -1
- package/dist-esm/lib/editor/managers/FontManager.mjs.map +2 -2
- package/dist-esm/lib/primitives/Box.mjs +39 -33
- package/dist-esm/lib/primitives/Box.mjs.map +2 -2
- package/dist-esm/lib/primitives/Vec.mjs +13 -8
- package/dist-esm/lib/primitives/Vec.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Arc2d.mjs +41 -21
- package/dist-esm/lib/primitives/geometry/Arc2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Circle2d.mjs +11 -11
- package/dist-esm/lib/primitives/geometry/Circle2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/CubicBezier2d.mjs +13 -16
- package/dist-esm/lib/primitives/geometry/CubicBezier2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/CubicSpline2d.mjs +4 -4
- package/dist-esm/lib/primitives/geometry/CubicSpline2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Edge2d.mjs +14 -17
- package/dist-esm/lib/primitives/geometry/Edge2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Ellipse2d.mjs +11 -11
- package/dist-esm/lib/primitives/geometry/Ellipse2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Point2d.mjs +6 -6
- package/dist-esm/lib/primitives/geometry/Point2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Polygon2d.mjs +3 -0
- package/dist-esm/lib/primitives/geometry/Polygon2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Polyline2d.mjs +8 -5
- package/dist-esm/lib/primitives/geometry/Polyline2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Rectangle2d.mjs +22 -11
- package/dist-esm/lib/primitives/geometry/Rectangle2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Stadium2d.mjs +22 -22
- package/dist-esm/lib/primitives/geometry/Stadium2d.mjs.map +2 -2
- package/dist-esm/lib/utils/areShapesContentEqual.mjs +1 -1
- package/dist-esm/lib/utils/areShapesContentEqual.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/package.json +7 -7
- package/src/index.ts +1 -0
- package/src/lib/editor/Editor.ts +3 -4
- package/src/lib/editor/managers/FontManager.ts +5 -1
- package/src/lib/primitives/Box.test.ts +588 -7
- package/src/lib/primitives/Box.ts +41 -33
- package/src/lib/primitives/Vec.test.ts +2 -2
- package/src/lib/primitives/Vec.ts +13 -8
- package/src/lib/primitives/geometry/Arc2d.ts +42 -23
- package/src/lib/primitives/geometry/Circle2d.ts +12 -12
- package/src/lib/primitives/geometry/CubicBezier2d.test.ts +5 -0
- package/src/lib/primitives/geometry/CubicBezier2d.ts +13 -17
- package/src/lib/primitives/geometry/CubicSpline2d.ts +5 -5
- package/src/lib/primitives/geometry/Edge2d.ts +14 -18
- package/src/lib/primitives/geometry/Ellipse2d.ts +12 -13
- package/src/lib/primitives/geometry/Point2d.ts +6 -6
- package/src/lib/primitives/geometry/Polygon2d.ts +4 -0
- package/src/lib/primitives/geometry/Polyline2d.ts +10 -7
- package/src/lib/primitives/geometry/Rectangle2d.ts +24 -11
- package/src/lib/primitives/geometry/Stadium2d.ts +22 -23
- package/src/lib/utils/areShapesContentEqual.ts +2 -1
- package/src/version.ts +3 -3
|
@@ -25,13 +25,16 @@ var import_Vec = require("../Vec");
|
|
|
25
25
|
var import_Edge2d = require("./Edge2d");
|
|
26
26
|
var import_Geometry2d = require("./Geometry2d");
|
|
27
27
|
class Polyline2d extends import_Geometry2d.Geometry2d {
|
|
28
|
-
|
|
28
|
+
_points;
|
|
29
|
+
_segments;
|
|
29
30
|
constructor(config) {
|
|
30
31
|
super({ isClosed: false, isFilled: false, ...config });
|
|
31
32
|
const { points } = config;
|
|
32
|
-
this.
|
|
33
|
+
this._points = points;
|
|
34
|
+
if (points.length < 2) {
|
|
35
|
+
throw new Error("Polyline2d: points must be an array of at least 2 points");
|
|
36
|
+
}
|
|
33
37
|
}
|
|
34
|
-
_segments;
|
|
35
38
|
// eslint-disable-next-line no-restricted-syntax
|
|
36
39
|
get segments() {
|
|
37
40
|
if (!this._segments) {
|
|
@@ -52,11 +55,11 @@ class Polyline2d extends import_Geometry2d.Geometry2d {
|
|
|
52
55
|
return this.segments.reduce((acc, segment) => acc + segment.length, 0);
|
|
53
56
|
}
|
|
54
57
|
getVertices() {
|
|
55
|
-
return this.
|
|
58
|
+
return this._points;
|
|
56
59
|
}
|
|
57
60
|
nearestPoint(A) {
|
|
58
61
|
const { segments } = this;
|
|
59
|
-
let nearest = this.
|
|
62
|
+
let nearest = this._points[0];
|
|
60
63
|
let dist = Infinity;
|
|
61
64
|
let p;
|
|
62
65
|
let d;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/primitives/geometry/Polyline2d.ts"],
|
|
4
|
-
"sourcesContent": ["import { Vec, VecLike } from '../Vec'\nimport { Edge2d } from './Edge2d'\nimport { Geometry2d, Geometry2dOptions } from './Geometry2d'\n\n/** @public */\nexport class Polyline2d extends Geometry2d {\n\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAA6B;AAC7B,oBAAuB;AACvB,wBAA8C;AAGvC,MAAM,mBAAmB,6BAAW;AAAA,
|
|
4
|
+
"sourcesContent": ["import { Vec, VecLike } from '../Vec'\nimport { Edge2d } from './Edge2d'\nimport { Geometry2d, Geometry2dOptions } from './Geometry2d'\n\n/** @public */\nexport class Polyline2d extends Geometry2d {\n\tprivate _points: Vec[]\n\tprivate _segments?: Edge2d[]\n\n\tconstructor(config: Omit<Geometry2dOptions, 'isFilled' | 'isClosed'> & { points: Vec[] }) {\n\t\tsuper({ isClosed: false, isFilled: false, ...config })\n\t\tconst { points } = config\n\t\tthis._points = points\n\n\t\tif (points.length < 2) {\n\t\t\tthrow new Error('Polyline2d: points must be an array of at least 2 points')\n\t\t}\n\t}\n\n\t// eslint-disable-next-line no-restricted-syntax\n\tprotected get segments() {\n\t\tif (!this._segments) {\n\t\t\tthis._segments = []\n\t\t\tconst { vertices } = this\n\t\t\tfor (let i = 0, n = vertices.length - 1; i < n; i++) {\n\t\t\t\tconst start = vertices[i]\n\t\t\t\tconst end = vertices[i + 1]\n\t\t\t\tthis._segments.push(new Edge2d({ start, end }))\n\t\t\t}\n\n\t\t\tif (this.isClosed) {\n\t\t\t\tthis._segments.push(new Edge2d({ start: vertices[vertices.length - 1], end: vertices[0] }))\n\t\t\t}\n\t\t}\n\n\t\treturn this._segments\n\t}\n\n\toverride getLength() {\n\t\treturn this.segments.reduce((acc, segment) => acc + segment.length, 0)\n\t}\n\n\tgetVertices() {\n\t\treturn this._points\n\t}\n\n\tnearestPoint(A: VecLike): Vec {\n\t\tconst { segments } = this\n\t\tlet nearest = this._points[0]\n\t\tlet dist = Infinity\n\t\tlet p: Vec // current point on segment\n\t\tlet d: number // distance from A to p\n\t\tfor (let i = 0; i < segments.length; i++) {\n\t\t\tp = segments[i].nearestPoint(A)\n\t\t\td = Vec.Dist2(p, A)\n\t\t\tif (d < dist) {\n\t\t\t\tnearest = p\n\t\t\t\tdist = d\n\t\t\t}\n\t\t}\n\t\tif (!nearest) throw Error('nearest point not found')\n\t\treturn nearest\n\t}\n\n\thitTestLineSegment(A: VecLike, B: VecLike, distance = 0): boolean {\n\t\tconst { segments } = this\n\t\tfor (let i = 0, n = segments.length; i < n; i++) {\n\t\t\tif (segments[i].hitTestLineSegment(A, B, distance)) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t\treturn false\n\t}\n\n\tgetSvgPathData(): string {\n\t\tconst { vertices } = this\n\t\tif (vertices.length < 2) return ''\n\t\treturn vertices.reduce((acc, vertex, i) => {\n\t\t\tif (i === 0) return `M ${vertex.x} ${vertex.y}`\n\t\t\treturn `${acc} L ${vertex.x} ${vertex.y}`\n\t\t}, '')\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAA6B;AAC7B,oBAAuB;AACvB,wBAA8C;AAGvC,MAAM,mBAAmB,6BAAW;AAAA,EAClC;AAAA,EACA;AAAA,EAER,YAAY,QAA8E;AACzF,UAAM,EAAE,UAAU,OAAO,UAAU,OAAO,GAAG,OAAO,CAAC;AACrD,UAAM,EAAE,OAAO,IAAI;AACnB,SAAK,UAAU;AAEf,QAAI,OAAO,SAAS,GAAG;AACtB,YAAM,IAAI,MAAM,0DAA0D;AAAA,IAC3E;AAAA,EACD;AAAA;AAAA,EAGA,IAAc,WAAW;AACxB,QAAI,CAAC,KAAK,WAAW;AACpB,WAAK,YAAY,CAAC;AAClB,YAAM,EAAE,SAAS,IAAI;AACrB,eAAS,IAAI,GAAG,IAAI,SAAS,SAAS,GAAG,IAAI,GAAG,KAAK;AACpD,cAAM,QAAQ,SAAS,CAAC;AACxB,cAAM,MAAM,SAAS,IAAI,CAAC;AAC1B,aAAK,UAAU,KAAK,IAAI,qBAAO,EAAE,OAAO,IAAI,CAAC,CAAC;AAAA,MAC/C;AAEA,UAAI,KAAK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OAAO,CAAC;AAAA,IACxC,GAAG,EAAE;AAAA,EACN;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -25,10 +25,10 @@ var import_Box = require("../Box");
|
|
|
25
25
|
var import_Vec = require("../Vec");
|
|
26
26
|
var import_Polygon2d = require("./Polygon2d");
|
|
27
27
|
class Rectangle2d extends import_Polygon2d.Polygon2d {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
_x;
|
|
29
|
+
_y;
|
|
30
|
+
_w;
|
|
31
|
+
_h;
|
|
32
32
|
constructor(config) {
|
|
33
33
|
const { x = 0, y = 0, width, height } = config;
|
|
34
34
|
super({
|
|
@@ -40,17 +40,28 @@ class Rectangle2d extends import_Polygon2d.Polygon2d {
|
|
|
40
40
|
new import_Vec.Vec(x, y + height)
|
|
41
41
|
]
|
|
42
42
|
});
|
|
43
|
-
this.
|
|
44
|
-
this.
|
|
45
|
-
this.
|
|
46
|
-
this.
|
|
43
|
+
this._x = x;
|
|
44
|
+
this._y = y;
|
|
45
|
+
this._w = width;
|
|
46
|
+
this._h = height;
|
|
47
47
|
}
|
|
48
48
|
getBounds() {
|
|
49
|
-
return new import_Box.Box(this.
|
|
49
|
+
return new import_Box.Box(this._x, this._y, this._w, this._h);
|
|
50
50
|
}
|
|
51
51
|
getSvgPathData() {
|
|
52
|
-
const { x, y, w, h } = this;
|
|
53
|
-
|
|
52
|
+
const { _x: x, _y: y, _w: w, _h: h } = this;
|
|
53
|
+
this.negativeZeroFix();
|
|
54
|
+
return `M${x},${y} h${w} v${h} h${-w}z`;
|
|
54
55
|
}
|
|
56
|
+
negativeZeroFix() {
|
|
57
|
+
this._x = zeroFix(this._x);
|
|
58
|
+
this._y = zeroFix(this._y);
|
|
59
|
+
this._w = zeroFix(this._w);
|
|
60
|
+
this._h = zeroFix(this._h);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function zeroFix(value) {
|
|
64
|
+
if (Object.is(value, -0)) return 0;
|
|
65
|
+
return value;
|
|
55
66
|
}
|
|
56
67
|
//# sourceMappingURL=Rectangle2d.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/primitives/geometry/Rectangle2d.ts"],
|
|
4
|
-
"sourcesContent": ["import { Box } from '../Box'\nimport { Vec } from '../Vec'\nimport { Geometry2dOptions } from './Geometry2d'\nimport { Polygon2d } from './Polygon2d'\n\n/** @public */\nexport class Rectangle2d extends Polygon2d {\n\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAoB;AACpB,iBAAoB;AAEpB,uBAA0B;AAGnB,MAAM,oBAAoB,2BAAU;AAAA,
|
|
4
|
+
"sourcesContent": ["import { Box } from '../Box'\nimport { Vec } from '../Vec'\nimport { Geometry2dOptions } from './Geometry2d'\nimport { Polygon2d } from './Polygon2d'\n\n/** @public */\nexport class Rectangle2d extends Polygon2d {\n\tprivate _x: number\n\tprivate _y: number\n\tprivate _w: number\n\tprivate _h: number\n\n\tconstructor(\n\t\tconfig: Omit<Geometry2dOptions, 'isClosed'> & {\n\t\t\tx?: number\n\t\t\ty?: number\n\t\t\twidth: number\n\t\t\theight: number\n\t\t}\n\t) {\n\t\tconst { x = 0, y = 0, width, height } = config\n\t\tsuper({\n\t\t\t...config,\n\t\t\tpoints: [\n\t\t\t\tnew Vec(x, y),\n\t\t\t\tnew Vec(x + width, y),\n\t\t\t\tnew Vec(x + width, y + height),\n\t\t\t\tnew Vec(x, y + height),\n\t\t\t],\n\t\t})\n\t\tthis._x = x\n\t\tthis._y = y\n\t\tthis._w = width\n\t\tthis._h = height\n\t}\n\n\tgetBounds() {\n\t\treturn new Box(this._x, this._y, this._w, this._h)\n\t}\n\n\tgetSvgPathData(): string {\n\t\tconst { _x: x, _y: y, _w: w, _h: h } = this\n\t\tthis.negativeZeroFix()\n\t\treturn `M${x},${y} h${w} v${h} h${-w}z`\n\t}\n\n\tprivate negativeZeroFix() {\n\t\tthis._x = zeroFix(this._x)\n\t\tthis._y = zeroFix(this._y)\n\t\tthis._w = zeroFix(this._w)\n\t\tthis._h = zeroFix(this._h)\n\t}\n}\n\nfunction zeroFix(value: number) {\n\tif (Object.is(value, -0)) return 0\n\treturn value\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAoB;AACpB,iBAAoB;AAEpB,uBAA0B;AAGnB,MAAM,oBAAoB,2BAAU;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAER,YACC,QAMC;AACD,UAAM,EAAE,IAAI,GAAG,IAAI,GAAG,OAAO,OAAO,IAAI;AACxC,UAAM;AAAA,MACL,GAAG;AAAA,MACH,QAAQ;AAAA,QACP,IAAI,eAAI,GAAG,CAAC;AAAA,QACZ,IAAI,eAAI,IAAI,OAAO,CAAC;AAAA,QACpB,IAAI,eAAI,IAAI,OAAO,IAAI,MAAM;AAAA,QAC7B,IAAI,eAAI,GAAG,IAAI,MAAM;AAAA,MACtB;AAAA,IACD,CAAC;AACD,SAAK,KAAK;AACV,SAAK,KAAK;AACV,SAAK,KAAK;AACV,SAAK,KAAK;AAAA,EACX;AAAA,EAEA,YAAY;AACX,WAAO,IAAI,eAAI,KAAK,IAAI,KAAK,IAAI,KAAK,IAAI,KAAK,EAAE;AAAA,EAClD;AAAA,EAEA,iBAAyB;AACxB,UAAM,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,EAAE,IAAI;AACvC,SAAK,gBAAgB;AACrB,WAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAAA,EACrC;AAAA,EAEQ,kBAAkB;AACzB,SAAK,KAAK,QAAQ,KAAK,EAAE;AACzB,SAAK,KAAK,QAAQ,KAAK,EAAE;AACzB,SAAK,KAAK,QAAQ,KAAK,EAAE;AACzB,SAAK,KAAK,QAAQ,KAAK,EAAE;AAAA,EAC1B;AACD;AAEA,SAAS,QAAQ,OAAe;AAC/B,MAAI,OAAO,GAAG,OAAO,EAAE,EAAG,QAAO;AACjC,SAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -32,58 +32,58 @@ class Stadium2d extends import_Geometry2d.Geometry2d {
|
|
|
32
32
|
super({ ...config, isClosed: true });
|
|
33
33
|
this.config = config;
|
|
34
34
|
const { width: w, height: h } = config;
|
|
35
|
-
this.
|
|
36
|
-
this.
|
|
35
|
+
this._w = w;
|
|
36
|
+
this._h = h;
|
|
37
37
|
if (h > w) {
|
|
38
38
|
const r = w / 2;
|
|
39
|
-
this.
|
|
39
|
+
this._a = new import_Arc2d.Arc2d({
|
|
40
40
|
start: new import_Vec.Vec(0, r),
|
|
41
41
|
end: new import_Vec.Vec(w, r),
|
|
42
42
|
center: new import_Vec.Vec(w / 2, r),
|
|
43
43
|
sweepFlag: 1,
|
|
44
44
|
largeArcFlag: 1
|
|
45
45
|
});
|
|
46
|
-
this.
|
|
47
|
-
this.
|
|
46
|
+
this._b = new import_Edge2d.Edge2d({ start: new import_Vec.Vec(w, r), end: new import_Vec.Vec(w, h - r) });
|
|
47
|
+
this._c = new import_Arc2d.Arc2d({
|
|
48
48
|
start: new import_Vec.Vec(w, h - r),
|
|
49
49
|
end: new import_Vec.Vec(0, h - r),
|
|
50
50
|
center: new import_Vec.Vec(w / 2, h - r),
|
|
51
51
|
sweepFlag: 1,
|
|
52
52
|
largeArcFlag: 1
|
|
53
53
|
});
|
|
54
|
-
this.
|
|
54
|
+
this._d = new import_Edge2d.Edge2d({ start: new import_Vec.Vec(0, h - r), end: new import_Vec.Vec(0, r) });
|
|
55
55
|
} else {
|
|
56
56
|
const r = h / 2;
|
|
57
|
-
this.
|
|
57
|
+
this._a = new import_Arc2d.Arc2d({
|
|
58
58
|
start: new import_Vec.Vec(r, h),
|
|
59
59
|
end: new import_Vec.Vec(r, 0),
|
|
60
60
|
center: new import_Vec.Vec(r, r),
|
|
61
61
|
sweepFlag: 1,
|
|
62
62
|
largeArcFlag: 1
|
|
63
63
|
});
|
|
64
|
-
this.
|
|
65
|
-
this.
|
|
64
|
+
this._b = new import_Edge2d.Edge2d({ start: new import_Vec.Vec(r, 0), end: new import_Vec.Vec(w - r, 0) });
|
|
65
|
+
this._c = new import_Arc2d.Arc2d({
|
|
66
66
|
start: new import_Vec.Vec(w - r, 0),
|
|
67
67
|
end: new import_Vec.Vec(w - r, h),
|
|
68
68
|
center: new import_Vec.Vec(w - r, r),
|
|
69
69
|
sweepFlag: 1,
|
|
70
70
|
largeArcFlag: 1
|
|
71
71
|
});
|
|
72
|
-
this.
|
|
72
|
+
this._d = new import_Edge2d.Edge2d({ start: new import_Vec.Vec(w - r, h), end: new import_Vec.Vec(r, h) });
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
75
|
+
_w;
|
|
76
|
+
_h;
|
|
77
|
+
_a;
|
|
78
|
+
_b;
|
|
79
|
+
_c;
|
|
80
|
+
_d;
|
|
81
81
|
nearestPoint(A) {
|
|
82
82
|
let nearest;
|
|
83
83
|
let dist = Infinity;
|
|
84
84
|
let _d;
|
|
85
85
|
let p;
|
|
86
|
-
const { a, b, c, d } = this;
|
|
86
|
+
const { _a: a, _b: b, _c: c, _d: d } = this;
|
|
87
87
|
for (const part of [a, b, c, d]) {
|
|
88
88
|
p = part.nearestPoint(A);
|
|
89
89
|
_d = import_Vec.Vec.Dist2(p, A);
|
|
@@ -96,26 +96,26 @@ class Stadium2d extends import_Geometry2d.Geometry2d {
|
|
|
96
96
|
return nearest;
|
|
97
97
|
}
|
|
98
98
|
hitTestLineSegment(A, B) {
|
|
99
|
-
const { a, b, c, d } = this;
|
|
99
|
+
const { _a: a, _b: b, _c: c, _d: d } = this;
|
|
100
100
|
return [a, b, c, d].some((edge) => edge.hitTestLineSegment(A, B));
|
|
101
101
|
}
|
|
102
102
|
getVertices() {
|
|
103
|
-
const { a, b, c, d } = this;
|
|
103
|
+
const { _a: a, _b: b, _c: c, _d: d } = this;
|
|
104
104
|
return [a, b, c, d].reduce((a2, p) => {
|
|
105
105
|
a2.push(...p.vertices);
|
|
106
106
|
return a2;
|
|
107
107
|
}, []);
|
|
108
108
|
}
|
|
109
109
|
getBounds() {
|
|
110
|
-
return new import_Box.Box(0, 0, this.
|
|
110
|
+
return new import_Box.Box(0, 0, this._w, this._h);
|
|
111
111
|
}
|
|
112
112
|
getLength() {
|
|
113
|
-
const { h, w } = this;
|
|
113
|
+
const { _h: h, _w: w } = this;
|
|
114
114
|
if (h > w) return (import_utils.PI * (w / 2) + (h - w)) * 2;
|
|
115
115
|
else return (import_utils.PI * (h / 2) + (w - h)) * 2;
|
|
116
116
|
}
|
|
117
117
|
getSvgPathData() {
|
|
118
|
-
const { a, b, c, d } = this;
|
|
118
|
+
const { _a: a, _b: b, _c: c, _d: d } = this;
|
|
119
119
|
return [a, b, c, d].map((p, i) => p.getSvgPathData(i === 0)).join(" ") + " Z";
|
|
120
120
|
}
|
|
121
121
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/primitives/geometry/Stadium2d.ts"],
|
|
4
|
-
"sourcesContent": ["import { Box } from '../Box'\nimport { Vec, VecLike } from '../Vec'\nimport { PI } from '../utils'\nimport { Arc2d } from './Arc2d'\nimport { Edge2d } from './Edge2d'\nimport { Geometry2d, Geometry2dOptions } from './Geometry2d'\n\n/** @public */\nexport class Stadium2d extends Geometry2d {\n\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAoB;AACpB,iBAA6B;AAC7B,mBAAmB;AACnB,mBAAsB;AACtB,oBAAuB;AACvB,wBAA8C;AAGvC,MAAM,kBAAkB,6BAAW;AAAA,
|
|
4
|
+
"sourcesContent": ["import { Box } from '../Box'\nimport { Vec, VecLike } from '../Vec'\nimport { PI } from '../utils'\nimport { Arc2d } from './Arc2d'\nimport { Edge2d } from './Edge2d'\nimport { Geometry2d, Geometry2dOptions } from './Geometry2d'\n\n/** @public */\nexport class Stadium2d extends Geometry2d {\n\tprivate _w: number\n\tprivate _h: number\n\tprivate _a: Arc2d\n\tprivate _b: Edge2d\n\tprivate _c: Arc2d\n\tprivate _d: Edge2d\n\n\tconstructor(\n\t\tpublic config: Omit<Geometry2dOptions, 'isClosed'> & {\n\t\t\twidth: number\n\t\t\theight: number\n\t\t}\n\t) {\n\t\tsuper({ ...config, isClosed: true })\n\t\tconst { width: w, height: h } = config\n\t\tthis._w = w\n\t\tthis._h = h\n\n\t\tif (h > w) {\n\t\t\tconst r = w / 2\n\t\t\tthis._a = new Arc2d({\n\t\t\t\tstart: new Vec(0, r),\n\t\t\t\tend: new Vec(w, r),\n\t\t\t\tcenter: new Vec(w / 2, r),\n\t\t\t\tsweepFlag: 1,\n\t\t\t\tlargeArcFlag: 1,\n\t\t\t})\n\t\t\tthis._b = new Edge2d({ start: new Vec(w, r), end: new Vec(w, h - r) })\n\t\t\tthis._c = new Arc2d({\n\t\t\t\tstart: new Vec(w, h - r),\n\t\t\t\tend: new Vec(0, h - r),\n\t\t\t\tcenter: new Vec(w / 2, h - r),\n\t\t\t\tsweepFlag: 1,\n\t\t\t\tlargeArcFlag: 1,\n\t\t\t})\n\t\t\tthis._d = new Edge2d({ start: new Vec(0, h - r), end: new Vec(0, r) })\n\t\t} else {\n\t\t\tconst r = h / 2\n\t\t\tthis._a = new Arc2d({\n\t\t\t\tstart: new Vec(r, h),\n\t\t\t\tend: new Vec(r, 0),\n\t\t\t\tcenter: new Vec(r, r),\n\t\t\t\tsweepFlag: 1,\n\t\t\t\tlargeArcFlag: 1,\n\t\t\t})\n\t\t\tthis._b = new Edge2d({ start: new Vec(r, 0), end: new Vec(w - r, 0) })\n\t\t\tthis._c = new Arc2d({\n\t\t\t\tstart: new Vec(w - r, 0),\n\t\t\t\tend: new Vec(w - r, h),\n\t\t\t\tcenter: new Vec(w - r, r),\n\t\t\t\tsweepFlag: 1,\n\t\t\t\tlargeArcFlag: 1,\n\t\t\t})\n\t\t\tthis._d = new Edge2d({ start: new Vec(w - r, h), end: new Vec(r, h) })\n\t\t}\n\t}\n\n\tnearestPoint(A: VecLike): Vec {\n\t\tlet nearest: Vec | undefined\n\t\tlet dist = Infinity\n\t\tlet _d: number\n\t\tlet p: Vec\n\n\t\tconst { _a: a, _b: b, _c: c, _d: d } = this\n\t\tfor (const part of [a, b, c, d]) {\n\t\t\tp = part.nearestPoint(A)\n\t\t\t_d = Vec.Dist2(p, A)\n\t\t\tif (_d < dist) {\n\t\t\t\tnearest = p\n\t\t\t\tdist = _d\n\t\t\t}\n\t\t}\n\t\tif (!nearest) throw Error('nearest point not found')\n\t\treturn nearest\n\t}\n\n\thitTestLineSegment(A: VecLike, B: VecLike): boolean {\n\t\tconst { _a: a, _b: b, _c: c, _d: d } = this\n\t\treturn [a, b, c, d].some((edge) => edge.hitTestLineSegment(A, B))\n\t}\n\n\tgetVertices() {\n\t\tconst { _a: a, _b: b, _c: c, _d: d } = this\n\t\treturn [a, b, c, d].reduce<Vec[]>((a, p) => {\n\t\t\ta.push(...p.vertices)\n\t\t\treturn a\n\t\t}, [])\n\t}\n\n\tgetBounds() {\n\t\treturn new Box(0, 0, this._w, this._h)\n\t}\n\n\tgetLength() {\n\t\tconst { _h: h, _w: w } = this\n\t\tif (h > w) return (PI * (w / 2) + (h - w)) * 2\n\t\telse return (PI * (h / 2) + (w - h)) * 2\n\t}\n\n\tgetSvgPathData() {\n\t\tconst { _a: a, _b: b, _c: c, _d: d } = this\n\t\treturn [a, b, c, d].map((p, i) => p.getSvgPathData(i === 0)).join(' ') + ' Z'\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";;;;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K,mBAAmB,GAAG,CAAC,CAAC;AAAA,EACjE;AAAA,EAEA,cAAc;AACb,UAAM,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,EAAE,IAAI;AACvC,WAAO,CAAC,GAAG,GAAG,GAAG,CAAC,EAAE,OAAc,CAACA,IAAG,MAAM;AAC3C,MAAAA,GAAE,KAAK,GAAG,EAAE,QAAQ;AACpB,aAAOA;AAAA,IACR,GAAG,CAAC,CAAC;AAAA,EACN;AAAA,EAEA,YAAY;AACX,WAAO,IAAI,eAAI,GAAG,GAAG,KAAK,IAAI,KAAK,EAAE;AAAA,EACtC;AAAA,EAEA,YAAY;AACX,UAAM,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI;AACzB,QAAI,IAAI,EAAG,SAAQ,mBAAM,IAAI,MAAM,IAAI,MAAM;AAAA,QACxC,SAAQ,mBAAM,IAAI,MAAM,IAAI,MAAM;AAAA,EACxC;AAAA,EAEA,iBAAiB;AAChB,UAAM,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,EAAE,IAAI;AACvC,WAAO,CAAC,GAAG,GAAG,GAAG,CAAC,EAAE,IAAI,CAAC,GAAG,MAAM,EAAE,eAAe,MAAM,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI;AAAA,EAC1E;AACD;",
|
|
6
6
|
"names": ["a"]
|
|
7
7
|
}
|
|
@@ -21,5 +21,5 @@ __export(areShapesContentEqual_exports, {
|
|
|
21
21
|
areShapesContentEqual: () => areShapesContentEqual
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(areShapesContentEqual_exports);
|
|
24
|
-
const areShapesContentEqual = (a, b) => a.props === b.props && a.meta === b.meta;
|
|
24
|
+
const areShapesContentEqual = (a, b) => a.parentId === b.parentId && a.props === b.props && a.meta === b.meta;
|
|
25
25
|
//# sourceMappingURL=areShapesContentEqual.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/lib/utils/areShapesContentEqual.ts"],
|
|
4
|
-
"sourcesContent": ["import { TLShape } from '@tldraw/tlschema'\n\nexport const areShapesContentEqual = (a: TLShape, b: TLShape) =>\n\ta.props === b.props && a.meta === b.meta\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import { TLShape } from '@tldraw/tlschema'\n\n/** @public */\nexport const areShapesContentEqual = (a: TLShape, b: TLShape) =>\n\ta.parentId === b.parentId && a.props === b.props && a.meta === b.meta\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,wBAAwB,CAAC,GAAY,MACjD,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist-cjs/version.js
CHANGED
|
@@ -22,10 +22,10 @@ __export(version_exports, {
|
|
|
22
22
|
version: () => version
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(version_exports);
|
|
25
|
-
const version = "3.14.0-canary.
|
|
25
|
+
const version = "3.14.0-canary.e099968e8b09";
|
|
26
26
|
const publishDates = {
|
|
27
27
|
major: "2024-09-13T14:36:29.063Z",
|
|
28
|
-
minor: "2025-
|
|
29
|
-
patch: "2025-
|
|
28
|
+
minor: "2025-06-06T16:01:04.424Z",
|
|
29
|
+
patch: "2025-06-06T16:01:04.424Z"
|
|
30
30
|
};
|
|
31
31
|
//# sourceMappingURL=version.js.map
|
package/dist-cjs/version.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/version.ts"],
|
|
4
|
-
"sourcesContent": ["// This file is automatically generated by internal/scripts/refresh-assets.ts.\n// Do not edit manually. Or do, I'm a comment, not a cop.\n\nexport const version = '3.14.0-canary.
|
|
4
|
+
"sourcesContent": ["// This file is automatically generated by internal/scripts/refresh-assets.ts.\n// Do not edit manually. Or do, I'm a comment, not a cop.\n\nexport const version = '3.14.0-canary.e099968e8b09'\nexport const publishDates = {\n\tmajor: '2024-09-13T14:36:29.063Z',\n\tminor: '2025-06-06T16:01:04.424Z',\n\tpatch: '2025-06-06T16:01:04.424Z',\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,UAAU;AAChB,MAAM,eAAe;AAAA,EAC3B,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist-esm/index.d.mts
CHANGED
|
@@ -105,15 +105,15 @@ export declare function approximately(a: number, b: number, precision?: number):
|
|
|
105
105
|
|
|
106
106
|
/** @public */
|
|
107
107
|
export declare class Arc2d extends Geometry2d {
|
|
108
|
-
_center
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
108
|
+
private _center;
|
|
109
|
+
private _radius;
|
|
110
|
+
private _start;
|
|
111
|
+
private _end;
|
|
112
|
+
private _largeArcFlag;
|
|
113
|
+
private _sweepFlag;
|
|
114
|
+
private _measure;
|
|
115
|
+
private _angleStart;
|
|
116
|
+
private _angleEnd;
|
|
117
117
|
constructor(config: Omit<Geometry2dOptions, 'isClosed' | 'isFilled'> & {
|
|
118
118
|
center: Vec;
|
|
119
119
|
end: Vec;
|
|
@@ -138,6 +138,9 @@ export declare class Arc2d extends Geometry2d {
|
|
|
138
138
|
*/
|
|
139
139
|
export declare function areAnglesCompatible(a: number, b: number): boolean;
|
|
140
140
|
|
|
141
|
+
/** @public */
|
|
142
|
+
export declare const areShapesContentEqual: (a: TLShape, b: TLShape) => boolean;
|
|
143
|
+
|
|
141
144
|
/** @public */
|
|
142
145
|
export declare function average(A: VecLike, B: VecLike): string;
|
|
143
146
|
|
|
@@ -514,6 +517,8 @@ export declare class Box {
|
|
|
514
517
|
};
|
|
515
518
|
equals(other: Box | BoxModel): boolean;
|
|
516
519
|
static Equals(a: Box | BoxModel, b: Box | BoxModel): boolean;
|
|
520
|
+
prettyMuchEquals(other: Box | BoxModel): boolean;
|
|
521
|
+
static PrettyMuchEquals(a: Box | BoxModel, b: Box | BoxModel): boolean;
|
|
517
522
|
zeroFix(): this;
|
|
518
523
|
static ZeroFix(other: Box | BoxModel): Box;
|
|
519
524
|
}
|
|
@@ -551,10 +556,10 @@ export declare class Circle2d extends Geometry2d {
|
|
|
551
556
|
x?: number;
|
|
552
557
|
y?: number;
|
|
553
558
|
};
|
|
554
|
-
_center
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
559
|
+
private _center;
|
|
560
|
+
private _radius;
|
|
561
|
+
private _x;
|
|
562
|
+
private _y;
|
|
558
563
|
constructor(config: Omit<Geometry2dOptions, 'isClosed'> & {
|
|
559
564
|
isFilled: boolean;
|
|
560
565
|
radius: number;
|
|
@@ -716,10 +721,10 @@ export declare function createTLUser(opts?: {
|
|
|
716
721
|
|
|
717
722
|
/** @public */
|
|
718
723
|
export declare class CubicBezier2d extends Polyline2d {
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
724
|
+
private _a;
|
|
725
|
+
private _b;
|
|
726
|
+
private _c;
|
|
727
|
+
private _d;
|
|
723
728
|
constructor(config: Omit<Geometry2dOptions, 'isClosed' | 'isFilled'> & {
|
|
724
729
|
cp1: Vec;
|
|
725
730
|
cp2: Vec;
|
|
@@ -727,20 +732,19 @@ export declare class CubicBezier2d extends Polyline2d {
|
|
|
727
732
|
start: Vec;
|
|
728
733
|
});
|
|
729
734
|
getVertices(): Vec[];
|
|
730
|
-
midPoint(): Vec;
|
|
731
735
|
nearestPoint(A: VecLike): Vec;
|
|
732
736
|
getSvgPathData(first?: boolean): string;
|
|
733
737
|
static GetAtT(segment: CubicBezier2d, t: number): Vec;
|
|
734
|
-
getLength(
|
|
738
|
+
getLength(_filters?: Geometry2dFilters, precision?: number): number;
|
|
735
739
|
}
|
|
736
740
|
|
|
737
741
|
/** @public */
|
|
738
742
|
export declare class CubicSpline2d extends Geometry2d {
|
|
739
|
-
|
|
743
|
+
private _points;
|
|
740
744
|
constructor(config: Omit<Geometry2dOptions, 'isClosed' | 'isFilled'> & {
|
|
741
745
|
points: Vec[];
|
|
742
746
|
});
|
|
743
|
-
_segments
|
|
747
|
+
private _segments?;
|
|
744
748
|
get segments(): CubicBezier2d[];
|
|
745
749
|
getLength(): number;
|
|
746
750
|
getVertices(): Vec[];
|
|
@@ -927,17 +931,16 @@ export declare const EASINGS: {
|
|
|
927
931
|
|
|
928
932
|
/** @public */
|
|
929
933
|
export declare class Edge2d extends Geometry2d {
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
934
|
+
private _start;
|
|
935
|
+
private _end;
|
|
936
|
+
private _d;
|
|
937
|
+
private _u;
|
|
938
|
+
private _ul;
|
|
935
939
|
constructor(config: {
|
|
936
940
|
end: Vec;
|
|
937
941
|
start: Vec;
|
|
938
942
|
});
|
|
939
943
|
getLength(): number;
|
|
940
|
-
midPoint(): Vec;
|
|
941
944
|
getVertices(): Vec[];
|
|
942
945
|
nearestPoint(point: VecLike): Vec;
|
|
943
946
|
getSvgPathData(first?: boolean): string;
|
|
@@ -3996,13 +3999,13 @@ export declare class Ellipse2d extends Geometry2d {
|
|
|
3996
3999
|
height: number;
|
|
3997
4000
|
width: number;
|
|
3998
4001
|
};
|
|
3999
|
-
|
|
4000
|
-
|
|
4002
|
+
private _w;
|
|
4003
|
+
private _h;
|
|
4004
|
+
private _edges?;
|
|
4001
4005
|
constructor(config: Omit<Geometry2dOptions, 'isClosed'> & {
|
|
4002
4006
|
height: number;
|
|
4003
4007
|
width: number;
|
|
4004
4008
|
});
|
|
4005
|
-
_edges?: Edge2d[];
|
|
4006
4009
|
get edges(): Edge2d[];
|
|
4007
4010
|
getVertices(): any[];
|
|
4008
4011
|
nearestPoint(A: VecLike): Vec;
|
|
@@ -4687,7 +4690,7 @@ export declare const PI2: number;
|
|
|
4687
4690
|
|
|
4688
4691
|
/** @public */
|
|
4689
4692
|
export declare class Point2d extends Geometry2d {
|
|
4690
|
-
|
|
4693
|
+
private _point;
|
|
4691
4694
|
constructor(config: Omit<Geometry2dOptions, 'isClosed' | 'isFilled'> & {
|
|
4692
4695
|
margin: number;
|
|
4693
4696
|
point: Vec;
|
|
@@ -4731,12 +4734,12 @@ export declare function polygonsIntersect(a: VecLike[], b: VecLike[]): boolean;
|
|
|
4731
4734
|
|
|
4732
4735
|
/** @public */
|
|
4733
4736
|
export declare class Polyline2d extends Geometry2d {
|
|
4734
|
-
|
|
4737
|
+
private _points;
|
|
4738
|
+
private _segments?;
|
|
4735
4739
|
constructor(config: Omit<Geometry2dOptions, 'isClosed' | 'isFilled'> & {
|
|
4736
4740
|
points: Vec[];
|
|
4737
4741
|
});
|
|
4738
|
-
|
|
4739
|
-
get segments(): Edge2d[];
|
|
4742
|
+
protected get segments(): Edge2d[];
|
|
4740
4743
|
getLength(): number;
|
|
4741
4744
|
getVertices(): Vec[];
|
|
4742
4745
|
nearestPoint(A: VecLike): Vec;
|
|
@@ -4802,10 +4805,10 @@ export declare class ReadonlySharedStyleMap {
|
|
|
4802
4805
|
|
|
4803
4806
|
/** @public */
|
|
4804
4807
|
export declare class Rectangle2d extends Polygon2d {
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4808
|
+
private _x;
|
|
4809
|
+
private _y;
|
|
4810
|
+
private _w;
|
|
4811
|
+
private _h;
|
|
4809
4812
|
constructor(config: Omit<Geometry2dOptions, 'isClosed'> & {
|
|
4810
4813
|
height: number;
|
|
4811
4814
|
width: number;
|
|
@@ -4814,6 +4817,7 @@ export declare class Rectangle2d extends Polygon2d {
|
|
|
4814
4817
|
});
|
|
4815
4818
|
getBounds(): Box;
|
|
4816
4819
|
getSvgPathData(): string;
|
|
4820
|
+
private negativeZeroFix;
|
|
4817
4821
|
}
|
|
4818
4822
|
|
|
4819
4823
|
/** @public */
|
|
@@ -5548,12 +5552,12 @@ export declare class Stadium2d extends Geometry2d {
|
|
|
5548
5552
|
height: number;
|
|
5549
5553
|
width: number;
|
|
5550
5554
|
};
|
|
5551
|
-
|
|
5552
|
-
|
|
5553
|
-
|
|
5554
|
-
|
|
5555
|
-
|
|
5556
|
-
|
|
5555
|
+
private _w;
|
|
5556
|
+
private _h;
|
|
5557
|
+
private _a;
|
|
5558
|
+
private _b;
|
|
5559
|
+
private _c;
|
|
5560
|
+
private _d;
|
|
5557
5561
|
constructor(config: Omit<Geometry2dOptions, 'isClosed'> & {
|
|
5558
5562
|
height: number;
|
|
5559
5563
|
width: number;
|
|
@@ -7686,7 +7690,7 @@ export declare class Vec {
|
|
|
7686
7690
|
len(): number;
|
|
7687
7691
|
pry(V: VecLike): number;
|
|
7688
7692
|
per(): this;
|
|
7689
|
-
uni():
|
|
7693
|
+
uni(): this;
|
|
7690
7694
|
tan(V: VecLike): Vec;
|
|
7691
7695
|
dist(V: VecLike): number;
|
|
7692
7696
|
distanceToLineSegment(A: VecLike, B: VecLike): number;
|
|
@@ -7697,8 +7701,9 @@ export declare class Vec {
|
|
|
7697
7701
|
lrp(B: VecLike, t: number): Vec;
|
|
7698
7702
|
equals(B: VecLike): boolean;
|
|
7699
7703
|
equalsXY(x: number, y: number): boolean;
|
|
7704
|
+
/** @deprecated use `uni` instead */
|
|
7700
7705
|
norm(): this;
|
|
7701
|
-
toFixed():
|
|
7706
|
+
toFixed(): this;
|
|
7702
7707
|
toString(): string;
|
|
7703
7708
|
toJson(): VecModel;
|
|
7704
7709
|
toArray(): number[];
|
package/dist-esm/index.mjs
CHANGED
|
@@ -4,6 +4,7 @@ import "core-js/stable/array/flat-map.js";
|
|
|
4
4
|
import "core-js/stable/array/flat.js";
|
|
5
5
|
import "core-js/stable/string/at.js";
|
|
6
6
|
import "core-js/stable/string/replace-all.js";
|
|
7
|
+
import { areShapesContentEqual } from "./lib/utils/areShapesContentEqual.mjs";
|
|
7
8
|
export * from "@tldraw/state";
|
|
8
9
|
export * from "@tldraw/state-react";
|
|
9
10
|
export * from "@tldraw/store";
|
|
@@ -288,7 +289,7 @@ function debugEnableLicensing() {
|
|
|
288
289
|
}
|
|
289
290
|
registerTldrawLibraryVersion(
|
|
290
291
|
"@tldraw/editor",
|
|
291
|
-
"3.14.0-canary.
|
|
292
|
+
"3.14.0-canary.e099968e8b09",
|
|
292
293
|
"esm"
|
|
293
294
|
);
|
|
294
295
|
export {
|
|
@@ -376,6 +377,7 @@ export {
|
|
|
376
377
|
applyRotationToSnapshotShapes,
|
|
377
378
|
approximately,
|
|
378
379
|
areAnglesCompatible,
|
|
380
|
+
areShapesContentEqual,
|
|
379
381
|
average,
|
|
380
382
|
canonicalizeRotation,
|
|
381
383
|
centerOfCircleFromThreePoints,
|