pantograph2d 0.6.0 → 0.8.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.
Files changed (132) hide show
  1. package/dist/Diagram-2450b2e6.js +1750 -0
  2. package/dist/Diagram-2450b2e6.js.map +1 -0
  3. package/dist/Diagram-57e17509.cjs +4 -0
  4. package/dist/Diagram-57e17509.cjs.map +1 -0
  5. package/dist/QuadraticBezier-e116a2d6.js +3647 -0
  6. package/dist/QuadraticBezier-e116a2d6.js.map +1 -0
  7. package/dist/QuadraticBezier-e3d7218b.cjs +9 -0
  8. package/dist/QuadraticBezier-e3d7218b.cjs.map +1 -0
  9. package/dist/algorithms/intersections/arcsCubicBezierIntersection.d.ts +5 -0
  10. package/dist/algorithms/intersections/arcsQuadraticBezierIntersection.d.ts +5 -0
  11. package/dist/algorithms/intersections/bezierClip.d.ts +28 -0
  12. package/dist/algorithms/intersections/cubicBezierCubicBezierIntersection.d.ts +4 -0
  13. package/dist/algorithms/intersections/lineBezierIntersection.d.ts +5 -0
  14. package/dist/algorithms/intersections/quadraticBezierQuadraticBezierIntersection.d.ts +4 -0
  15. package/dist/algorithms/optimisation/Brent.d.ts +6 -0
  16. package/dist/api/svg.d.ts +1 -0
  17. package/dist/draw-27ac6dae.cjs +2 -0
  18. package/dist/draw-27ac6dae.cjs.map +1 -0
  19. package/dist/draw-c7b2705c.js +344 -0
  20. package/dist/draw-c7b2705c.js.map +1 -0
  21. package/dist/{types/draw.d.ts → draw.d.ts} +15 -0
  22. package/dist/export/json/exportJSON.d.ts +393 -0
  23. package/dist/export/json/jsonDiagram.d.ts +135 -0
  24. package/dist/export/json/jsonFigure.d.ts +132 -0
  25. package/dist/export/json/jsonLoop.d.ts +65 -0
  26. package/dist/export/json/jsonSegment.d.ts +62 -0
  27. package/dist/export/svg/api.d.ts +6 -0
  28. package/dist/{types/export → export}/svg/exportSVG.d.ts +5 -5
  29. package/dist/{types/export → export}/svg/wrapSVG.d.ts +1 -1
  30. package/dist/{types/import → import}/json/importJSON.d.ts +3 -1
  31. package/dist/{types/main.d.ts → main.d.ts} +1 -1
  32. package/dist/{types/models → models}/BoundingBox.d.ts +3 -0
  33. package/dist/{types/models → models}/exports.d.ts +4 -0
  34. package/dist/models/segments/CubicBezier.d.ts +31 -0
  35. package/dist/models/segments/QuadraticBezier.d.ts +30 -0
  36. package/dist/models/segments/utils/deCasteljau.d.ts +3 -0
  37. package/dist/models/segments/utils/isSegment.d.ts +8 -0
  38. package/dist/pantograph/drawShape.cjs +1 -1
  39. package/dist/pantograph/drawShape.cjs.map +1 -1
  40. package/dist/pantograph/drawShape.js +12 -11
  41. package/dist/pantograph/drawShape.js.map +1 -1
  42. package/dist/pantograph/models.cjs +1 -1
  43. package/dist/pantograph/models.js +15 -10
  44. package/dist/pantograph/models.js.map +1 -1
  45. package/dist/pantograph/svg.cjs +2 -0
  46. package/dist/pantograph/svg.cjs.map +1 -0
  47. package/dist/pantograph/svg.js +11 -0
  48. package/dist/pantograph/svg.js.map +1 -0
  49. package/dist/pantograph.cjs +2 -8
  50. package/dist/pantograph.cjs.map +1 -1
  51. package/dist/pantograph.js +368 -375
  52. package/dist/pantograph.js.map +1 -1
  53. package/dist/utils/removeDuplicateValues.d.ts +1 -0
  54. package/dist/wrapSVG-02b823ac.cjs +8 -0
  55. package/dist/wrapSVG-02b823ac.cjs.map +1 -0
  56. package/dist/wrapSVG-0ec8a111.js +62 -0
  57. package/dist/wrapSVG-0ec8a111.js.map +1 -0
  58. package/package.json +33 -22
  59. package/dist/Diagram-ab93c8b7.cjs +0 -11
  60. package/dist/Diagram-ab93c8b7.cjs.map +0 -1
  61. package/dist/Diagram-d848c815.js +0 -4252
  62. package/dist/Diagram-d848c815.js.map +0 -1
  63. package/dist/draw-0f591ea4.cjs +0 -2
  64. package/dist/draw-0f591ea4.cjs.map +0 -1
  65. package/dist/draw-a830827a.js +0 -288
  66. package/dist/draw-a830827a.js.map +0 -1
  67. package/dist/types/export/json/exportJSON.d.ts +0 -196
  68. package/dist/types/export/json/jsonDiagram.d.ts +0 -69
  69. package/dist/types/export/json/jsonFigure.d.ts +0 -66
  70. package/dist/types/export/json/jsonLoop.d.ts +0 -32
  71. package/dist/types/export/json/jsonSegment.d.ts +0 -29
  72. /package/dist/{types/algorithms → algorithms}/boolean/figureBooleans.d.ts +0 -0
  73. /package/dist/{types/algorithms → algorithms}/boolean/loopBooleans.d.ts +0 -0
  74. /package/dist/{types/algorithms → algorithms}/boolean/strandBoolean.d.ts +0 -0
  75. /package/dist/{types/algorithms → algorithms}/boolean/strandsBetweenIntersections.d.ts +0 -0
  76. /package/dist/{types/algorithms → algorithms}/distances/arcArcDistance.d.ts +0 -0
  77. /package/dist/{types/algorithms → algorithms}/distances/genericDistance.d.ts +0 -0
  78. /package/dist/{types/algorithms → algorithms}/distances/index.d.ts +0 -0
  79. /package/dist/{types/algorithms → algorithms}/distances/lineArcDistance.d.ts +0 -0
  80. /package/dist/{types/algorithms → algorithms}/distances/lineLineDistance.d.ts +0 -0
  81. /package/dist/{types/algorithms → algorithms}/filletSegments.d.ts +0 -0
  82. /package/dist/{types/algorithms → algorithms}/intersections/arcArcIntersection.d.ts +0 -0
  83. /package/dist/{types/algorithms → algorithms}/intersections/arcEllipseArcIntersection.d.ts +0 -0
  84. /package/dist/{types/algorithms → algorithms}/intersections/ellipseArcEllipseArcIntersection.d.ts +0 -0
  85. /package/dist/{types/algorithms → algorithms}/intersections/ellipseEllipseIntersection.d.ts +0 -0
  86. /package/dist/{types/algorithms → algorithms}/intersections/index.d.ts +0 -0
  87. /package/dist/{types/algorithms → algorithms}/intersections/lineArcIntersection.d.ts +0 -0
  88. /package/dist/{types/algorithms → algorithms}/intersections/lineEllipseArcIntersection.d.ts +0 -0
  89. /package/dist/{types/algorithms → algorithms}/intersections/lineLineIntersection.d.ts +0 -0
  90. /package/dist/{types/algorithms → algorithms}/intersections/rayIntersections.d.ts +0 -0
  91. /package/dist/{types/algorithms → algorithms}/offsets/offsetFigure.d.ts +0 -0
  92. /package/dist/{types/algorithms → algorithms}/offsets/offsetSegment.d.ts +0 -0
  93. /package/dist/{types/algorithms → algorithms}/offsets/offsetStroke.d.ts +0 -0
  94. /package/dist/{types/algorithms → algorithms}/optimisation/DiRect.d.ts +0 -0
  95. /package/dist/{types/algorithms → algorithms}/organiseLoops.d.ts +0 -0
  96. /package/dist/{types/algorithms → algorithms}/simplify.d.ts +0 -0
  97. /package/dist/{types/algorithms → algorithms}/solvers/solvePolynomials.d.ts +0 -0
  98. /package/dist/{types/algorithms → algorithms}/stitchSegments.d.ts +0 -0
  99. /package/dist/{types/api → api}/drawShape.d.ts +0 -0
  100. /package/dist/{types/api → api}/models.d.ts +0 -0
  101. /package/dist/{types/booleanOperations.d.ts → booleanOperations.d.ts} +0 -0
  102. /package/dist/{types/definitions.d.ts → definitions.d.ts} +0 -0
  103. /package/dist/{types/drawShape → drawShape}/drawCircle.d.ts +0 -0
  104. /package/dist/{types/drawShape → drawShape}/drawRect.d.ts +0 -0
  105. /package/dist/{types/export → export}/svg/svgDiagram.d.ts +0 -0
  106. /package/dist/{types/export → export}/svg/svgFigure.d.ts +0 -0
  107. /package/dist/{types/export → export}/svg/svgLoop.d.ts +0 -0
  108. /package/dist/{types/export → export}/svg/svgSegment.d.ts +0 -0
  109. /package/dist/{types/export → export}/svg/svgStrand.d.ts +0 -0
  110. /package/dist/{types/models → models}/Diagram.d.ts +0 -0
  111. /package/dist/{types/models → models}/Figure.d.ts +0 -0
  112. /package/dist/{types/models → models}/Loop.d.ts +0 -0
  113. /package/dist/{types/models → models}/Strand.d.ts +0 -0
  114. /package/dist/{types/models → models}/Stroke.d.ts +0 -0
  115. /package/dist/{types/models → models}/TransformationMatrix.d.ts +0 -0
  116. /package/dist/{types/models → models}/segments/Arc.d.ts +0 -0
  117. /package/dist/{types/models → models}/segments/EllipseArc.d.ts +0 -0
  118. /package/dist/{types/models → models}/segments/Line.d.ts +0 -0
  119. /package/dist/{types/models → models}/segments/Segment.d.ts +0 -0
  120. /package/dist/{types/models → models}/utils/Transformable.d.ts +0 -0
  121. /package/dist/{types/offsetOperations.d.ts → offsetOperations.d.ts} +0 -0
  122. /package/dist/{types/operations.d.ts → operations.d.ts} +0 -0
  123. /package/dist/{types/utils → utils}/allCombinations.d.ts +0 -0
  124. /package/dist/{types/utils → utils}/allPairs.d.ts +0 -0
  125. /package/dist/{types/utils → utils}/angularDistance.d.ts +0 -0
  126. /package/dist/{types/utils → utils}/listOfFigures.d.ts +0 -0
  127. /package/dist/{types/utils → utils}/projectPointOnLine.d.ts +0 -0
  128. /package/dist/{types/utils → utils}/range.d.ts +0 -0
  129. /package/dist/{types/utils → utils}/removeDuplicatePoints.d.ts +0 -0
  130. /package/dist/{types/utils → utils}/unitAngle.d.ts +0 -0
  131. /package/dist/{types/utils → utils}/zip.d.ts +0 -0
  132. /package/dist/{types/vectorOperations.d.ts → vectorOperations.d.ts} +0 -0
@@ -0,0 +1,65 @@
1
+ import type { Loop } from "../../models/Loop.js";
2
+ export declare function jsonLoop(loop: Loop): {
3
+ type: string;
4
+ segments: ({
5
+ type: string;
6
+ firstPoint: import("../../definitions.js").Vector;
7
+ lastPoint: import("../../definitions.js").Vector;
8
+ center?: undefined;
9
+ clockwise?: undefined;
10
+ majorRadius?: undefined;
11
+ minorRadius?: undefined;
12
+ tiltAngle?: undefined;
13
+ controlPoint?: undefined;
14
+ firstControlPoint?: undefined;
15
+ lastControlPoint?: undefined;
16
+ } | {
17
+ type: string;
18
+ firstPoint: import("../../definitions.js").Vector;
19
+ lastPoint: import("../../definitions.js").Vector;
20
+ center: import("../../definitions.js").Vector;
21
+ clockwise: boolean;
22
+ majorRadius?: undefined;
23
+ minorRadius?: undefined;
24
+ tiltAngle?: undefined;
25
+ controlPoint?: undefined;
26
+ firstControlPoint?: undefined;
27
+ lastControlPoint?: undefined;
28
+ } | {
29
+ type: string;
30
+ firstPoint: import("../../definitions.js").Vector;
31
+ lastPoint: import("../../definitions.js").Vector;
32
+ center: import("../../definitions.js").Vector;
33
+ clockwise: boolean;
34
+ majorRadius: number;
35
+ minorRadius: number;
36
+ tiltAngle: number;
37
+ controlPoint?: undefined;
38
+ firstControlPoint?: undefined;
39
+ lastControlPoint?: undefined;
40
+ } | {
41
+ type: string;
42
+ firstPoint: import("../../definitions.js").Vector;
43
+ lastPoint: import("../../definitions.js").Vector;
44
+ controlPoint: import("../../definitions.js").Vector;
45
+ center?: undefined;
46
+ clockwise?: undefined;
47
+ majorRadius?: undefined;
48
+ minorRadius?: undefined;
49
+ tiltAngle?: undefined;
50
+ firstControlPoint?: undefined;
51
+ lastControlPoint?: undefined;
52
+ } | {
53
+ type: string;
54
+ firstPoint: import("../../definitions.js").Vector;
55
+ lastPoint: import("../../definitions.js").Vector;
56
+ firstControlPoint: import("../../definitions.js").Vector;
57
+ lastControlPoint: import("../../definitions.js").Vector;
58
+ center?: undefined;
59
+ clockwise?: undefined;
60
+ majorRadius?: undefined;
61
+ minorRadius?: undefined;
62
+ tiltAngle?: undefined;
63
+ controlPoint?: undefined;
64
+ })[];
65
+ };
@@ -0,0 +1,62 @@
1
+ import { Segment } from "../../models/segments/Segment.js";
2
+ export declare function jsonSegment(segment: Segment): {
3
+ type: string;
4
+ firstPoint: import("../../definitions.js").Vector;
5
+ lastPoint: import("../../definitions.js").Vector;
6
+ center?: undefined;
7
+ clockwise?: undefined;
8
+ majorRadius?: undefined;
9
+ minorRadius?: undefined;
10
+ tiltAngle?: undefined;
11
+ controlPoint?: undefined;
12
+ firstControlPoint?: undefined;
13
+ lastControlPoint?: undefined;
14
+ } | {
15
+ type: string;
16
+ firstPoint: import("../../definitions.js").Vector;
17
+ lastPoint: import("../../definitions.js").Vector;
18
+ center: import("../../definitions.js").Vector;
19
+ clockwise: boolean;
20
+ majorRadius?: undefined;
21
+ minorRadius?: undefined;
22
+ tiltAngle?: undefined;
23
+ controlPoint?: undefined;
24
+ firstControlPoint?: undefined;
25
+ lastControlPoint?: undefined;
26
+ } | {
27
+ type: string;
28
+ firstPoint: import("../../definitions.js").Vector;
29
+ lastPoint: import("../../definitions.js").Vector;
30
+ center: import("../../definitions.js").Vector;
31
+ clockwise: boolean;
32
+ majorRadius: number;
33
+ minorRadius: number;
34
+ tiltAngle: number;
35
+ controlPoint?: undefined;
36
+ firstControlPoint?: undefined;
37
+ lastControlPoint?: undefined;
38
+ } | {
39
+ type: string;
40
+ firstPoint: import("../../definitions.js").Vector;
41
+ lastPoint: import("../../definitions.js").Vector;
42
+ controlPoint: import("../../definitions.js").Vector;
43
+ center?: undefined;
44
+ clockwise?: undefined;
45
+ majorRadius?: undefined;
46
+ minorRadius?: undefined;
47
+ tiltAngle?: undefined;
48
+ firstControlPoint?: undefined;
49
+ lastControlPoint?: undefined;
50
+ } | {
51
+ type: string;
52
+ firstPoint: import("../../definitions.js").Vector;
53
+ lastPoint: import("../../definitions.js").Vector;
54
+ firstControlPoint: import("../../definitions.js").Vector;
55
+ lastControlPoint: import("../../definitions.js").Vector;
56
+ center?: undefined;
57
+ clockwise?: undefined;
58
+ majorRadius?: undefined;
59
+ minorRadius?: undefined;
60
+ tiltAngle?: undefined;
61
+ controlPoint?: undefined;
62
+ };
@@ -0,0 +1,6 @@
1
+ export { svgDiagram } from "./svgDiagram.js";
2
+ export { svgFigure } from "./svgFigure.js";
3
+ export { svgLoop } from "./svgLoop.js";
4
+ export { svgSegmentToPath } from "./svgSegment.js";
5
+ export { svgStrand } from "./svgStrand.js";
6
+ export { svgViewbox } from "./wrapSVG.js";
@@ -1,18 +1,18 @@
1
1
  import { Diagram } from "../../models/Diagram.js";
2
2
  import { Figure } from "../../models/Figure.js";
3
- import { Arc } from "../../models/segments/Arc.js";
4
- import { Line } from "../../models/segments/Line.js";
3
+ import { BoundingBox } from "../../models/BoundingBox.js";
5
4
  import { SVGUnit } from "./wrapSVG.js";
6
5
  import type { Stroke } from "../../models/Stroke.js";
7
- import { EllipseArc } from "../../models/segments/EllipseArc.js";
8
- type Shape = Figure | Diagram | Arc | Line | EllipseArc | Stroke;
6
+ import { Segment } from "../../main.js";
7
+ type Shape = Figure | Diagram | Stroke | Segment;
9
8
  export declare function svgBody(shape: Shape): string;
10
9
  type ConfiguredShape = Shape | {
11
10
  shape: Shape;
12
11
  color?: string;
13
12
  };
14
- export declare function exportSVG(shape: ConfiguredShape | ConfiguredShape[], { margin, unit, }?: {
13
+ export declare function exportSVG(shape: ConfiguredShape | ConfiguredShape[], { margin, unit, viewBox, }?: {
15
14
  margin?: number;
16
15
  unit?: null | SVGUnit;
16
+ viewBox?: BoundingBox;
17
17
  }): string;
18
18
  export {};
@@ -1,4 +1,4 @@
1
1
  import { BoundingBox } from "../../models/BoundingBox.js";
2
- export declare function SVGViewbox(bbox: BoundingBox, margin?: number): string;
2
+ export declare function svgViewbox(bbox: BoundingBox, margin?: number): string;
3
3
  export type SVGUnit = "mm" | "cm" | "in" | "pc" | "px" | "pt";
4
4
  export declare function wrapSVG(body: string, boundingBox: BoundingBox, margin: number | undefined, unit: null | SVGUnit): string;
@@ -4,4 +4,6 @@ import { Loop } from "../../models/Loop.js";
4
4
  import { Figure } from "../../models/Figure.js";
5
5
  import { Diagram } from "../../models/Diagram.js";
6
6
  import { EllipseArc } from "../../models/segments/EllipseArc.js";
7
- export declare function importJSON(json: any): Diagram | Figure | Loop | Line | Arc | EllipseArc;
7
+ import { CubicBezier } from "../../models/segments/CubicBezier.js";
8
+ import { QuadraticBezier } from "../../models/segments/QuadraticBezier.js";
9
+ export declare function importJSON(json: any): Diagram | Figure | Loop | Line | Arc | EllipseArc | CubicBezier | QuadraticBezier;
@@ -4,7 +4,7 @@ export declare const DEG2RAD: number;
4
4
  export declare const RAD2DEG: number;
5
5
  export declare function polarToCartesian(r: number, theta: number): Vector;
6
6
  export declare function cartesianToPolar([x, y]: Vector): [number, number];
7
- export type { Diagram, Figure, Loop, Strand, Stroke, TransformationMatrix, BoundingBox, Segment, Line, Arc, } from "./models/exports.js";
7
+ export type { Diagram, Figure, Loop, Strand, Stroke, TransformationMatrix, BoundingBox, Segment, Line, Arc, EllipseArc, CubicBezier, } from "./models/exports.js";
8
8
  export { draw } from "./draw.js";
9
9
  export { fuseAll, fuse, cut, intersect, eraseStrand, confineStrand, offset, outlineStroke, } from "./operations.js";
10
10
  export { exportSVG, svgBody } from "./export/svg/exportSVG.js";
@@ -7,9 +7,12 @@ export declare class BoundingBox {
7
7
  constructor(xMin?: number, yMin?: number, xMax?: number, yMax?: number);
8
8
  get width(): number;
9
9
  get height(): number;
10
+ get center(): Vector;
11
+ grow(amount: number): BoundingBox;
10
12
  contains(point: Vector): boolean;
11
13
  overlaps(other: BoundingBox): boolean;
12
14
  addPoint(point: Vector): BoundingBox;
13
15
  merge(other: BoundingBox): BoundingBox;
16
+ intersection(other: BoundingBox): BoundingBox;
14
17
  }
15
18
  export declare function pointsBoundingBox(points: Vector[]): BoundingBox;
@@ -7,5 +7,9 @@ export { BoundingBox } from "./BoundingBox.js";
7
7
  export { TransformationMatrix } from "./TransformationMatrix.js";
8
8
  export { Line } from "./segments/Line.js";
9
9
  export { Arc } from "./segments/Arc.js";
10
+ export { EllipseArc } from "./segments/EllipseArc.js";
11
+ export { CubicBezier } from "./segments/CubicBezier.js";
12
+ export { QuadraticBezier } from "./segments/QuadraticBezier.js";
10
13
  export type { Segment } from "./segments/Segment.js";
14
+ export { isSegment } from "./segments/utils/isSegment.js";
11
15
  export { Transformable } from "./utils/Transformable.js";
@@ -0,0 +1,31 @@
1
+ import { Vector } from "../../definitions.js";
2
+ import { BoundingBox } from "../BoundingBox.js";
3
+ import { TransformationMatrix } from "../TransformationMatrix.js";
4
+ import { AbstractSegment } from "./Segment.js";
5
+ export declare class CubicBezier extends AbstractSegment<CubicBezier> {
6
+ segmentType: string;
7
+ readonly firstControlPoint: Vector;
8
+ readonly lastControlPoint: Vector;
9
+ constructor(firstPoint: Vector, lastPoint: Vector, firstControlPoint: Vector, lastControlPoint: Vector);
10
+ get midPoint(): Vector;
11
+ _boundingBox: BoundingBox | null;
12
+ get boundingBox(): BoundingBox;
13
+ clone(): CubicBezier;
14
+ reverse(): CubicBezier;
15
+ isSame(other: CubicBezier): boolean;
16
+ distanceFrom(element: Vector): number;
17
+ isOnSegment(point: Vector): boolean;
18
+ gradientAt(t: number): Vector;
19
+ tangentAt(point: Vector): Vector;
20
+ get tangentAtFirstPoint(): Vector;
21
+ get tangentAtLastPoint(): Vector;
22
+ normalAt(point: Vector): Vector;
23
+ splitAtParameters(params: number[], paramsMap?: null | Map<number, Vector>): CubicBezier[];
24
+ splitAt(points: Vector[] | Vector): CubicBezier[];
25
+ transform(matrix: TransformationMatrix): CubicBezier;
26
+ paramPoint(t: number): Vector;
27
+ _polynomialCoefficients: null | [number, number, number, number][];
28
+ get polynomialCoefficients(): [number, number, number, number][];
29
+ paramsAtY(y: number): number[];
30
+ pointToParam(point: Vector): number;
31
+ }
@@ -0,0 +1,30 @@
1
+ import { Vector } from "../../definitions.js";
2
+ import { BoundingBox } from "../BoundingBox.js";
3
+ import { TransformationMatrix } from "../TransformationMatrix.js";
4
+ import { AbstractSegment } from "./Segment.js";
5
+ export declare class QuadraticBezier extends AbstractSegment<QuadraticBezier> {
6
+ segmentType: string;
7
+ readonly controlPoint: Vector;
8
+ constructor(firstPoint: Vector, lastPoint: Vector, controlPoint: Vector);
9
+ get midPoint(): Vector;
10
+ _boundingBox: BoundingBox | null;
11
+ get boundingBox(): BoundingBox;
12
+ clone(): QuadraticBezier;
13
+ reverse(): QuadraticBezier;
14
+ isSame(other: QuadraticBezier): boolean;
15
+ distanceFrom(element: Vector): number;
16
+ isOnSegment(point: Vector): boolean;
17
+ gradientAt(t: number): Vector;
18
+ tangentAt(point: Vector): Vector;
19
+ get tangentAtFirstPoint(): Vector;
20
+ get tangentAtLastPoint(): Vector;
21
+ normalAt(point: Vector): Vector;
22
+ splitAtParameters(params: number[], paramsMap?: null | Map<number, Vector>): QuadraticBezier[];
23
+ splitAt(points: Vector[] | Vector): QuadraticBezier[];
24
+ transform(matrix: TransformationMatrix): QuadraticBezier;
25
+ paramPoint(t: number): Vector;
26
+ _polynomialCoefficients: null | [number, number, number][];
27
+ get polynomialCoefficients(): [number, number, number][];
28
+ paramsAtY(y: number): number[];
29
+ pointToParam(point: Vector): number;
30
+ }
@@ -0,0 +1,3 @@
1
+ import { Vector } from "../../../definitions.js";
2
+ export declare function deCasteljauWithHistory(points: Vector[], t: number): Vector[][];
3
+ export declare function deCasteljau(points: Vector[], t: number): Vector;
@@ -0,0 +1,8 @@
1
+ import { Arc } from "../Arc.js";
2
+ import { CubicBezier } from "../CubicBezier.js";
3
+ import { EllipseArc } from "../EllipseArc.js";
4
+ import { Line } from "../Line.js";
5
+ import { QuadraticBezier } from "../QuadraticBezier.js";
6
+ import { Segment } from "../Segment.js";
7
+ export declare const ALL_SEGMENT_CLASSES: (typeof Line | typeof Arc | typeof CubicBezier | typeof QuadraticBezier | typeof EllipseArc)[];
8
+ export declare function isSegment(s: unknown): s is Segment;
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../draw-0f591ea4.cjs");require("../Diagram-ab93c8b7.cjs");function R(n){return f.draw([-n,0]).sagittaArc(2*n,0,n).sagittaArc(-2*n,0,n).close()}function p(n,c,a=0){const{rx:u=0,ry:m=0}=typeof a=="number"?{ry:a,rx:a}:a;let e=Math.min(u??a??0,n/2),r=Math.min(m??a??0,c/2);const l=e&&r;l||(e=0,r=0);const y=e===r,t=f.draw([Math.min(0,-(n/2-e)),-c/2]),i=(o,s)=>{l&&(y?t.tangentArc(o,s):t.ellipse(o,s,e,r,0,!1,!1))};return e<n/2&&t.hLine(n-2*e),i(e,r),r<c/2&&t.vLine(c-2*r),i(-e,r),e<n/2&&t.hLine(-(n-2*e)),i(-e,-r),r<c/2&&t.vLine(-(c-2*r)),i(e,-r),t.close()}exports.drawCircle=R;exports.drawRect=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../draw-27ac6dae.cjs");require("../QuadraticBezier-e3d7218b.cjs");require("../Diagram-57e17509.cjs");function R(n){return f.draw([-n,0]).sagittaArc(2*n,0,n).sagittaArc(-2*n,0,n).close()}function p(n,c,a=0){const{rx:u=0,ry:m=0}=typeof a=="number"?{ry:a,rx:a}:a;let e=Math.min(u??a??0,n/2),r=Math.min(m??a??0,c/2);const l=e&&r;l||(e=0,r=0);const y=e===r,t=f.draw([Math.min(0,-(n/2-e)),-c/2]),i=(o,s)=>{l&&(y?t.tangentArc(o,s):t.ellipse(o,s,e,r,0,!1,!1))};return e<n/2&&t.hLine(n-2*e),i(e,r),r<c/2&&t.vLine(c-2*r),i(-e,r),e<n/2&&t.hLine(-(n-2*e)),i(-e,-r),r<c/2&&t.vLine(-(c-2*r)),i(e,-r),t.close()}exports.drawCircle=R;exports.drawRect=p;
2
2
  //# sourceMappingURL=drawShape.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"drawShape.cjs","sources":["../../src/drawShape/drawCircle.ts","../../src/drawShape/drawRect.ts"],"sourcesContent":["import { draw } from \"../draw.js\";\nimport type { Diagram } from \"../models/Diagram.js\";\n\nexport function drawCircle(radius: number): Diagram {\n return draw([-radius, 0])\n .sagittaArc(2 * radius, 0, radius)\n .sagittaArc(-2 * radius, 0, radius)\n .close();\n}\n","import { draw } from \"../draw.js\";\nimport type { Diagram } from \"../models/Diagram.js\";\n\nexport function drawRect(\n width: number,\n height: number,\n r: number | { rx?: number; ry?: number } = 0\n): Diagram {\n const { rx: inputRx = 0, ry: inputRy = 0 } =\n typeof r === \"number\" ? { ry: r, rx: r } : r;\n let rx = Math.min(inputRx ?? r ?? 0, width / 2);\n let ry = Math.min(inputRy ?? r ?? 0, height / 2);\n\n const withRadius = rx && ry;\n if (!withRadius) {\n rx = 0;\n ry = 0;\n }\n const symmetricRadius = rx === ry;\n\n const sk = draw([Math.min(0, -(width / 2 - rx)), -height / 2]);\n\n const addFillet = (xDist: number, yDist: number) => {\n if (withRadius) {\n if (symmetricRadius) sk.tangentArc(xDist, yDist);\n else {\n sk.ellipse(xDist, yDist, rx, ry, 0, false, false);\n }\n }\n };\n\n if (rx < width / 2) {\n sk.hLine(width - 2 * rx);\n }\n addFillet(rx, ry);\n if (ry < height / 2) {\n sk.vLine(height - 2 * ry);\n }\n addFillet(-rx, ry);\n if (rx < width / 2) {\n sk.hLine(-(width - 2 * rx));\n }\n addFillet(-rx, -ry);\n if (ry < height / 2) {\n sk.vLine(-(height - 2 * ry));\n }\n addFillet(rx, -ry);\n return sk.close();\n}\n"],"names":["drawCircle","radius","draw","drawRect","width","height","r","inputRx","inputRy","rx","ry","withRadius","symmetricRadius","sk","addFillet","xDist","yDist"],"mappings":"2JAGO,SAASA,EAAWC,EAAyB,CAClD,OAAOC,OAAK,CAAC,CAACD,EAAQ,CAAC,CAAC,EACrB,WAAW,EAAIA,EAAQ,EAAGA,CAAM,EAChC,WAAW,GAAKA,EAAQ,EAAGA,CAAM,EACjC,OACL,CCLO,SAASE,EACdC,EACAC,EACAC,EAA2C,EAClC,CACT,KAAM,CAAE,GAAIC,EAAU,EAAG,GAAIC,EAAU,CAAE,EACvC,OAAOF,GAAM,SAAW,CAAE,GAAIA,EAAG,GAAIA,CAAM,EAAAA,EAC7C,IAAIG,EAAK,KAAK,IAAIF,GAAWD,GAAK,EAAGF,EAAQ,CAAC,EAC1CM,EAAK,KAAK,IAAIF,GAAWF,GAAK,EAAGD,EAAS,CAAC,EAE/C,MAAMM,EAAaF,GAAMC,EACpBC,IACEF,EAAA,EACAC,EAAA,GAEP,MAAME,EAAkBH,IAAOC,EAEzBG,EAAKX,EAAA,KAAK,CAAC,KAAK,IAAI,EAAG,EAAEE,EAAQ,EAAIK,EAAG,EAAG,CAACJ,EAAS,CAAC,CAAC,EAEvDS,EAAY,CAACC,EAAeC,IAAkB,CAC9CL,IACEC,EAAoBC,EAAA,WAAWE,EAAOC,CAAK,EAE7CH,EAAG,QAAQE,EAAOC,EAAOP,EAAIC,EAAI,EAAG,GAAO,EAAK,EAEpD,EAGE,OAAAD,EAAKL,EAAQ,GACZS,EAAA,MAAMT,EAAQ,EAAIK,CAAE,EAEzBK,EAAUL,EAAIC,CAAE,EACZA,EAAKL,EAAS,GACbQ,EAAA,MAAMR,EAAS,EAAIK,CAAE,EAEhBI,EAAA,CAACL,EAAIC,CAAE,EACbD,EAAKL,EAAQ,GACfS,EAAG,MAAM,EAAET,EAAQ,EAAIK,EAAG,EAElBK,EAAA,CAACL,EAAI,CAACC,CAAE,EACdA,EAAKL,EAAS,GAChBQ,EAAG,MAAM,EAAER,EAAS,EAAIK,EAAG,EAEnBI,EAAAL,EAAI,CAACC,CAAE,EACVG,EAAG,OACZ"}
1
+ {"version":3,"file":"drawShape.cjs","sources":["../../src/drawShape/drawCircle.ts","../../src/drawShape/drawRect.ts"],"sourcesContent":["import { draw } from \"../draw.js\";\nimport type { Diagram } from \"../models/Diagram.js\";\n\nexport function drawCircle(radius: number): Diagram {\n return draw([-radius, 0])\n .sagittaArc(2 * radius, 0, radius)\n .sagittaArc(-2 * radius, 0, radius)\n .close();\n}\n","import { draw } from \"../draw.js\";\nimport type { Diagram } from \"../models/Diagram.js\";\n\nexport function drawRect(\n width: number,\n height: number,\n r: number | { rx?: number; ry?: number } = 0,\n): Diagram {\n const { rx: inputRx = 0, ry: inputRy = 0 } =\n typeof r === \"number\" ? { ry: r, rx: r } : r;\n let rx = Math.min(inputRx ?? r ?? 0, width / 2);\n let ry = Math.min(inputRy ?? r ?? 0, height / 2);\n\n const withRadius = rx && ry;\n if (!withRadius) {\n rx = 0;\n ry = 0;\n }\n const symmetricRadius = rx === ry;\n\n const sk = draw([Math.min(0, -(width / 2 - rx)), -height / 2]);\n\n const addFillet = (xDist: number, yDist: number) => {\n if (withRadius) {\n if (symmetricRadius) sk.tangentArc(xDist, yDist);\n else {\n sk.ellipse(xDist, yDist, rx, ry, 0, false, false);\n }\n }\n };\n\n if (rx < width / 2) {\n sk.hLine(width - 2 * rx);\n }\n addFillet(rx, ry);\n if (ry < height / 2) {\n sk.vLine(height - 2 * ry);\n }\n addFillet(-rx, ry);\n if (rx < width / 2) {\n sk.hLine(-(width - 2 * rx));\n }\n addFillet(-rx, -ry);\n if (ry < height / 2) {\n sk.vLine(-(height - 2 * ry));\n }\n addFillet(rx, -ry);\n return sk.close();\n}\n"],"names":["drawCircle","radius","draw","drawRect","width","height","r","inputRx","inputRy","rx","ry","withRadius","symmetricRadius","sk","addFillet","xDist","yDist"],"mappings":"sMAGO,SAASA,EAAWC,EAAyB,CAClD,OAAOC,OAAK,CAAC,CAACD,EAAQ,CAAC,CAAC,EACrB,WAAW,EAAIA,EAAQ,EAAGA,CAAM,EAChC,WAAW,GAAKA,EAAQ,EAAGA,CAAM,EACjC,OACL,CCLO,SAASE,EACdC,EACAC,EACAC,EAA2C,EAClC,CACT,KAAM,CAAE,GAAIC,EAAU,EAAG,GAAIC,EAAU,CAAE,EACvC,OAAOF,GAAM,SAAW,CAAE,GAAIA,EAAG,GAAIA,CAAM,EAAAA,EAC7C,IAAIG,EAAK,KAAK,IAAIF,GAAWD,GAAK,EAAGF,EAAQ,CAAC,EAC1CM,EAAK,KAAK,IAAIF,GAAWF,GAAK,EAAGD,EAAS,CAAC,EAE/C,MAAMM,EAAaF,GAAMC,EACpBC,IACEF,EAAA,EACAC,EAAA,GAEP,MAAME,EAAkBH,IAAOC,EAEzBG,EAAKX,EAAA,KAAK,CAAC,KAAK,IAAI,EAAG,EAAEE,EAAQ,EAAIK,EAAG,EAAG,CAACJ,EAAS,CAAC,CAAC,EAEvDS,EAAY,CAACC,EAAeC,IAAkB,CAC9CL,IACEC,EAAoBC,EAAA,WAAWE,EAAOC,CAAK,EAE7CH,EAAG,QAAQE,EAAOC,EAAOP,EAAIC,EAAI,EAAG,GAAO,EAAK,EAEpD,EAGE,OAAAD,EAAKL,EAAQ,GACZS,EAAA,MAAMT,EAAQ,EAAIK,CAAE,EAEzBK,EAAUL,EAAIC,CAAE,EACZA,EAAKL,EAAS,GACbQ,EAAA,MAAMR,EAAS,EAAIK,CAAE,EAEhBI,EAAA,CAACL,EAAIC,CAAE,EACbD,EAAKL,EAAQ,GACfS,EAAG,MAAM,EAAET,EAAQ,EAAIK,EAAG,EAElBK,EAAA,CAACL,EAAI,CAACC,CAAE,EACdA,EAAKL,EAAS,GAChBQ,EAAG,MAAM,EAAER,EAAS,EAAIK,EAAG,EAEnBI,EAAAL,EAAI,CAACC,CAAE,EACVG,EAAG,OACZ"}
@@ -1,20 +1,21 @@
1
- import { d as s } from "../draw-a830827a.js";
2
- import "../Diagram-d848c815.js";
3
- function x(e) {
1
+ import { d as s } from "../draw-c7b2705c.js";
2
+ import "../QuadraticBezier-e116a2d6.js";
3
+ import "../Diagram-2450b2e6.js";
4
+ function L(e) {
4
5
  return s([-e, 0]).sagittaArc(2 * e, 0, e).sagittaArc(-2 * e, 0, e).close();
5
6
  }
6
- function L(e, o, r = 0) {
7
+ function A(e, o, r = 0) {
7
8
  const { rx: m = 0, ry: p = 0 } = typeof r == "number" ? { ry: r, rx: r } : r;
8
9
  let n = Math.min(m ?? r ?? 0, e / 2), t = Math.min(p ?? r ?? 0, o / 2);
9
- const f = n && t;
10
- f || (n = 0, t = 0);
11
- const u = n === t, c = s([Math.min(0, -(e / 2 - n)), -o / 2]), a = (i, l) => {
12
- f && (u ? c.tangentArc(i, l) : c.ellipse(i, l, n, t, 0, !1, !1));
10
+ const a = n && t;
11
+ a || (n = 0, t = 0);
12
+ const u = n === t, c = s([Math.min(0, -(e / 2 - n)), -o / 2]), i = (f, l) => {
13
+ a && (u ? c.tangentArc(f, l) : c.ellipse(f, l, n, t, 0, !1, !1));
13
14
  };
14
- return n < e / 2 && c.hLine(e - 2 * n), a(n, t), t < o / 2 && c.vLine(o - 2 * t), a(-n, t), n < e / 2 && c.hLine(-(e - 2 * n)), a(-n, -t), t < o / 2 && c.vLine(-(o - 2 * t)), a(n, -t), c.close();
15
+ return n < e / 2 && c.hLine(e - 2 * n), i(n, t), t < o / 2 && c.vLine(o - 2 * t), i(-n, t), n < e / 2 && c.hLine(-(e - 2 * n)), i(-n, -t), t < o / 2 && c.vLine(-(o - 2 * t)), i(n, -t), c.close();
15
16
  }
16
17
  export {
17
- x as drawCircle,
18
- L as drawRect
18
+ L as drawCircle,
19
+ A as drawRect
19
20
  };
20
21
  //# sourceMappingURL=drawShape.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"drawShape.js","sources":["../../src/drawShape/drawCircle.ts","../../src/drawShape/drawRect.ts"],"sourcesContent":["import { draw } from \"../draw.js\";\nimport type { Diagram } from \"../models/Diagram.js\";\n\nexport function drawCircle(radius: number): Diagram {\n return draw([-radius, 0])\n .sagittaArc(2 * radius, 0, radius)\n .sagittaArc(-2 * radius, 0, radius)\n .close();\n}\n","import { draw } from \"../draw.js\";\nimport type { Diagram } from \"../models/Diagram.js\";\n\nexport function drawRect(\n width: number,\n height: number,\n r: number | { rx?: number; ry?: number } = 0\n): Diagram {\n const { rx: inputRx = 0, ry: inputRy = 0 } =\n typeof r === \"number\" ? { ry: r, rx: r } : r;\n let rx = Math.min(inputRx ?? r ?? 0, width / 2);\n let ry = Math.min(inputRy ?? r ?? 0, height / 2);\n\n const withRadius = rx && ry;\n if (!withRadius) {\n rx = 0;\n ry = 0;\n }\n const symmetricRadius = rx === ry;\n\n const sk = draw([Math.min(0, -(width / 2 - rx)), -height / 2]);\n\n const addFillet = (xDist: number, yDist: number) => {\n if (withRadius) {\n if (symmetricRadius) sk.tangentArc(xDist, yDist);\n else {\n sk.ellipse(xDist, yDist, rx, ry, 0, false, false);\n }\n }\n };\n\n if (rx < width / 2) {\n sk.hLine(width - 2 * rx);\n }\n addFillet(rx, ry);\n if (ry < height / 2) {\n sk.vLine(height - 2 * ry);\n }\n addFillet(-rx, ry);\n if (rx < width / 2) {\n sk.hLine(-(width - 2 * rx));\n }\n addFillet(-rx, -ry);\n if (ry < height / 2) {\n sk.vLine(-(height - 2 * ry));\n }\n addFillet(rx, -ry);\n return sk.close();\n}\n"],"names":["drawCircle","radius","draw","drawRect","width","height","inputRx","inputRy","rx","ry","withRadius","symmetricRadius","sk","addFillet","xDist","yDist"],"mappings":";;AAGO,SAASA,EAAWC,GAAyB;AAClD,SAAOC,EAAK,CAAC,CAACD,GAAQ,CAAC,CAAC,EACrB,WAAW,IAAIA,GAAQ,GAAGA,CAAM,EAChC,WAAW,KAAKA,GAAQ,GAAGA,CAAM,EACjC;AACL;ACLO,SAASE,EACdC,GACAC,GACA,IAA2C,GAClC;AACT,QAAM,EAAE,IAAIC,IAAU,GAAG,IAAIC,IAAU,EAAE,IACvC,OAAO,KAAM,WAAW,EAAE,IAAI,GAAG,IAAI,EAAM,IAAA;AAC7C,MAAIC,IAAK,KAAK,IAAIF,KAAW,KAAK,GAAGF,IAAQ,CAAC,GAC1CK,IAAK,KAAK,IAAIF,KAAW,KAAK,GAAGF,IAAS,CAAC;AAE/C,QAAMK,IAAaF,KAAMC;AACzB,EAAKC,MACEF,IAAA,GACAC,IAAA;AAEP,QAAME,IAAkBH,MAAOC,GAEzBG,IAAKV,EAAK,CAAC,KAAK,IAAI,GAAG,EAAEE,IAAQ,IAAII,EAAG,GAAG,CAACH,IAAS,CAAC,CAAC,GAEvDQ,IAAY,CAACC,GAAeC,MAAkB;AAClD,IAAIL,MACEC,IAAoBC,EAAA,WAAWE,GAAOC,CAAK,IAE7CH,EAAG,QAAQE,GAAOC,GAAOP,GAAIC,GAAI,GAAG,IAAO,EAAK;AAAA,EAEpD;AAGE,SAAAD,IAAKJ,IAAQ,KACZQ,EAAA,MAAMR,IAAQ,IAAII,CAAE,GAEzBK,EAAUL,GAAIC,CAAE,GACZA,IAAKJ,IAAS,KACbO,EAAA,MAAMP,IAAS,IAAII,CAAE,GAEhBI,EAAA,CAACL,GAAIC,CAAE,GACbD,IAAKJ,IAAQ,KACfQ,EAAG,MAAM,EAAER,IAAQ,IAAII,EAAG,GAElBK,EAAA,CAACL,GAAI,CAACC,CAAE,GACdA,IAAKJ,IAAS,KAChBO,EAAG,MAAM,EAAEP,IAAS,IAAII,EAAG,GAEnBI,EAAAL,GAAI,CAACC,CAAE,GACVG,EAAG;AACZ;"}
1
+ {"version":3,"file":"drawShape.js","sources":["../../src/drawShape/drawCircle.ts","../../src/drawShape/drawRect.ts"],"sourcesContent":["import { draw } from \"../draw.js\";\nimport type { Diagram } from \"../models/Diagram.js\";\n\nexport function drawCircle(radius: number): Diagram {\n return draw([-radius, 0])\n .sagittaArc(2 * radius, 0, radius)\n .sagittaArc(-2 * radius, 0, radius)\n .close();\n}\n","import { draw } from \"../draw.js\";\nimport type { Diagram } from \"../models/Diagram.js\";\n\nexport function drawRect(\n width: number,\n height: number,\n r: number | { rx?: number; ry?: number } = 0,\n): Diagram {\n const { rx: inputRx = 0, ry: inputRy = 0 } =\n typeof r === \"number\" ? { ry: r, rx: r } : r;\n let rx = Math.min(inputRx ?? r ?? 0, width / 2);\n let ry = Math.min(inputRy ?? r ?? 0, height / 2);\n\n const withRadius = rx && ry;\n if (!withRadius) {\n rx = 0;\n ry = 0;\n }\n const symmetricRadius = rx === ry;\n\n const sk = draw([Math.min(0, -(width / 2 - rx)), -height / 2]);\n\n const addFillet = (xDist: number, yDist: number) => {\n if (withRadius) {\n if (symmetricRadius) sk.tangentArc(xDist, yDist);\n else {\n sk.ellipse(xDist, yDist, rx, ry, 0, false, false);\n }\n }\n };\n\n if (rx < width / 2) {\n sk.hLine(width - 2 * rx);\n }\n addFillet(rx, ry);\n if (ry < height / 2) {\n sk.vLine(height - 2 * ry);\n }\n addFillet(-rx, ry);\n if (rx < width / 2) {\n sk.hLine(-(width - 2 * rx));\n }\n addFillet(-rx, -ry);\n if (ry < height / 2) {\n sk.vLine(-(height - 2 * ry));\n }\n addFillet(rx, -ry);\n return sk.close();\n}\n"],"names":["drawCircle","radius","draw","drawRect","width","height","inputRx","inputRy","rx","ry","withRadius","symmetricRadius","sk","addFillet","xDist","yDist"],"mappings":";;;AAGO,SAASA,EAAWC,GAAyB;AAClD,SAAOC,EAAK,CAAC,CAACD,GAAQ,CAAC,CAAC,EACrB,WAAW,IAAIA,GAAQ,GAAGA,CAAM,EAChC,WAAW,KAAKA,GAAQ,GAAGA,CAAM,EACjC;AACL;ACLO,SAASE,EACdC,GACAC,GACA,IAA2C,GAClC;AACT,QAAM,EAAE,IAAIC,IAAU,GAAG,IAAIC,IAAU,EAAE,IACvC,OAAO,KAAM,WAAW,EAAE,IAAI,GAAG,IAAI,EAAM,IAAA;AAC7C,MAAIC,IAAK,KAAK,IAAIF,KAAW,KAAK,GAAGF,IAAQ,CAAC,GAC1CK,IAAK,KAAK,IAAIF,KAAW,KAAK,GAAGF,IAAS,CAAC;AAE/C,QAAMK,IAAaF,KAAMC;AACzB,EAAKC,MACEF,IAAA,GACAC,IAAA;AAEP,QAAME,IAAkBH,MAAOC,GAEzBG,IAAKV,EAAK,CAAC,KAAK,IAAI,GAAG,EAAEE,IAAQ,IAAII,EAAG,GAAG,CAACH,IAAS,CAAC,CAAC,GAEvDQ,IAAY,CAACC,GAAeC,MAAkB;AAClD,IAAIL,MACEC,IAAoBC,EAAA,WAAWE,GAAOC,CAAK,IAE7CH,EAAG,QAAQE,GAAOC,GAAOP,GAAIC,GAAI,GAAG,IAAO,EAAK;AAAA,EAEpD;AAGE,SAAAD,IAAKJ,IAAQ,KACZQ,EAAA,MAAMR,IAAQ,IAAII,CAAE,GAEzBK,EAAUL,GAAIC,CAAE,GACZA,IAAKJ,IAAS,KACbO,EAAA,MAAMP,IAAS,IAAII,CAAE,GAEhBI,EAAA,CAACL,GAAIC,CAAE,GACbD,IAAKJ,IAAQ,KACfQ,EAAG,MAAM,EAAER,IAAQ,IAAII,EAAG,GAElBK,EAAA,CAACL,GAAI,CAACC,CAAE,GACdA,IAAKJ,IAAS,KAChBO,EAAG,MAAM,EAAEP,IAAS,IAAII,EAAG,GAEnBI,EAAAL,GAAI,CAACC,CAAE,GACVG,EAAG;AACZ;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../Diagram-ab93c8b7.cjs");exports.Arc=r.Arc;exports.BoundingBox=r.BoundingBox;exports.Diagram=r.Diagram;exports.Figure=r.Figure;exports.Line=r.Line;exports.Loop=r.Loop;exports.Strand=r.Strand;exports.Transformable=r.Transformable;exports.TransformationMatrix=r.TransformationMatrix;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../Diagram-57e17509.cjs"),r=require("../QuadraticBezier-e3d7218b.cjs");exports.Diagram=e.Diagram;exports.Figure=e.Figure;exports.Loop=e.Loop;exports.Strand=e.Strand;exports.isSegment=e.isSegment;exports.Arc=r.Arc;exports.BoundingBox=r.BoundingBox;exports.CubicBezier=r.CubicBezier;exports.EllipseArc=r.EllipseArc;exports.Line=r.Line;exports.QuadraticBezier=r.QuadraticBezier;exports.Transformable=r.Transformable;exports.TransformationMatrix=r.TransformationMatrix;
2
2
  //# sourceMappingURL=models.cjs.map
@@ -1,13 +1,18 @@
1
- import { A as s, B as o, D as n, F as i, o as e, L as m, S as t, x, T as f } from "../Diagram-d848c815.js";
1
+ import { D as s, F as e, L as i, S as o, e as n } from "../Diagram-2450b2e6.js";
2
+ import { A as m, B as g, C as B, E as c, L as f, Q as p, g as u, T as x } from "../QuadraticBezier-e116a2d6.js";
2
3
  export {
3
- s as Arc,
4
- o as BoundingBox,
5
- n as Diagram,
6
- i as Figure,
7
- e as Line,
8
- m as Loop,
9
- t as Strand,
10
- x as Transformable,
11
- f as TransformationMatrix
4
+ m as Arc,
5
+ g as BoundingBox,
6
+ B as CubicBezier,
7
+ s as Diagram,
8
+ c as EllipseArc,
9
+ e as Figure,
10
+ f as Line,
11
+ i as Loop,
12
+ p as QuadraticBezier,
13
+ o as Strand,
14
+ u as Transformable,
15
+ x as TransformationMatrix,
16
+ n as isSegment
12
17
  };
13
18
  //# sourceMappingURL=models.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"models.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"models.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("../wrapSVG-02b823ac.cjs");require("../QuadraticBezier-e3d7218b.cjs");exports.svgDiagram=g.svgDiagram;exports.svgFigure=g.svgFigure;exports.svgLoop=g.svgLoop;exports.svgSegmentToPath=g.svgSegmentToPath;exports.svgStrand=g.svgStrand;exports.svgViewbox=g.svgViewbox;
2
+ //# sourceMappingURL=svg.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"svg.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ import { s as o, a as e, b as r, d as v, c as t, e as i } from "../wrapSVG-0ec8a111.js";
2
+ import "../QuadraticBezier-e116a2d6.js";
3
+ export {
4
+ o as svgDiagram,
5
+ e as svgFigure,
6
+ r as svgLoop,
7
+ v as svgSegmentToPath,
8
+ t as svgStrand,
9
+ i as svgViewbox
10
+ };
11
+ //# sourceMappingURL=svg.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"svg.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -1,9 +1,3 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("./draw-0f591ea4.cjs"),r=require("./Diagram-ab93c8b7.cjs");function d(t){if(t instanceof r.Figure)return[t];if(t instanceof r.Loop)return[new r.Figure(t)];if(t instanceof r.Diagram)return t.figures;throw new Error("Unknown shape")}function N(t,n,e=1e-9){let i=[];const o=[],s=new Array(n.segments.length).fill(0).map(()=>[]);n.segments.forEach((f,l)=>{t.segments.forEach(c=>{const{intersections:g,overlaps:p}=r.findIntersectionsAndOverlaps(f,c,e);i.push(...g),s[l].push(...g),o.push(...p);const h=p.flatMap(u=>[u.firstPoint,u.lastPoint]);i.push(...h),s[l].push(...h)})}),i=r.removeDuplicatePoints(i,e);const a=r.zip([n.segments,s]).flatMap(([f,l])=>l.length?f.splitAt(l):[f]);return Array.from(r.strandsBetweenIntersections(a,i,o))}function $(t,n,e=!1){return N(n,t).filter(o=>{const s=o.segments[0].midPoint;return n.onStroke(s)?!e:!n.contains(s)})}function F(t,n,e=!1){return N(n,t).filter(o=>{const s=o.segments[0].midPoint;return n.onStroke(s)?!e:n.contains(s)})}function R(t,n,e=!1){const i=$(t,n.contour,e),o=n.holes.flatMap(s=>F(t,s,e));return[...i,...o]}function C(t,n,e=!1){let i=F(t,n.contour,e);return n.holes.forEach(o=>{i=i.flatMap(s=>$(s,o,e))}),i}function z(t,n){return new r.Diagram(r.fuseFiguresLists(d(t),d(n)))}function S(t){return t.reduce((n,e)=>z(n,e),new r.Diagram)}function E(t,n){return new r.Diagram(r.cutFiguresLists(d(t),d(n)))}function nt(t,n){return new r.Diagram(r.intersectFiguresLists(d(t),d(n)))}function et(t,n,e=!0){if(n instanceof r.Loop)return $(t,n,e);if(n instanceof r.Figure)return R(t,n,e);let i=[new r.Strand([...t.segments])];return n.figures.forEach(o=>{i=i.flatMap(s=>R(s,o,e))}),i}function it(t,n,e=!1){if(n instanceof r.Loop)return F(t,n,e);if(n instanceof r.Figure)return C(t,n,e);let i=[new r.Strand([...t.segments])];return n.figures.forEach(o=>{i=i.flatMap(s=>C(s,o,e))}),i}function V(t){return t<0?"before":t>1?"after":"between"}const G=(t,n,e)=>{if(e==="before")return t.distanceFrom(n.firstPoint);if(e==="after")return t.distanceFrom(n.lastPoint);throw new Error("Invalid position")};function rt(t,n){const e=r.lineLineParams(t,n);if(e==="parallel")return Math.min(t.distanceFrom(n.firstPoint),t.distanceFrom(n.lastPoint));const{intersectionParam1:i,intersectionParam2:o}=e,s=V(i),a=V(o);if(s==="between"&&a==="between")return 0;if(s==="between"&&a!=="between")return G(t,n,a);if(a==="between"&&s!=="between")return G(n,t,s);if(s==="before"&&a==="before")return r.distance(t.firstPoint,n.firstPoint);if(s==="after"&&a==="after")return r.distance(t.lastPoint,n.lastPoint);if(s==="before"&&a==="after")return r.distance(t.firstPoint,n.lastPoint);if(s==="after"&&a==="before")return r.distance(t.lastPoint,n.firstPoint);throw new Error("Invalid position")}function T(t,n){if(r.lineArcIntersection(t,n).length>0)return 0;const e=r.projectPointOnLine(t,n.center);if(t.isOnSegment(e)){const i=r.distance(e,n.center);if(Math.abs(i-n.radius)<t.precision&&n.isOnSegment(e))return 0;if(i-n.radius>t.precision){const o=r.normalize(r.subtract(e,n.center)),s=r.add(n.center,r.scalarMultiply(o,n.radius));if(n.isOnSegment(s))return r.distance(s,e)}}return Math.min(n.distanceFrom(t.firstPoint),n.distanceFrom(t.lastPoint),t.distanceFrom(n.firstPoint),t.distanceFrom(n.lastPoint))}const st=(t,n)=>{const e=t.angleToParam(n.firstAngle);if(t.isValidParameter(e))return!0;const i=t.angleToParam(n.lastAngle);return!!t.isValidParameter(i)};function ot(t,n){if(r.arcArcIntersection(t,n,!0).length>0)return 0;const e=r.distance(t.center,n.center);if(e<t.precision&&st(t,n))return Math.abs(t.radius-n.radius);const i=r.normalize(r.subtract(n.center,t.center)),o=e-Math.abs(t.radius-n.radius)<t.precision;let s=r.polarAngle(i);o&&n.radius>t.radius&&(s+=Math.PI);const a=o?s:s+Math.PI,f=t.angleToParam(s),l=n.angleToParam(a);return t.isValidParameter(f)&&n.isValidParameter(l)?r.distance(t.paramPoint(f),n.paramPoint(l)):Math.min(t.distanceFrom(n.firstPoint),t.distanceFrom(n.lastPoint),n.distanceFrom(t.firstPoint),n.distanceFrom(t.lastPoint))}function at(t,n,e){let i=0,o=t.length-1;for(;i<=o;){const s=Math.floor((i+o)/2),a=e(t[s],n);if(a<0)i=s+1;else if(a>0)o=s-1;else return s}return-(i+1)}function ct(t,n,e){const i=at(t,n,e);i<0?t.splice(-(i+1),0,n):t.splice(i,0,n)}class ft{constructor(){this.buckets=[]}addInterval(n){const e=this.buckets[n.rectangle.diagonalBucketIndex];e===void 0?this.buckets[n.rectangle.diagonalBucketIndex]=[n]:ct(e,n,(i,o)=>i.value-o.value)}removeInterval(n){const e=this.buckets[n.rectangle.diagonalBucketIndex];if(e===void 0)throw new Error("Interval not found");e.shift()}getBottomRightHullIntervals(){const n=[];for(let e=this.buckets.length-1;e>=0;e--){const i=this.buckets[e];if(!i===void 0)continue;const o=i[0];if(o!==void 0){if(!n.length){n.push(o);continue}for(;n.length&&n[n.length-1].value>=o.value;)n.pop();for(;n.length>=2;){const s=n[n.length-1],a=n[n.length-2],f=(o.value-a.value)/((o.rectangle.diagonal-a.rectangle.diagonal)*2);if(a.value+(s.rectangle.diagonal-a.rectangle.diagonal)/2*f<s.value)n.pop();else break}n.push(o)}}return n}}class lt{constructor(n,e){this.x=n,this.y=e,this.xLength=Math.pow(3,-n),this.yLength=Math.pow(3,-e),this.diagonal=Math.sqrt(this.xLength*this.xLength+this.yLength*this.yLength),this.diagonalBucketIndex=n+e,this.index=`${n},${e}`}}class ut{constructor(n,e=1e-8,i=1e3,o=1e-6){this.fcn=n,this.endTolerance=e,this.maxIterations=i,this.epsilon=o,this.fcn=n,this.epsilon=o,this.endTolerance=e,this.maxIterations=i,this.rectangles=new Map,this.buckets=new ft;const s=[.5,.5],a=this.rect(0,0),f=this.fcn(s);this.buckets.addInterval(new v(s,f,a)),this.fMin=f,this.argMin=s,this.tol=a.diagonal}registerInterval(n){this.buckets.addInterval(n),n.value<=this.fMin&&(this.fMin=n.value,this.argMin=n.center,this.tol=n.rectangle.diagonal)}rect(n,e){const i=`${n},${e}`;return this.rectangles.has(i)||this.rectangles.set(i,new lt(n,e)),this.rectangles.get(i)}splitInterval(n){let e,i,o;const[s,a]=n.center;return n.rectangle.x<=n.rectangle.y?(e=this.rect(n.rectangle.x+1,n.rectangle.y),i=[s-e.xLength,a],o=[s+e.xLength,a]):(e=this.rect(n.rectangle.x,n.rectangle.y+1),i=[s,a-e.yLength],o=[s,a+e.yLength]),[new v(i,this.fcn(i),e),new v(n.center,n.value,e),new v(o,this.fcn(o),e)]}single_iteration(){const n=this.buckets.getBottomRightHullIntervals();for(;n.length>=2;){const e=n[0],i=n[1],o=(i.value-e.value)/((i.rectangle.diagonal-e.rectangle.diagonal)/2),s=e.value-o*i.value/2;if((this.fMin-s)/Math.abs(this.fMin)<this.epsilon)n.shift();else break}n.forEach(e=>{this.buckets.removeInterval(e)});for(const e of n){const[i,o,s]=this.splitInterval(e);this.registerInterval(i),this.registerInterval(o),this.registerInterval(s)}}run(){let n=0;for(;this.tol>this.endTolerance/2&&(this.single_iteration(),n++,!(n>this.maxIterations)););return{fMin:this.fMin,argMin:this.argMin,tol:this.tol,iterations:n}}}class v{constructor(n,e,i){this.center=n,this.value=e,this.rectangle=i}}function gt(t,n=1e-8,e=1e3,i=1e-6){return new ut(t,n,e,i).run()}function ht(t,n,e=1e-9){const i=gt(o=>{const s=t.paramPoint(o[0]),a=n.paramPoint(o[1]);return r.squareDistance(s,a)},e);return Math.sqrt(i.fMin)}function pt(t,n){return t instanceof r.Line&&n instanceof r.Line?rt(t,n):t instanceof r.Line&&n instanceof r.Arc?T(t,n):t instanceof r.Arc&&n instanceof r.Line?T(n,t):t instanceof r.Arc&&n instanceof r.Arc?ot(t,n):ht(t,n)}const y=1e-8;function I(t,n,e=!0){const i=t.map(c=>({offset:P.offsetSegment(c,n),original:c})),o=[];let s=e?null:i.at(-1),a=e?i.at(-1):null;if(o.length===1)return o;const f=c=>{s?c.offset instanceof P.DegenerateSegment?r.sameVector(c.offset.firstPoint,c.offset.lastPoint)||o.push(new r.Line(c.offset.firstPoint,c.offset.lastPoint)):o.push(c.offset):s=c},l=function*(){for(const c of i.slice(0,-1))yield c;if(!s)throw new Error("Bug in the offset algorithm");yield s};for(const c of l()){if(!a){a=c;continue}const g=a.offset.lastPoint,p=c.offset.firstPoint;if(r.sameVector(g,p)){f(a),a=c;continue}let h=[];if(!(a.offset instanceof P.DegenerateSegment)&&!(c.offset instanceof P.DegenerateSegment)){const{intersections:m,overlaps:M}=r.findIntersectionsAndOverlaps(a.offset,c.offset,y/100);h=[...m,...M.flatMap(w=>[w.firstPoint,w.lastPoint])]}if(h.length>0){let m=h[0];if(h.length>1){const j=a==null?void 0:a.original.lastPoint,x=h.map(tt=>r.squareDistance(tt,j));m=h[x.indexOf(Math.min(...x))]}const M=a.offset.splitAt([m])[0],w=c.offset.splitAt([m]).at(-1);if(!w)throw new Error("Bug in the splitting algo in offset");f({offset:M,original:a.original}),a={offset:w,original:c.original};continue}const u=a.original.lastPoint,L=r.crossProduct(r.subtract(p,u),r.subtract(g,u))>0,Q=new r.Arc(g,p,u,L);f(a),o.push(Q),a=c}return a&&f(a),o}function J(t){const n=new Map,e=(i,o)=>{const s=n.get(i)||[];n.set(i,[...s,...o])};return t.forEach((i,o)=>{t.slice(o+1).forEach((s,a)=>{const{intersections:f,overlaps:l}=r.findIntersectionsAndOverlaps(i,s,y),c=[...f,...l.flatMap(g=>[g.firstPoint,g.lastPoint])].filter(g=>{const p=r.sameVector(g,i.firstPoint)||r.sameVector(g,i.lastPoint),h=r.sameVector(g,s.firstPoint)||r.sameVector(g,s.lastPoint);return!(p&&h)});c.length&&(e(o,c),e(a+o+1,c))})}),n}function _(t,n){return n.flatMap((e,i)=>{if(!t.has(i))return e;const o=t.get(i);return o?e.splitAt(o):e})}function H(t,n,e){return t.filter(i=>!n.segments.some(s=>pt(s,i)<Math.abs(e)-y))}function A(t,n){const e=t.clockwise?n:-n,i=I(t.segments,e);if(i.length<2)return new r.Diagram;const o=J(i);if(!o.size){const c=new r.Loop(i);return new r.Diagram([new r.Figure(c)])}const s=_(o,i),a=H(s,t,n);if(!a.length)return new r.Diagram;const l=r.stitchSegments(a).filter(c=>c.length>1).filter(c=>r.sameVector(c[0].firstPoint,c.at(-1).lastPoint)).map(c=>new r.Loop(c));return l.length?new r.Diagram(l.map(c=>new r.Figure(c))):new r.Diagram}function dt(t,n,e="round"){const i=n/2,o=I(t.segments,i,!1),s=I(t.segments,-i,!1).map(u=>u.reverse());s.reverse();const a=(u,L)=>e==="round"?r.tangentArc(u.lastPoint,L.firstPoint,u.tangentAtLastPoint):new r.Line(u.lastPoint,L.firstPoint),f=[...o,a(o[o.length-1],s[0]),...s,a(s[s.length-1],o[0])],l=J(f);if(!l.size){const u=new r.Loop(f);return new r.Diagram([new r.Figure(u)])}const c=_(l,f),g=H(c,t,i);if(!g.length)return new r.Diagram;const h=r.stitchSegments(g).filter(u=>u.length>1).filter(u=>r.sameVector(u[0].firstPoint,u.at(-1).lastPoint)).map(u=>new r.Loop(u));return h.length?new r.Diagram(h.map(u=>new r.Figure(u))):new r.Diagram}function mt(t,n){const e=t.map(i=>{const o=S(i.holes.map(s=>A(s,n)));return E(A(i.contour,n),o)});return S(e)}function wt(t,n){const e=Math.abs(n/2),i=t.map(o=>S(o.allLoops.map(s=>E(A(s,e),A(s,-e)))));return S(i)}function Pt(t,n){return mt(d(t),n)}function St(t,n,{endCap:e="round"}={}){return t instanceof r.Strand?dt(t,n,e):wt(d(t),n)}function O(t){if(t instanceof r.Line)return`L ${t.lastPoint.join(" ")}`;if(t instanceof r.Arc)return`A ${t.radius} ${t.radius} 0 ${t.angularLength>Math.PI?"1":"0"} ${t.clockwise?"0":"1"} ${t.lastPoint.join(" ")}`;if(t instanceof r.EllipseArc)return`A ${t.majorRadius} ${t.minorRadius} ${t.tiltAngle*r.RAD2DEG} ${t.deltaAngle>Math.PI?"1":"0"} ${t.clockwise?"0":"1"} ${t.lastPoint.join(" ")}`;throw new Error("Unknown segment type")}function W(t){const n=`M ${t.firstPoint.join(" ")}`,e=t.segments.map(O).join(" ");return`${n} ${e} Z`}function X(t){return`<path d="${t.allLoops.map(W).join(" ")}" />`}function Lt(t){return`<g>
2
- ${t.figures.map(X).join(`
3
- `)}
4
- </g>`}function vt(t){const n=`M ${t.firstPoint.join(" ")}`,e=t.segments.map(O).join(" ");return`${n} ${e}`}function At(t,n=1){const e=t.xMin-n,i=t.yMin-n;return`${e} ${i} ${t.width+2*n} ${t.height+2*n}`}function B(t,n,e=1,i){const o=At(n,e),s=i?`width="${n.width+2*e}${i}" height="${n.height+2*e}${i}"`:"";return`<?xml version="1.0" encoding="UTF-8" standalone="no"?>
5
- <svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="${o}" fill="none" stroke="black" stroke-width="0.2%" vector-effect="non-scaling-stroke" ${s}>
6
- ${t}
7
- </svg>`}function b(t){if(t instanceof r.Diagram)return Lt(t);if(t instanceof r.Figure)return X(t);if(t instanceof r.Loop)return`<path d="${W(t)}" />`;if(t instanceof r.Strand)return`<path d="${vt(t)}" />`;if(t instanceof r.Arc||t instanceof r.Line||t instanceof r.EllipseArc)return`<path d="${`M ${t.firstPoint.join(" ")}`} ${O(t)}" />`;throw new Error("Unknown shape type")}const U=t=>"shape"in t?t.shape:t,q=(t,n)=>{if(!("shape"in t))return n;const{color:e}=t;return e?`<g stroke="${e}">${n}</g>`:n};function Mt(t,{margin:n=1,unit:e=null}={}){if(Array.isArray(t)){const o=t.map(f=>U(f).mirror()),s=o.map((f,l)=>q(t[l],b(f))).join(`
8
- `),a=o.slice(1).reduce((f,l)=>f.merge(l.boundingBox),o[0].boundingBox);return B(s,a,n,e)}const i=U(t).mirror();return B(q(t,b(i)),i.boundingBox,n,e)}const Y=t=>{if(t.type==="LINE")return new r.Line(t.firstPoint,t.lastPoint);if(t.type==="ARC")return new r.Arc(t.firstPoint,t.lastPoint,t.center,t.clockwise);if(t.type==="ELLIPSE_ARC")return new r.EllipseArc(t.firstPoint,t.lastPoint,t.center,t.majorRadius,t.minorRadius,t.tiltAngle,t.clockwise,{angleUnits:"rad"});throw new Error("Unknown segment type")},k=t=>{const n=t.segments.map(Y);return new r.Loop(n)},Z=t=>{const n=k(t.contour),e=t.holes.map(k);return new r.Figure(n,e)},It=t=>{const n=t.figures.map(Z);return new r.Diagram(n)};function bt(t){if(t.type==="DIAGRAM")return It(t);if(t.type==="FIGURE")return Z(t);if(t.type==="LOOP")return k(t);if(t.type==="LINE"||t.type==="ARC"||t.type==="ELLIPSE_ARC")return Y(t);throw new Error("Unknown shape type")}const D=Math.PI/180,K=180/Math.PI;function kt(t,n){const e=Math.cos(n*D)*t,i=Math.sin(n*D)*t;return[e,i]}function Dt([t,n]){const e=Math.sqrt(t*t+n*n),i=Math.atan2(n,t)*K;return[e,i]}exports.draw=P.draw;exports.exportJSON=r.exportJSON;exports.DEG2RAD=D;exports.RAD2DEG=K;exports.cartesianToPolar=Dt;exports.confineStrand=it;exports.cut=E;exports.eraseStrand=et;exports.exportSVG=Mt;exports.fuse=z;exports.fuseAll=S;exports.importJSON=bt;exports.intersect=nt;exports.offset=Pt;exports.outlineStroke=St;exports.polarToCartesian=kt;exports.svgBody=b;
1
+ "use strict";var et=Object.defineProperty;var nt=(t,e,n)=>e in t?et(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var d=(t,e,n)=>(nt(t,typeof e!="symbol"?e+"":e,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("./draw-27ac6dae.cjs"),a=require("./Diagram-57e17509.cjs"),c=require("./QuadraticBezier-e3d7218b.cjs"),w=require("./wrapSVG-02b823ac.cjs");function P(t){if(t instanceof a.Figure)return[t];if(t instanceof a.Loop)return[new a.Figure(t)];if(t instanceof a.Diagram)return t.figures;throw new Error("Unknown shape")}function _(t,e,n=1e-9){let i=[];const s=[],r=new Array(e.segments.length).fill(0).map(()=>[]);e.segments.forEach((u,l)=>{t.segments.forEach(f=>{const{intersections:h,overlaps:m}=a.findIntersectionsAndOverlaps(u,f,n);i.push(...h),r[l].push(...h),s.push(...m);const p=m.flatMap(g=>[g.firstPoint,g.lastPoint]);i.push(...p),r[l].push(...p)})}),i=c.removeDuplicatePoints(i,n);const o=c.zip([e.segments,r]).flatMap(([u,l])=>l.length?u.splitAt(l):[u]);return Array.from(a.strandsBetweenIntersections(o,i,s))}function C(t,e,n=!1){return _(e,t).filter(s=>{const r=s.segments[0].midPoint;return e.onStroke(r)?!n:!e.contains(r)})}function x(t,e,n=!1){return _(e,t).filter(s=>{const r=s.segments[0].midPoint;return e.onStroke(r)?!n:e.contains(r)})}function V(t,e,n=!1){const i=C(t,e.contour,n),s=e.holes.flatMap(r=>x(t,r,n));return[...i,...s]}function G(t,e,n=!1){let i=x(t,e.contour,n);return e.holes.forEach(s=>{i=i.flatMap(r=>C(r,s,n))}),i}function J(t,e){return new a.Diagram(a.fuseFiguresLists(P(t),P(e)))}function M(t){return t.reduce((e,n)=>J(e,n),new a.Diagram)}function O(t,e){return new a.Diagram(a.cutFiguresLists(P(t),P(e)))}function it(t,e){return new a.Diagram(a.intersectFiguresLists(P(t),P(e)))}function rt(t,e,n=!0){if(e instanceof a.Loop)return C(t,e,n);if(e instanceof a.Figure)return V(t,e,n);let i=[new a.Strand([...t.segments])];return e.figures.forEach(s=>{i=i.flatMap(r=>V(r,s,n))}),i}function st(t,e,n=!1){if(e instanceof a.Loop)return x(t,e,n);if(e instanceof a.Figure)return G(t,e,n);let i=[new a.Strand([...t.segments])];return e.figures.forEach(s=>{i=i.flatMap(r=>G(r,s,n))}),i}function T(t){return t<0?"before":t>1?"after":"between"}const $=(t,e,n)=>{if(n==="before")return t.distanceFrom(e.firstPoint);if(n==="after")return t.distanceFrom(e.lastPoint);throw new Error("Invalid position")};function ot(t,e){const n=c.lineLineParams(t,e);if(n==="parallel")return Math.min(t.distanceFrom(e.firstPoint),t.distanceFrom(e.lastPoint));const{intersectionParam1:i,intersectionParam2:s}=n,r=T(i),o=T(s);if(r==="between"&&o==="between")return 0;if(r==="between"&&o!=="between")return $(t,e,o);if(o==="between"&&r!=="between")return $(e,t,r);if(r==="before"&&o==="before")return c.distance(t.firstPoint,e.firstPoint);if(r==="after"&&o==="after")return c.distance(t.lastPoint,e.lastPoint);if(r==="before"&&o==="after")return c.distance(t.firstPoint,e.lastPoint);if(r==="after"&&o==="before")return c.distance(t.lastPoint,e.firstPoint);throw new Error("Invalid position")}function q(t,e){if(a.lineArcIntersection(t,e).length>0)return 0;const n=a.projectPointOnLine(t,e.center);if(t.isOnSegment(n)){const i=c.distance(n,e.center);if(Math.abs(i-e.radius)<t.precision&&e.isOnSegment(n))return 0;if(i-e.radius>t.precision){const s=c.normalize(c.subtract(n,e.center)),r=c.add(e.center,c.scalarMultiply(s,e.radius));if(e.isOnSegment(r))return c.distance(r,n)}}return Math.min(e.distanceFrom(t.firstPoint),e.distanceFrom(t.lastPoint),t.distanceFrom(e.firstPoint),t.distanceFrom(e.lastPoint))}const at=(t,e)=>{const n=t.angleToParam(e.firstAngle);if(t.isValidParameter(n))return!0;const i=t.angleToParam(e.lastAngle);return!!t.isValidParameter(i)};function ct(t,e){if(a.arcArcIntersection(t,e,!0).length>0)return 0;const n=c.distance(t.center,e.center);if(n<t.precision&&at(t,e))return Math.abs(t.radius-e.radius);const i=c.normalize(c.subtract(e.center,t.center)),s=n-Math.abs(t.radius-e.radius)<t.precision;let r=c.polarAngle(i);s&&e.radius>t.radius&&(r+=Math.PI);const o=s?r:r+Math.PI,u=t.angleToParam(r),l=e.angleToParam(o);return t.isValidParameter(u)&&e.isValidParameter(l)?c.distance(t.paramPoint(u),e.paramPoint(l)):Math.min(t.distanceFrom(e.firstPoint),t.distanceFrom(e.lastPoint),e.distanceFrom(t.firstPoint),e.distanceFrom(t.lastPoint))}function ft(t,e,n){let i=0,s=t.length-1;for(;i<=s;){const r=Math.floor((i+s)/2),o=n(t[r],e);if(o<0)i=r+1;else if(o>0)s=r-1;else return r}return-(i+1)}function ut(t,e,n){const i=ft(t,e,n);i<0?t.splice(-(i+1),0,e):t.splice(i,0,e)}class lt{constructor(){d(this,"buckets");this.buckets=[]}addInterval(e){const n=this.buckets[e.rectangle.diagonalBucketIndex];n===void 0?this.buckets[e.rectangle.diagonalBucketIndex]=[e]:ut(n,e,(i,s)=>i.value-s.value)}removeInterval(e){const n=this.buckets[e.rectangle.diagonalBucketIndex];if(n===void 0)throw new Error("Interval not found");n.shift()}getBottomRightHullIntervals(){const e=[];for(let n=this.buckets.length-1;n>=0;n--){const i=this.buckets[n];if(!i===void 0)continue;const s=i[0];if(s!==void 0){if(!e.length){e.push(s);continue}for(;e.length&&e[e.length-1].value>=s.value;)e.pop();for(;e.length>=2;){const r=e[e.length-1],o=e[e.length-2],u=(s.value-o.value)/((s.rectangle.diagonal-o.rectangle.diagonal)*2);if(o.value+(r.rectangle.diagonal-o.rectangle.diagonal)/2*u<r.value)e.pop();else break}e.push(s)}}return e}}class gt{constructor(e,n){d(this,"diagonal");d(this,"diagonalBucketIndex");d(this,"xLength");d(this,"yLength");d(this,"index");this.x=e,this.y=n,this.xLength=Math.pow(3,-e),this.yLength=Math.pow(3,-n),this.diagonal=Math.sqrt(this.xLength*this.xLength+this.yLength*this.yLength),this.diagonalBucketIndex=e+n,this.index=`${e},${n}`}}class ht{constructor(e,n=1e-8,i=1e3,s=1e-6){d(this,"rectangles");d(this,"buckets");d(this,"fMin");d(this,"argMin");d(this,"tol");this.fcn=e,this.endTolerance=n,this.maxIterations=i,this.epsilon=s,this.fcn=e,this.epsilon=s,this.endTolerance=n,this.maxIterations=i,this.rectangles=new Map,this.buckets=new lt;const r=[.5,.5],o=this.rect(0,0),u=this.fcn(r);this.buckets.addInterval(new b(r,u,o)),this.fMin=u,this.argMin=r,this.tol=o.diagonal}registerInterval(e){this.buckets.addInterval(e),e.value<=this.fMin&&(this.fMin=e.value,this.argMin=e.center,this.tol=e.rectangle.diagonal)}rect(e,n){const i=`${e},${n}`;return this.rectangles.has(i)||this.rectangles.set(i,new gt(e,n)),this.rectangles.get(i)}splitInterval(e){let n,i,s;const[r,o]=e.center;return e.rectangle.x<=e.rectangle.y?(n=this.rect(e.rectangle.x+1,e.rectangle.y),i=[r-n.xLength,o],s=[r+n.xLength,o]):(n=this.rect(e.rectangle.x,e.rectangle.y+1),i=[r,o-n.yLength],s=[r,o+n.yLength]),[new b(i,this.fcn(i),n),new b(e.center,e.value,n),new b(s,this.fcn(s),n)]}single_iteration(){const e=this.buckets.getBottomRightHullIntervals();for(;e.length>=2;){const n=e[0],i=e[1],s=(i.value-n.value)/((i.rectangle.diagonal-n.rectangle.diagonal)/2),r=n.value-s*i.value/2;if((this.fMin-r)/Math.abs(this.fMin)<this.epsilon)e.shift();else break}e.forEach(n=>{this.buckets.removeInterval(n)});for(const n of e){const[i,s,r]=this.splitInterval(n);this.registerInterval(i),this.registerInterval(s),this.registerInterval(r)}}run(){let e=0;for(;this.tol>this.endTolerance/2&&(this.single_iteration(),e++,!(e>this.maxIterations)););return{fMin:this.fMin,argMin:this.argMin,tol:this.tol,iterations:e}}}class b{constructor(e,n,i){this.center=e,this.value=n,this.rectangle=i}}function pt(t,e=1e-8,n=1e3,i=1e-6){return new ht(t,e,n,i).run()}function dt(t,e,n=1e-9){const i=pt(s=>{const r=t.paramPoint(s[0]),o=e.paramPoint(s[1]);return c.squareDistance(r,o)},n);return Math.sqrt(i.fMin)}function mt(t,e){return t instanceof c.Line&&e instanceof c.Line?ot(t,e):t instanceof c.Line&&e instanceof c.Arc?q(t,e):t instanceof c.Arc&&e instanceof c.Line?q(e,t):t instanceof c.Arc&&e instanceof c.Arc?ct(t,e):dt(t,e)}const R=1e-8;function k(t,e,n=!0){const i=t.map(f=>({offset:I.offsetSegment(f,e),original:f})),s=[];let r=n?null:i.at(-1),o=n?i.at(-1):null;if(s.length===1)return s;const u=f=>{r?f.offset instanceof I.DegenerateSegment?c.sameVector(f.offset.firstPoint,f.offset.lastPoint)||s.push(new c.Line(f.offset.firstPoint,f.offset.lastPoint)):s.push(f.offset):r=f},l=function*(){for(const f of i.slice(0,-1))yield f;if(!r)throw new Error("Bug in the offset algorithm");yield r};for(const f of l()){if(!o){o=f;continue}const h=o.offset.lastPoint,m=f.offset.firstPoint;if(c.sameVector(h,m)){u(o),o=f;continue}let p=[];if(!(o.offset instanceof I.DegenerateSegment)&&!(f.offset instanceof I.DegenerateSegment)){const{intersections:S,overlaps:D}=a.findIntersectionsAndOverlaps(o.offset,f.offset,R/100);p=[...S,...D.flatMap(L=>[L.firstPoint,L.lastPoint])]}if(p.length>0){let S=p[0];if(p.length>1){const j=o==null?void 0:o.original.lastPoint,B=p.map(tt=>c.squareDistance(tt,j));S=p[B.indexOf(Math.min(...B))]}const D=o.offset.splitAt([S])[0],L=f.offset.splitAt([S]).at(-1);if(!L)throw new Error("Bug in the splitting algo in offset");u({offset:D,original:o.original}),o={offset:L,original:f.original};continue}const g=o.original.lastPoint,A=c.crossProduct(c.subtract(m,g),c.subtract(h,g))>0,Y=new c.Arc(h,m,g,A);u(o),s.push(Y),o=f}return o&&u(o),s}function Q(t){const e=new Map,n=(i,s)=>{const r=e.get(i)||[];e.set(i,[...r,...s])};return t.forEach((i,s)=>{t.slice(s+1).forEach((r,o)=>{const{intersections:u,overlaps:l}=a.findIntersectionsAndOverlaps(i,r,R),f=[...u,...l.flatMap(h=>[h.firstPoint,h.lastPoint])].filter(h=>{const m=c.sameVector(h,i.firstPoint)||c.sameVector(h,i.lastPoint),p=c.sameVector(h,r.firstPoint)||c.sameVector(h,r.lastPoint);return!(m&&p)});f.length&&(n(s,f),n(o+s+1,f))})}),e}function Z(t,e){return e.flatMap((n,i)=>{if(!t.has(i))return n;const s=t.get(i);return s?n.splitAt(s):n})}function H(t,e,n){return t.filter(i=>!e.segments.some(r=>mt(r,i)<Math.abs(n)-R))}function v(t,e){const n=t.clockwise?e:-e,i=k(t.segments,n);if(i.length<2)return new a.Diagram;const s=Q(i);if(!s.size){const f=new a.Loop(i);return new a.Diagram([new a.Figure(f)])}const r=Z(s,i),o=H(r,t,e);if(!o.length)return new a.Diagram;const l=a.stitchSegments(o).filter(f=>f.length>1).filter(f=>c.sameVector(f[0].firstPoint,f.at(-1).lastPoint)).map(f=>new a.Loop(f));return l.length?new a.Diagram(l.map(f=>new a.Figure(f))):new a.Diagram}function Pt(t,e,n="round"){const i=e/2,s=k(t.segments,i,!1),r=k(t.segments,-i,!1).map(g=>g.reverse());r.reverse();const o=(g,A)=>n==="round"?c.tangentArc(g.lastPoint,A.firstPoint,g.tangentAtLastPoint):new c.Line(g.lastPoint,A.firstPoint),u=[...s,o(s[s.length-1],r[0]),...r,o(r[r.length-1],s[0])],l=Q(u);if(!l.size){const g=new a.Loop(u);return new a.Diagram([new a.Figure(g)])}const f=Z(l,u),h=H(f,t,i);if(!h.length)return new a.Diagram;const p=a.stitchSegments(h).filter(g=>g.length>1).filter(g=>c.sameVector(g[0].firstPoint,g.at(-1).lastPoint)).map(g=>new a.Loop(g));return p.length?new a.Diagram(p.map(g=>new a.Figure(g))):new a.Diagram}function wt(t,e){const n=t.map(i=>{const s=M(i.holes.map(r=>v(r,e)));return O(v(i.contour,e),s)});return M(n)}function St(t,e){const n=Math.abs(e/2),i=t.map(s=>M(s.allLoops.map(r=>O(v(r,n),v(r,-n)))));return M(i)}function Lt(t,e){return wt(P(t),e)}function It(t,e,{endCap:n="round"}={}){return t instanceof a.Strand?Pt(t,e,n):St(P(t),e)}function y(t){if(t instanceof a.Diagram)return w.svgDiagram(t);if(t instanceof a.Figure)return w.svgFigure(t);if(t instanceof a.Loop)return`<path d="${w.svgLoop(t)}" />`;if(t instanceof a.Strand)return`<path d="${w.svgStrand(t)}" />`;if(a.isSegment(t))return`<path d="${`M ${t.firstPoint.join(" ")}`} ${w.svgSegmentToPath(t)}" />`;throw new Error("Unknown shape type")}const U=t=>"shape"in t?t.shape:t,z=(t,e)=>{if(!("shape"in t))return e;const{color:n}=t;return n?`<g stroke="${n}">${e}</g>`:e},N=t=>new c.BoundingBox(t.xMin,-t.yMax,t.xMax,-t.yMin);function Mt(t,{margin:e=1,unit:n=null,viewBox:i}={}){if(Array.isArray(t)){const r=t.map(l=>U(l).mirror()),o=r.map((l,f)=>z(t[f],y(l))).join(`
2
+ `),u=r.slice(1).reduce((l,f)=>l.merge(f.boundingBox),r[0].boundingBox);return w.wrapSVG(o,i?N(i):u,e,n)}const s=U(t).mirror();return w.wrapSVG(z(t,y(s)),i?N(i):s.boundingBox,e,n)}const W=t=>{if(t.type==="LINE")return new c.Line(t.firstPoint,t.lastPoint);if(t.type==="ARC")return new c.Arc(t.firstPoint,t.lastPoint,t.center,t.clockwise);if(t.type==="ELLIPSE_ARC")return new c.EllipseArc(t.firstPoint,t.lastPoint,t.center,t.majorRadius,t.minorRadius,t.tiltAngle,t.clockwise,{angleUnits:"rad"});if(t.type==="QUADRATIC_BEZIER")return new c.QuadraticBezier(t.firstPoint,t.lastPoint,t.controlPoint);if(t.type==="CUBIC_BEZIER")return new c.CubicBezier(t.firstPoint,t.lastPoint,t.firstControlPoint,t.lastControlPoint);throw new Error("Unknown segment type")},E=t=>{const e=t.segments.map(W);return new a.Loop(e)},K=t=>{const e=E(t.contour),n=t.holes.map(E);return new a.Figure(e,n)},At=t=>{const e=t.figures.map(K);return new a.Diagram(e)};function bt(t){if(t.type==="DIAGRAM")return At(t);if(t.type==="FIGURE")return K(t);if(t.type==="LOOP")return E(t);if(t.type==="LINE"||t.type==="ARC"||t.type==="ELLIPSE_ARC"||t.type==="CUBIC_BEZIER")return W(t);throw new Error("Unknown shape type")}const F=Math.PI/180,X=180/Math.PI;function vt(t,e){const n=Math.cos(e*F)*t,i=Math.sin(e*F)*t;return[n,i]}function Dt([t,e]){const n=Math.sqrt(t*t+e*e),i=Math.atan2(e,t)*X;return[n,i]}exports.draw=I.draw;exports.exportJSON=a.exportJSON;exports.DEG2RAD=F;exports.RAD2DEG=X;exports.cartesianToPolar=Dt;exports.confineStrand=st;exports.cut=O;exports.eraseStrand=rt;exports.exportSVG=Mt;exports.fuse=J;exports.fuseAll=M;exports.importJSON=bt;exports.intersect=it;exports.offset=Lt;exports.outlineStroke=It;exports.polarToCartesian=vt;exports.svgBody=y;
9
3
  //# sourceMappingURL=pantograph.cjs.map