pantograph2d 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Diagram-ab93c8b7.cjs +11 -0
- package/dist/Diagram-ab93c8b7.cjs.map +1 -0
- package/dist/Diagram-d848c815.js +4252 -0
- package/dist/Diagram-d848c815.js.map +1 -0
- package/dist/draw-0f591ea4.cjs +2 -0
- package/dist/draw-0f591ea4.cjs.map +1 -0
- package/dist/draw-a830827a.js +288 -0
- package/dist/draw-a830827a.js.map +1 -0
- package/dist/pantograph/drawShape.cjs +1 -1
- package/dist/pantograph/drawShape.cjs.map +1 -1
- package/dist/pantograph/drawShape.js +13 -17
- package/dist/pantograph/drawShape.js.map +1 -1
- package/dist/pantograph/models.cjs +1 -1
- package/dist/pantograph/models.js +3 -3
- package/dist/pantograph.cjs +6 -6
- package/dist/pantograph.cjs.map +1 -1
- package/dist/pantograph.js +475 -334
- package/dist/pantograph.js.map +1 -1
- package/dist/types/algorithms/boolean/figureBooleans.d.ts +8 -0
- package/dist/types/algorithms/boolean/loopBooleans.d.ts +14 -0
- package/dist/types/algorithms/boolean/strandBoolean.d.ts +8 -0
- package/dist/types/algorithms/boolean/strandsBetweenIntersections.d.ts +4 -0
- package/dist/types/algorithms/distances/arcArcDistance.d.ts +2 -0
- package/dist/types/algorithms/distances/genericDistance.d.ts +6 -0
- package/dist/types/algorithms/distances/index.d.ts +2 -0
- package/dist/types/algorithms/distances/lineArcDistance.d.ts +3 -0
- package/dist/types/algorithms/distances/lineLineDistance.d.ts +2 -0
- package/dist/types/algorithms/filletSegments.d.ts +3 -0
- package/dist/types/algorithms/intersections/arcArcIntersection.d.ts +3 -0
- package/dist/types/algorithms/intersections/arcEllipseArcIntersection.d.ts +3 -0
- package/dist/types/algorithms/intersections/ellipseArcEllipseArcIntersection.d.ts +3 -0
- package/dist/types/algorithms/intersections/ellipseEllipseIntersection.d.ts +4 -0
- package/dist/types/algorithms/intersections/index.d.ts +8 -0
- package/dist/types/algorithms/intersections/lineArcIntersection.d.ts +4 -0
- package/dist/types/algorithms/intersections/lineEllipseArcIntersection.d.ts +4 -0
- package/dist/types/algorithms/intersections/lineLineIntersection.d.ts +28 -0
- package/dist/types/algorithms/intersections/rayIntersections.d.ts +3 -0
- package/dist/types/algorithms/offsets/offsetFigure.d.ts +4 -0
- package/dist/types/algorithms/offsets/offsetSegment.d.ts +12 -0
- package/dist/types/algorithms/offsets/offsetStroke.d.ts +9 -0
- package/dist/types/algorithms/optimisation/DiRect.d.ts +45 -0
- package/dist/types/algorithms/organiseLoops.d.ts +9 -0
- package/dist/types/algorithms/simplify.d.ts +3 -0
- package/dist/types/algorithms/solvers/solvePolynomials.d.ts +4 -0
- package/dist/types/algorithms/stitchSegments.d.ts +2 -0
- package/dist/types/api/drawShape.d.ts +2 -0
- package/dist/types/api/models.d.ts +1 -0
- package/dist/types/booleanOperations.d.ts +11 -0
- package/dist/types/definitions.d.ts +2 -0
- package/dist/types/draw.d.ts +47 -0
- package/dist/types/drawShape/drawCircle.d.ts +2 -0
- package/dist/types/drawShape/drawRect.d.ts +5 -0
- package/dist/types/export/json/exportJSON.d.ts +196 -0
- package/dist/types/export/json/jsonDiagram.d.ts +69 -0
- package/dist/types/export/json/jsonFigure.d.ts +66 -0
- package/dist/types/export/json/jsonLoop.d.ts +32 -0
- package/dist/types/export/json/jsonSegment.d.ts +29 -0
- package/dist/types/export/svg/exportSVG.d.ts +18 -0
- package/dist/types/export/svg/svgDiagram.d.ts +2 -0
- package/dist/types/export/svg/svgFigure.d.ts +2 -0
- package/dist/types/export/svg/svgLoop.d.ts +2 -0
- package/dist/types/export/svg/svgSegment.d.ts +2 -0
- package/dist/types/export/svg/svgStrand.d.ts +2 -0
- package/dist/types/export/svg/wrapSVG.d.ts +4 -0
- package/dist/types/import/json/importJSON.d.ts +7 -0
- package/dist/types/main.d.ts +12 -0
- package/dist/types/models/BoundingBox.d.ts +15 -0
- package/dist/types/models/Diagram.d.ts +25 -0
- package/dist/types/models/Figure.d.ts +23 -0
- package/dist/types/models/Loop.d.ts +18 -0
- package/dist/types/models/Strand.d.ts +10 -0
- package/dist/types/models/Stroke.d.ts +29 -0
- package/dist/types/models/TransformationMatrix.d.ts +31 -0
- package/dist/types/models/exports.d.ts +11 -0
- package/dist/types/models/segments/Arc.d.ts +52 -0
- package/dist/types/models/segments/EllipseArc.d.ts +70 -0
- package/dist/types/models/segments/Line.d.ts +32 -0
- package/dist/types/models/segments/Segment.d.ts +28 -0
- package/dist/types/models/utils/Transformable.d.ts +14 -0
- package/dist/types/offsetOperations.d.ts +8 -0
- package/dist/types/operations.d.ts +2 -0
- package/dist/types/utils/allCombinations.d.ts +2 -0
- package/dist/types/utils/allPairs.d.ts +1 -0
- package/dist/types/utils/angularDistance.d.ts +1 -0
- package/dist/types/utils/listOfFigures.d.ts +4 -0
- package/dist/types/utils/projectPointOnLine.d.ts +3 -0
- package/dist/types/utils/range.d.ts +1 -0
- package/dist/types/utils/removeDuplicatePoints.d.ts +2 -0
- package/dist/types/utils/unitAngle.d.ts +1 -0
- package/dist/types/utils/zip.d.ts +3 -0
- package/dist/types/vectorOperations.d.ts +23 -0
- package/package.json +29 -10
- package/dist/Diagram-9915ed5e.js +0 -1700
- package/dist/Diagram-9915ed5e.js.map +0 -1
- package/dist/Diagram-c2ca1c3b.cjs +0 -4
- package/dist/Diagram-c2ca1c3b.cjs.map +0 -1
- package/dist/draw-25b9ed64.cjs +0 -2
- package/dist/draw-25b9ed64.cjs.map +0 -1
- package/dist/draw-cd61ec6b.js +0 -256
- package/dist/draw-cd61ec6b.js.map +0 -1
- package/dist/drawShape.d.ts +0 -153
- package/dist/models.d.ts +0 -210
- package/dist/pantograph/drawShape.d.ts +0 -1
- package/dist/pantograph/models.d.ts +0 -1
- package/dist/pantograph.d.ts +0 -397
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const r=require("./Diagram-ab93c8b7.cjs");class c{constructor(t,n){this.firstPoint=t,this.lastPoint=n}}function p(s,t){if(s instanceof r.Line)return E(s,t);if(s instanceof r.Arc)return x(s,t);throw new Error("Not implemented")}function E(s,t){const{firstPoint:n,lastPoint:e}=s,i=s.normalVector;return new r.Line(r.add(n,r.scalarMultiply(i,t)),r.add(e,r.scalarMultiply(i,t)))}function x(s,t){const n=r.add(s.firstPoint,r.scalarMultiply(r.perpendicular(s.tangentAtFirstPoint),t)),e=r.add(s.lastPoint,r.scalarMultiply(r.perpendicular(s.tangentAtLastPoint),t)),i=t*(s.clockwise?1:-1);return s.radius+i<s.precision?new c(n,e):new r.Arc(n,e,s.center,s.clockwise)}function A(s,t,n){const e=r.crossProduct(s.tangentAtLastPoint,t.tangentAtFirstPoint);if(Math.abs(e)<1e-10)return null;const i=e>0?1:-1,o=Math.abs(n)*i,a=p(s,o),h=p(t,o);if(a instanceof c||h instanceof c)return null;let l;try{l=r.findIntersections(a,h,1e-9).at(-1)}catch{return null}if(!l)return null;const u=l,f=(g,T)=>{const v=T.tangentAt(u),C=r.perpendicularClockwise(v),L=r.add(u,r.scalarMultiply(C,o));return g.splitAt(L)},[P]=f(s,a),[,S]=f(t,h);return{first:P,second:S,center:u}}function m(s,t,n){const e=A(s,t,n);if(!e)return console.warn("Cannot fillet between segments",s.repr,t.repr),[s,t];const{first:i,second:o}=e;return[i,r.tangentArc(i.lastPoint,o.firstPoint,i.tangentAtLastPoint),o]}function d(s,t,n){const e=A(s,t,n);if(!e)return console.warn("Cannot chamfer between segments",s.repr,t.repr),[s,t];const{first:i,second:o}=e;return[i,new r.Line(i.lastPoint,o.firstPoint),o]}function w(s,{ignoreChecks:t=!1}={}){return new r.Diagram([new r.Figure(new r.Loop([...s],{ignoreChecks:t}))])}class D{constructor(t=[0,0]){this.pointer=t,this.firstPoint=t,this.pendingSegments=[],this._nextCorner=null}movePointerTo(t){if(this.pendingSegments.length)throw new Error("You can only move the pointer if there is no segment defined");return this.pointer=t,this.firstPoint=t,this}saveSegment(t){if(r.sameVector(t.firstPoint,t.lastPoint))throw new Error(`Segment has no length, ${t.repr}`);if(!this._nextCorner)return this.pendingSegments.push(t),this;const n=this.pendingSegments.pop();if(!n)throw new Error("bug in the custom corner algorithm");const e=this._nextCorner.mode==="chamfer"?d:m;return this.pendingSegments.push(...e(n,t,this._nextCorner.radius)),this._nextCorner=null,this}lineTo(t){const n=new r.Line(this.pointer,t);return this.pointer=t,this.saveSegment(n)}line(t,n){return this.lineTo([this.pointer[0]+t,this.pointer[1]+n])}vLine(t){return this.line(0,t)}hLine(t){return this.line(t,0)}vLineTo(t){return this.lineTo([this.pointer[0],t])}hLineTo(t){return this.lineTo([t,this.pointer[1]])}polarLineTo([t,n]){const e=n*r.DEG2RAD,i=r.polarToCartesian(t,e);return this.lineTo(i)}polarLine(t,n){const e=n*r.DEG2RAD,[i,o]=r.polarToCartesian(t,e);return this.line(i,o)}tangentLine(t){const n=this.pendingSegments.at(-1);if(!n)throw new Error("You need a previous segment to sketch a tangent line");const[e,i]=n.tangentAtLastPoint;return this.line(e*t,i*t)}threePointsArcTo(t,n){return this.saveSegment(r.threePointsArc(this.pointer,n,t)),this.pointer=t,this}threePointsArc(t,n,e,i){const[o,a]=this.pointer;return this.threePointsArcTo([o+t,a+n],[o+e,a+i])}sagittaArcTo(t,n){if(!n)return this.lineTo(t);const e=new r.Line(this.pointer,t),i=r.perpendicular(e.tangentAtFirstPoint),o=r.add(e.midPoint,r.scalarMultiply(i,n));return this.threePointsArcTo(t,o)}sagittaArc(t,n,e){return this.sagittaArcTo([t+this.pointer[0],n+this.pointer[1]],e)}vSagittaArc(t,n){return this.sagittaArc(0,t,n)}hSagittaArc(t,n){return this.sagittaArc(t,0,n)}bulgeArcTo(t,n){if(!n)return this.lineTo(t);const e=r.distance(this.pointer,t)/2,i=-n*e;return this.sagittaArcTo(t,i)}bulgeArc(t,n,e){return this.bulgeArcTo([t+this.pointer[0],n+this.pointer[1]],e)}vBulgeArc(t,n){return this.bulgeArc(0,t,n)}hBulgeArc(t,n){return this.bulgeArc(t,0,n)}tangentArcTo(t,n){const e=this.pendingSegments.at(-1);if(!e)throw new Error("You need a previous curve to sketch a tangent arc");return this.saveSegment(r.tangentArc(this.pointer,t,n??e.tangentAtLastPoint)),this.pointer=t,this}tangentArc(t,n,e){const[i,o]=this.pointer;return this.tangentArcTo([t+i,n+o],e)}ellipseTo(t,n,e,i,o,a){return this.saveSegment(r.svgEllipse(this.pointer,t,n,e,i,o,a)),this.pointer=t,this}ellipse(t,n,e,i,o,a,h){return this.ellipseTo([t+this.pointer[0],n+this.pointer[1]],e,i,o,a,h)}halfEllipseTo(t,n){const[e,i]=r.cartesianToPolar(r.subtract(t,this.pointer));return this.ellipseTo(t,e/2,Math.abs(n),i*r.RAD2DEG,!0,n>0)}halfEllipse(t,n,e){return this.halfEllipseTo([t+this.pointer[0],n+this.pointer[1]],e)}customCorner(t,n="fillet"){if(!this.pendingSegments.length)throw new Error("You need a segment defined to fillet the angle");return t?(this._nextCorner={mode:n,radius:t},this):this}_customCornerLastWithFirst(t,n="fillet"){if(!t)return;const e=this.pendingSegments.pop(),i=this.pendingSegments.shift();if(!e||!i)throw new Error("Not enough curves to close and fillet");const o=n==="chamfer"?d:m;this.pendingSegments.push(...o(e,i,t))}close(t=!1){if(!this.pendingSegments.length)throw new Error("No segments to close");const n=this.pendingSegments[0],e=this.pendingSegments.at(-1);return r.sameVector(n.firstPoint,e.lastPoint)||this.lineTo(n.firstPoint),this._nextCorner!==null&&(this._customCornerLastWithFirst(this._nextCorner.radius,this._nextCorner.mode),this._nextCorner=null),w(this.pendingSegments,{ignoreChecks:t})}closeWithMirror(t=!1){if(!this.pendingSegments.length)throw new Error("No segments to close");const n=this.pendingSegments[0],e=this.pendingSegments.at(-1),i=r.subtract(e.lastPoint,n.firstPoint),o=new r.TransformationMatrix().mirrorLine(i,n.firstPoint),a=this.pendingSegments.map(h=>h.transform(o).reverse());return a.reverse(),w([...this.pendingSegments,...a],{ignoreChecks:t})}asStrand(){return new r.Strand([...this.pendingSegments])}}function b(s=[0,0]){return new D(s)}exports.DegenerateSegment=c;exports.draw=b;exports.offsetSegment=p;
|
|
2
|
+
//# sourceMappingURL=draw-0f591ea4.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"draw-0f591ea4.cjs","sources":["../src/algorithms/offsets/offsetSegment.ts","../src/algorithms/filletSegments.ts","../src/draw.ts"],"sourcesContent":["import { Line } from \"../../models/segments/Line.js\";\nimport { Arc } from \"../../models/segments/Arc.js\";\nimport { Segment } from \"../../models/segments/Segment.js\";\nimport {\n add,\n normalize,\n perpendicular,\n scalarMultiply,\n subtract,\n} from \"../../vectorOperations\";\nimport { Vector } from \"../../definitions.js\";\n\nexport class DegenerateSegment {\n constructor(\n public readonly firstPoint: Vector,\n public readonly lastPoint: Vector\n ) {}\n}\n\nexport function offsetSegment(\n segment: Segment,\n offset: number\n): Segment | DegenerateSegment {\n if (segment instanceof Line) {\n return offsetLine(segment, offset);\n }\n\n if (segment instanceof Arc) {\n return offsetArc(segment, offset);\n }\n\n throw new Error(\"Not implemented\");\n}\n\nexport function offsetLine(line: Line, offset: number): Line {\n const { firstPoint, lastPoint } = line;\n\n const normal = line.normalVector;\n return new Line(\n add(firstPoint, scalarMultiply(normal, offset)),\n add(lastPoint, scalarMultiply(normal, offset))\n );\n}\n\nexport function offsetArc(arc: Arc, offset: number): Arc | DegenerateSegment {\n const offsetStartPoint = add(\n arc.firstPoint,\n scalarMultiply(perpendicular(arc.tangentAtFirstPoint), offset)\n );\n const offsetEndPoint = add(\n arc.lastPoint,\n scalarMultiply(perpendicular(arc.tangentAtLastPoint), offset)\n );\n\n const orientedOffset = offset * (arc.clockwise ? 1 : -1);\n const newRadius = arc.radius + orientedOffset;\n if (newRadius < arc.precision) {\n return new DegenerateSegment(offsetStartPoint, offsetEndPoint);\n }\n\n return new Arc(offsetStartPoint, offsetEndPoint, arc.center, arc.clockwise);\n}\n","import { Vector } from \"../definitions.js\";\nimport { Line } from \"../models/segments/Line.js\";\nimport { tangentArc } from \"../models/segments/Arc.js\";\nimport type { Segment } from \"../models/segments/Segment.js\";\nimport {\n add,\n crossProduct,\n perpendicular,\n perpendicularClockwise,\n scalarMultiply,\n} from \"../vectorOperations\";\nimport { findIntersections } from \"./intersections\";\nimport { DegenerateSegment, offsetSegment } from \"./offsets/offsetSegment.js\";\nimport { exportJSON } from \"../main.js\";\n\nfunction removeCorner(\n firstSegment: Segment,\n secondSegment: Segment,\n radius: number\n) {\n const sinAngle = crossProduct(\n firstSegment.tangentAtLastPoint,\n secondSegment.tangentAtFirstPoint\n );\n\n // This cover the case when the segments are colinear\n if (Math.abs(sinAngle) < 1e-10) return null;\n\n const orientationCorrection = sinAngle > 0 ? 1 : -1;\n const offset = Math.abs(radius) * orientationCorrection;\n\n const firstOffset = offsetSegment(firstSegment, offset);\n const secondOffset = offsetSegment(secondSegment, offset);\n\n if (\n firstOffset instanceof DegenerateSegment ||\n secondOffset instanceof DegenerateSegment\n ) {\n return null;\n }\n\n let potentialCenter: Vector | undefined;\n try {\n const intersections = findIntersections(firstOffset, secondOffset, 1e-9);\n\n // We need to work on the case where there are more than one intersections\n potentialCenter = intersections.at(-1);\n } catch (e) {\n return null;\n }\n\n if (!potentialCenter) {\n return null;\n }\n const center = potentialCenter;\n\n const splitForFillet = (segment: Segment, offsetSegment: Segment) => {\n const tgt = offsetSegment.tangentAt(center);\n const normal = perpendicularClockwise(tgt);\n const splitPoint = add(center, scalarMultiply(normal, offset));\n return segment.splitAt(splitPoint);\n };\n\n const [first] = splitForFillet(firstSegment, firstOffset);\n const [, second] = splitForFillet(secondSegment, secondOffset);\n\n return { first, second, center };\n}\n\nexport function filletSegments(\n firstSegment: Segment,\n secondSegment: Segment,\n radius: number\n) {\n const cornerRemoved = removeCorner(firstSegment, secondSegment, radius);\n if (!cornerRemoved) {\n console.warn(\n \"Cannot fillet between segments\",\n firstSegment.repr,\n secondSegment.repr\n );\n return [firstSegment, secondSegment];\n }\n\n const { first, second } = cornerRemoved;\n\n return [\n first,\n tangentArc(first.lastPoint, second.firstPoint, first.tangentAtLastPoint),\n second,\n ];\n}\n\nexport function chamferSegments(\n firstSegment: Segment,\n secondSegment: Segment,\n radius: number\n) {\n const cornerRemoved = removeCorner(firstSegment, secondSegment, radius);\n if (!cornerRemoved) {\n console.warn(\n \"Cannot chamfer between segments\",\n firstSegment.repr,\n secondSegment.repr\n );\n return [firstSegment, secondSegment];\n }\n\n const { first, second } = cornerRemoved;\n\n return [first, new Line(first.lastPoint, second.firstPoint), second];\n}\n","import { chamferSegments, filletSegments } from \"./algorithms/filletSegments.js\";\nimport { Vector } from \"./definitions.js\";\nimport { Strand } from \"./models/Strand.js\";\nimport { Diagram } from \"./models/Diagram.js\";\nimport { Figure } from \"./models/Figure.js\";\nimport { Loop } from \"./models/Loop.js\";\nimport { tangentArc, threePointsArc } from \"./models/segments/Arc.js\";\nimport { Line } from \"./models/segments/Line.js\";\nimport { Segment } from \"./models/segments/Segment.js\";\nimport { TransformationMatrix } from \"./models/TransformationMatrix.js\";\nimport {\n polarToCartesian,\n DEG2RAD,\n subtract,\n sameVector,\n perpendicular,\n add,\n scalarMultiply,\n distance,\n cartesianToPolar,\n RAD2DEG,\n} from \"./vectorOperations\";\nimport { svgEllipse } from \"./models/segments/EllipseArc.js\";\n\nfunction loopySegmentsToDiagram(\n segments: Segment[],\n { ignoreChecks = false } = {}\n) {\n // Here we will need to do our best to fix cases where the drawing is\n // broken in some way (i.e. self-intersecting loops)\n\n return new Diagram([new Figure(new Loop([...segments], { ignoreChecks }))]);\n}\n\nexport class DrawingPen {\n pointer: Vector;\n protected firstPoint: Vector;\n protected pendingSegments: Segment[];\n\n protected _nextCorner: { radius: number; mode: \"fillet\" | \"chamfer\" } | null;\n\n constructor(origin: Vector = [0, 0]) {\n this.pointer = origin;\n this.firstPoint = origin;\n\n this.pendingSegments = [];\n this._nextCorner = null;\n }\n\n movePointerTo(point: Vector): this {\n if (this.pendingSegments.length)\n throw new Error(\n \"You can only move the pointer if there is no segment defined\"\n );\n\n this.pointer = point;\n this.firstPoint = point;\n return this;\n }\n\n protected saveSegment(segment: Segment) {\n if (sameVector(segment.firstPoint, segment.lastPoint)) {\n throw new Error(`Segment has no length, ${segment.repr}`);\n }\n\n if (!this._nextCorner) {\n this.pendingSegments.push(segment);\n return this;\n }\n\n const previousSegment = this.pendingSegments.pop();\n if (!previousSegment) throw new Error(\"bug in the custom corner algorithm\");\n\n const makeCorner =\n this._nextCorner.mode === \"chamfer\" ? chamferSegments : filletSegments;\n\n this.pendingSegments.push(\n ...makeCorner(previousSegment, segment, this._nextCorner.radius)\n );\n this._nextCorner = null;\n return this;\n }\n\n lineTo(point: Vector): this {\n const segment = new Line(this.pointer, point);\n this.pointer = point;\n return this.saveSegment(segment);\n }\n\n line(xDist: number, yDist: number): this {\n return this.lineTo([this.pointer[0] + xDist, this.pointer[1] + yDist]);\n }\n\n vLine(distance: number): this {\n return this.line(0, distance);\n }\n\n hLine(distance: number): this {\n return this.line(distance, 0);\n }\n\n vLineTo(yPos: number): this {\n return this.lineTo([this.pointer[0], yPos]);\n }\n\n hLineTo(xPos: number): this {\n return this.lineTo([xPos, this.pointer[1]]);\n }\n\n polarLineTo([r, theta]: Vector): this {\n const angleInRads = theta * DEG2RAD;\n const point = polarToCartesian(r, angleInRads);\n return this.lineTo(point);\n }\n\n polarLine(distance: number, angle: number): this {\n const angleInRads = angle * DEG2RAD;\n const [x, y] = polarToCartesian(distance, angleInRads);\n return this.line(x, y);\n }\n\n tangentLine(distance: number): this {\n const previousCurve = this.pendingSegments.at(-1);\n\n if (!previousCurve)\n throw new Error(\"You need a previous segment to sketch a tangent line\");\n\n const [xDir, yDir] = previousCurve.tangentAtLastPoint;\n return this.line(xDir * distance, yDir * distance);\n }\n\n threePointsArcTo(end: Vector, midPoint: Vector): this {\n this.saveSegment(threePointsArc(this.pointer, midPoint, end));\n this.pointer = end;\n return this;\n }\n\n threePointsArc(\n xDist: number,\n yDist: number,\n viaXDist: number,\n viaYDist: number\n ): this {\n const [x0, y0] = this.pointer;\n return this.threePointsArcTo(\n [x0 + xDist, y0 + yDist],\n [x0 + viaXDist, y0 + viaYDist]\n );\n }\n\n sagittaArcTo(end: Vector, sagitta: number): this {\n if (!sagitta) return this.lineTo(end);\n const chord = new Line(this.pointer, end);\n const norm = perpendicular(chord.tangentAtFirstPoint);\n\n const sagPoint: Vector = add(chord.midPoint, scalarMultiply(norm, sagitta));\n\n return this.threePointsArcTo(end, sagPoint);\n }\n\n sagittaArc(xDist: number, yDist: number, sagitta: number): this {\n return this.sagittaArcTo(\n [xDist + this.pointer[0], yDist + this.pointer[1]],\n sagitta\n );\n }\n\n vSagittaArc(distance: number, sagitta: number): this {\n return this.sagittaArc(0, distance, sagitta);\n }\n\n hSagittaArc(distance: number, sagitta: number): this {\n return this.sagittaArc(distance, 0, sagitta);\n }\n\n bulgeArcTo(end: Vector, bulge: number): this {\n if (!bulge) return this.lineTo(end);\n const halfChord = distance(this.pointer, end) / 2;\n const bulgeAsSagitta = -bulge * halfChord;\n\n return this.sagittaArcTo(end, bulgeAsSagitta);\n }\n\n bulgeArc(xDist: number, yDist: number, bulge: number): this {\n return this.bulgeArcTo(\n [xDist + this.pointer[0], yDist + this.pointer[1]],\n bulge\n );\n }\n\n vBulgeArc(distance: number, bulge: number): this {\n return this.bulgeArc(0, distance, bulge);\n }\n\n hBulgeArc(distance: number, bulge: number): this {\n return this.bulgeArc(distance, 0, bulge);\n }\n\n tangentArcTo(end: Vector, tangentAtStart?: Vector): this {\n const previousCurve = this.pendingSegments.at(-1);\n\n if (!previousCurve)\n throw new Error(\"You need a previous curve to sketch a tangent arc\");\n\n this.saveSegment(\n tangentArc(\n this.pointer,\n end,\n tangentAtStart ?? previousCurve.tangentAtLastPoint\n )\n );\n\n this.pointer = end;\n return this;\n }\n\n tangentArc(xDist: number, yDist: number, tangentAtStart?: Vector): this {\n const [x0, y0] = this.pointer;\n return this.tangentArcTo([xDist + x0, yDist + y0], tangentAtStart);\n }\n\n ellipseTo(\n end: Vector,\n r0: number,\n r1: number,\n xAxisRotation: number,\n longArc: boolean,\n sweepFlag: boolean\n ): this {\n this.saveSegment(\n svgEllipse(this.pointer, end, r0, r1, xAxisRotation, longArc, sweepFlag)\n );\n this.pointer = end;\n return this;\n }\n\n ellipse(\n xDist: number,\n yDist: number,\n r0: number,\n r1: number,\n xAxisRotation: number,\n longArc: boolean,\n sweepFlag: boolean\n ): this {\n return this.ellipseTo(\n [xDist + this.pointer[0], yDist + this.pointer[1]],\n r0,\n r1,\n xAxisRotation,\n longArc,\n sweepFlag\n );\n }\n\n halfEllipseTo(end: Vector, sagitta: number): this {\n const [distance, angle] = cartesianToPolar(subtract(end, this.pointer));\n\n return this.ellipseTo(\n end,\n distance / 2,\n Math.abs(sagitta),\n angle * RAD2DEG,\n true,\n sagitta > 0\n );\n }\n\n halfEllipse(xDist: number, yDist: number, sagitta: number): this {\n return this.halfEllipseTo(\n [xDist + this.pointer[0], yDist + this.pointer[1]],\n sagitta\n );\n }\n\n customCorner(radius: number, mode: \"fillet\" | \"chamfer\" = \"fillet\") {\n if (!this.pendingSegments.length)\n throw new Error(\"You need a segment defined to fillet the angle\");\n\n if (!radius) return this;\n\n this._nextCorner = { mode, radius };\n return this;\n }\n\n protected _customCornerLastWithFirst(\n radius: number,\n mode: \"fillet\" | \"chamfer\" = \"fillet\"\n ) {\n if (!radius) return;\n\n const lastSegment = this.pendingSegments.pop();\n const firstSegment = this.pendingSegments.shift();\n\n if (!lastSegment || !firstSegment)\n throw new Error(\"Not enough curves to close and fillet\");\n\n const makeCorner = mode === \"chamfer\" ? chamferSegments : filletSegments;\n\n this.pendingSegments.push(...makeCorner(lastSegment, firstSegment, radius));\n }\n\n close(ignoreChecks = false): Diagram {\n if (!this.pendingSegments.length) throw new Error(\"No segments to close\");\n const firstSegment = this.pendingSegments[0];\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const lastSegment = this.pendingSegments.at(-1)!;\n\n if (!sameVector(firstSegment.firstPoint, lastSegment.lastPoint)) {\n this.lineTo(firstSegment.firstPoint);\n }\n\n if (this._nextCorner !== null) {\n this._customCornerLastWithFirst(\n this._nextCorner.radius,\n this._nextCorner.mode\n );\n this._nextCorner = null;\n }\n\n return loopySegmentsToDiagram(this.pendingSegments, { ignoreChecks });\n }\n\n closeWithMirror(ignoreChecks = false): Diagram {\n if (!this.pendingSegments.length) throw new Error(\"No segments to close\");\n\n const firstSegment = this.pendingSegments[0];\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const lastSegment = this.pendingSegments.at(-1)!;\n\n const mirrorVector = subtract(\n lastSegment.lastPoint,\n firstSegment.firstPoint\n );\n const mirrorTranform = new TransformationMatrix().mirrorLine(\n mirrorVector,\n firstSegment.firstPoint\n );\n\n const mirroredSegments = this.pendingSegments.map((segment) =>\n segment.transform(mirrorTranform).reverse()\n );\n mirroredSegments.reverse();\n\n return loopySegmentsToDiagram(\n [...this.pendingSegments, ...mirroredSegments],\n { ignoreChecks }\n );\n }\n\n asStrand(): Strand {\n return new Strand([...this.pendingSegments]);\n }\n}\n\nexport function draw(origin: Vector = [0, 0]): DrawingPen {\n return new DrawingPen(origin);\n}\n"],"names":["DegenerateSegment","firstPoint","lastPoint","offsetSegment","segment","offset","Line","offsetLine","Arc","offsetArc","line","normal","add","scalarMultiply","arc","offsetStartPoint","perpendicular","offsetEndPoint","orientedOffset","removeCorner","firstSegment","secondSegment","radius","sinAngle","crossProduct","orientationCorrection","firstOffset","secondOffset","potentialCenter","findIntersections","center","splitForFillet","tgt","perpendicularClockwise","splitPoint","first","second","filletSegments","cornerRemoved","tangentArc","chamferSegments","loopySegmentsToDiagram","segments","ignoreChecks","Diagram","Figure","Loop","DrawingPen","origin","point","sameVector","previousSegment","makeCorner","xDist","yDist","distance","yPos","xPos","r","theta","angleInRads","DEG2RAD","polarToCartesian","angle","x","y","previousCurve","xDir","yDir","end","midPoint","threePointsArc","viaXDist","viaYDist","x0","y0","sagitta","chord","norm","sagPoint","bulge","halfChord","bulgeAsSagitta","tangentAtStart","r0","r1","xAxisRotation","longArc","sweepFlag","svgEllipse","cartesianToPolar","subtract","RAD2DEG","mode","lastSegment","mirrorVector","mirrorTranform","TransformationMatrix","mirroredSegments","Strand","draw"],"mappings":"uDAYO,MAAMA,CAAkB,CAC7B,YACkBC,EACAC,EAChB,CAFgB,KAAA,WAAAD,EACA,KAAA,UAAAC,CACf,CACL,CAEgB,SAAAC,EACdC,EACAC,EAC6B,CAC7B,GAAID,aAAmBE,EAAAA,KACd,OAAAC,EAAWH,EAASC,CAAM,EAGnC,GAAID,aAAmBI,EAAAA,IACd,OAAAC,EAAUL,EAASC,CAAM,EAG5B,MAAA,IAAI,MAAM,iBAAiB,CACnC,CAEgB,SAAAE,EAAWG,EAAYL,EAAsB,CACrD,KAAA,CAAE,WAAAJ,EAAY,UAAAC,CAAc,EAAAQ,EAE5BC,EAASD,EAAK,aACpB,OAAO,IAAIJ,EAAA,KACTM,EAAAA,IAAIX,EAAYY,EAAAA,eAAeF,EAAQN,CAAM,CAAC,EAC9CO,EAAAA,IAAIV,EAAWW,EAAAA,eAAeF,EAAQN,CAAM,CAAC,CAAA,CAEjD,CAEgB,SAAAI,EAAUK,EAAUT,EAAyC,CAC3E,MAAMU,EAAmBH,EAAA,IACvBE,EAAI,WACJD,EAAAA,eAAeG,EAAAA,cAAcF,EAAI,mBAAmB,EAAGT,CAAM,CAAA,EAEzDY,EAAiBL,EAAA,IACrBE,EAAI,UACJD,EAAAA,eAAeG,EAAAA,cAAcF,EAAI,kBAAkB,EAAGT,CAAM,CAAA,EAGxDa,EAAiBb,GAAUS,EAAI,UAAY,EAAI,IAEjD,OADcA,EAAI,OAASI,EACfJ,EAAI,UACX,IAAId,EAAkBe,EAAkBE,CAAc,EAGxD,IAAIT,EAAAA,IAAIO,EAAkBE,EAAgBH,EAAI,OAAQA,EAAI,SAAS,CAC5E,CC9CA,SAASK,EACPC,EACAC,EACAC,EACA,CACA,MAA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ACZ1E,EAAa,UAAA,EAET4E,EAAiB,IAAIC,EAAA,qBAAA,EAAuB,WAChDF,EACA3E,EAAa,UAAA,EAGT8E,EAAmB,KAAK,gBAAgB,IAAK9F,GACjDA,EAAQ,UAAU4F,CAAc,EAAE,QAAQ,CAAA,EAE5C,OAAAE,EAAiB,QAAQ,EAElBzD,EACL,CAAC,GAAG,KAAK,gBAAiB,GAAGyD,CAAgB,EAC7C,CAAE,aAAAvD,CAAa,CAAA,CAEnB,CAEA,UAAmB,CACjB,OAAO,IAAIwD,EAAAA,OAAO,CAAC,GAAG,KAAK,eAAe,CAAC,CAC7C,CACF,CAEO,SAASC,EAAKpD,EAAiB,CAAC,EAAG,CAAC,EAAe,CACjD,OAAA,IAAID,EAAWC,CAAM,CAC9B"}
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import { o as l, A as E, g as h, h as c, y as f, u as x, v as M, C as I, G as N, t as w, H as Y, d as G, I as O, J as V, e as P, R as W, T as B, S as H, D as J, F as K, L as $, K as A, M as S } from "./Diagram-d848c815.js";
|
|
2
|
+
class m {
|
|
3
|
+
constructor(t, n) {
|
|
4
|
+
this.firstPoint = t, this.lastPoint = n;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
function T(i, t) {
|
|
8
|
+
if (i instanceof l)
|
|
9
|
+
return j(i, t);
|
|
10
|
+
if (i instanceof E)
|
|
11
|
+
return q(i, t);
|
|
12
|
+
throw new Error("Not implemented");
|
|
13
|
+
}
|
|
14
|
+
function j(i, t) {
|
|
15
|
+
const { firstPoint: n, lastPoint: e } = i, r = i.normalVector;
|
|
16
|
+
return new l(
|
|
17
|
+
h(n, c(r, t)),
|
|
18
|
+
h(e, c(r, t))
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
function q(i, t) {
|
|
22
|
+
const n = h(
|
|
23
|
+
i.firstPoint,
|
|
24
|
+
c(f(i.tangentAtFirstPoint), t)
|
|
25
|
+
), e = h(
|
|
26
|
+
i.lastPoint,
|
|
27
|
+
c(f(i.tangentAtLastPoint), t)
|
|
28
|
+
), r = t * (i.clockwise ? 1 : -1);
|
|
29
|
+
return i.radius + r < i.precision ? new m(n, e) : new E(n, e, i.center, i.clockwise);
|
|
30
|
+
}
|
|
31
|
+
function b(i, t, n) {
|
|
32
|
+
const e = M(
|
|
33
|
+
i.tangentAtLastPoint,
|
|
34
|
+
t.tangentAtFirstPoint
|
|
35
|
+
);
|
|
36
|
+
if (Math.abs(e) < 1e-10)
|
|
37
|
+
return null;
|
|
38
|
+
const r = e > 0 ? 1 : -1, s = Math.abs(n) * r, o = T(i, s), a = T(t, s);
|
|
39
|
+
if (o instanceof m || a instanceof m)
|
|
40
|
+
return null;
|
|
41
|
+
let u;
|
|
42
|
+
try {
|
|
43
|
+
u = I(o, a, 1e-9).at(-1);
|
|
44
|
+
} catch {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
if (!u)
|
|
48
|
+
return null;
|
|
49
|
+
const g = u, d = (p, y) => {
|
|
50
|
+
const F = y.tangentAt(g), R = N(F), k = h(g, c(R, s));
|
|
51
|
+
return p.splitAt(k);
|
|
52
|
+
}, [D] = d(i, o), [, _] = d(t, a);
|
|
53
|
+
return { first: D, second: _, center: g };
|
|
54
|
+
}
|
|
55
|
+
function v(i, t, n) {
|
|
56
|
+
const e = b(i, t, n);
|
|
57
|
+
if (!e)
|
|
58
|
+
return console.warn(
|
|
59
|
+
"Cannot fillet between segments",
|
|
60
|
+
i.repr,
|
|
61
|
+
t.repr
|
|
62
|
+
), [i, t];
|
|
63
|
+
const { first: r, second: s } = e;
|
|
64
|
+
return [
|
|
65
|
+
r,
|
|
66
|
+
x(r.lastPoint, s.firstPoint, r.tangentAtLastPoint),
|
|
67
|
+
s
|
|
68
|
+
];
|
|
69
|
+
}
|
|
70
|
+
function C(i, t, n) {
|
|
71
|
+
const e = b(i, t, n);
|
|
72
|
+
if (!e)
|
|
73
|
+
return console.warn(
|
|
74
|
+
"Cannot chamfer between segments",
|
|
75
|
+
i.repr,
|
|
76
|
+
t.repr
|
|
77
|
+
), [i, t];
|
|
78
|
+
const { first: r, second: s } = e;
|
|
79
|
+
return [r, new l(r.lastPoint, s.firstPoint), s];
|
|
80
|
+
}
|
|
81
|
+
function L(i, { ignoreChecks: t = !1 } = {}) {
|
|
82
|
+
return new J([new K(new $([...i], { ignoreChecks: t }))]);
|
|
83
|
+
}
|
|
84
|
+
class z {
|
|
85
|
+
constructor(t = [0, 0]) {
|
|
86
|
+
this.pointer = t, this.firstPoint = t, this.pendingSegments = [], this._nextCorner = null;
|
|
87
|
+
}
|
|
88
|
+
movePointerTo(t) {
|
|
89
|
+
if (this.pendingSegments.length)
|
|
90
|
+
throw new Error(
|
|
91
|
+
"You can only move the pointer if there is no segment defined"
|
|
92
|
+
);
|
|
93
|
+
return this.pointer = t, this.firstPoint = t, this;
|
|
94
|
+
}
|
|
95
|
+
saveSegment(t) {
|
|
96
|
+
if (w(t.firstPoint, t.lastPoint))
|
|
97
|
+
throw new Error(`Segment has no length, ${t.repr}`);
|
|
98
|
+
if (!this._nextCorner)
|
|
99
|
+
return this.pendingSegments.push(t), this;
|
|
100
|
+
const n = this.pendingSegments.pop();
|
|
101
|
+
if (!n)
|
|
102
|
+
throw new Error("bug in the custom corner algorithm");
|
|
103
|
+
const e = this._nextCorner.mode === "chamfer" ? C : v;
|
|
104
|
+
return this.pendingSegments.push(
|
|
105
|
+
...e(n, t, this._nextCorner.radius)
|
|
106
|
+
), this._nextCorner = null, this;
|
|
107
|
+
}
|
|
108
|
+
lineTo(t) {
|
|
109
|
+
const n = new l(this.pointer, t);
|
|
110
|
+
return this.pointer = t, this.saveSegment(n);
|
|
111
|
+
}
|
|
112
|
+
line(t, n) {
|
|
113
|
+
return this.lineTo([this.pointer[0] + t, this.pointer[1] + n]);
|
|
114
|
+
}
|
|
115
|
+
vLine(t) {
|
|
116
|
+
return this.line(0, t);
|
|
117
|
+
}
|
|
118
|
+
hLine(t) {
|
|
119
|
+
return this.line(t, 0);
|
|
120
|
+
}
|
|
121
|
+
vLineTo(t) {
|
|
122
|
+
return this.lineTo([this.pointer[0], t]);
|
|
123
|
+
}
|
|
124
|
+
hLineTo(t) {
|
|
125
|
+
return this.lineTo([t, this.pointer[1]]);
|
|
126
|
+
}
|
|
127
|
+
polarLineTo([t, n]) {
|
|
128
|
+
const e = n * S, r = A(t, e);
|
|
129
|
+
return this.lineTo(r);
|
|
130
|
+
}
|
|
131
|
+
polarLine(t, n) {
|
|
132
|
+
const e = n * S, [r, s] = A(t, e);
|
|
133
|
+
return this.line(r, s);
|
|
134
|
+
}
|
|
135
|
+
tangentLine(t) {
|
|
136
|
+
const n = this.pendingSegments.at(-1);
|
|
137
|
+
if (!n)
|
|
138
|
+
throw new Error("You need a previous segment to sketch a tangent line");
|
|
139
|
+
const [e, r] = n.tangentAtLastPoint;
|
|
140
|
+
return this.line(e * t, r * t);
|
|
141
|
+
}
|
|
142
|
+
threePointsArcTo(t, n) {
|
|
143
|
+
return this.saveSegment(Y(this.pointer, n, t)), this.pointer = t, this;
|
|
144
|
+
}
|
|
145
|
+
threePointsArc(t, n, e, r) {
|
|
146
|
+
const [s, o] = this.pointer;
|
|
147
|
+
return this.threePointsArcTo(
|
|
148
|
+
[s + t, o + n],
|
|
149
|
+
[s + e, o + r]
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
sagittaArcTo(t, n) {
|
|
153
|
+
if (!n)
|
|
154
|
+
return this.lineTo(t);
|
|
155
|
+
const e = new l(this.pointer, t), r = f(e.tangentAtFirstPoint), s = h(e.midPoint, c(r, n));
|
|
156
|
+
return this.threePointsArcTo(t, s);
|
|
157
|
+
}
|
|
158
|
+
sagittaArc(t, n, e) {
|
|
159
|
+
return this.sagittaArcTo(
|
|
160
|
+
[t + this.pointer[0], n + this.pointer[1]],
|
|
161
|
+
e
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
vSagittaArc(t, n) {
|
|
165
|
+
return this.sagittaArc(0, t, n);
|
|
166
|
+
}
|
|
167
|
+
hSagittaArc(t, n) {
|
|
168
|
+
return this.sagittaArc(t, 0, n);
|
|
169
|
+
}
|
|
170
|
+
bulgeArcTo(t, n) {
|
|
171
|
+
if (!n)
|
|
172
|
+
return this.lineTo(t);
|
|
173
|
+
const e = G(this.pointer, t) / 2, r = -n * e;
|
|
174
|
+
return this.sagittaArcTo(t, r);
|
|
175
|
+
}
|
|
176
|
+
bulgeArc(t, n, e) {
|
|
177
|
+
return this.bulgeArcTo(
|
|
178
|
+
[t + this.pointer[0], n + this.pointer[1]],
|
|
179
|
+
e
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
vBulgeArc(t, n) {
|
|
183
|
+
return this.bulgeArc(0, t, n);
|
|
184
|
+
}
|
|
185
|
+
hBulgeArc(t, n) {
|
|
186
|
+
return this.bulgeArc(t, 0, n);
|
|
187
|
+
}
|
|
188
|
+
tangentArcTo(t, n) {
|
|
189
|
+
const e = this.pendingSegments.at(-1);
|
|
190
|
+
if (!e)
|
|
191
|
+
throw new Error("You need a previous curve to sketch a tangent arc");
|
|
192
|
+
return this.saveSegment(
|
|
193
|
+
x(
|
|
194
|
+
this.pointer,
|
|
195
|
+
t,
|
|
196
|
+
n ?? e.tangentAtLastPoint
|
|
197
|
+
)
|
|
198
|
+
), this.pointer = t, this;
|
|
199
|
+
}
|
|
200
|
+
tangentArc(t, n, e) {
|
|
201
|
+
const [r, s] = this.pointer;
|
|
202
|
+
return this.tangentArcTo([t + r, n + s], e);
|
|
203
|
+
}
|
|
204
|
+
ellipseTo(t, n, e, r, s, o) {
|
|
205
|
+
return this.saveSegment(
|
|
206
|
+
O(this.pointer, t, n, e, r, s, o)
|
|
207
|
+
), this.pointer = t, this;
|
|
208
|
+
}
|
|
209
|
+
ellipse(t, n, e, r, s, o, a) {
|
|
210
|
+
return this.ellipseTo(
|
|
211
|
+
[t + this.pointer[0], n + this.pointer[1]],
|
|
212
|
+
e,
|
|
213
|
+
r,
|
|
214
|
+
s,
|
|
215
|
+
o,
|
|
216
|
+
a
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
halfEllipseTo(t, n) {
|
|
220
|
+
const [e, r] = V(P(t, this.pointer));
|
|
221
|
+
return this.ellipseTo(
|
|
222
|
+
t,
|
|
223
|
+
e / 2,
|
|
224
|
+
Math.abs(n),
|
|
225
|
+
r * W,
|
|
226
|
+
!0,
|
|
227
|
+
n > 0
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
halfEllipse(t, n, e) {
|
|
231
|
+
return this.halfEllipseTo(
|
|
232
|
+
[t + this.pointer[0], n + this.pointer[1]],
|
|
233
|
+
e
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
customCorner(t, n = "fillet") {
|
|
237
|
+
if (!this.pendingSegments.length)
|
|
238
|
+
throw new Error("You need a segment defined to fillet the angle");
|
|
239
|
+
return t ? (this._nextCorner = { mode: n, radius: t }, this) : this;
|
|
240
|
+
}
|
|
241
|
+
_customCornerLastWithFirst(t, n = "fillet") {
|
|
242
|
+
if (!t)
|
|
243
|
+
return;
|
|
244
|
+
const e = this.pendingSegments.pop(), r = this.pendingSegments.shift();
|
|
245
|
+
if (!e || !r)
|
|
246
|
+
throw new Error("Not enough curves to close and fillet");
|
|
247
|
+
const s = n === "chamfer" ? C : v;
|
|
248
|
+
this.pendingSegments.push(...s(e, r, t));
|
|
249
|
+
}
|
|
250
|
+
close(t = !1) {
|
|
251
|
+
if (!this.pendingSegments.length)
|
|
252
|
+
throw new Error("No segments to close");
|
|
253
|
+
const n = this.pendingSegments[0], e = this.pendingSegments.at(-1);
|
|
254
|
+
return w(n.firstPoint, e.lastPoint) || this.lineTo(n.firstPoint), this._nextCorner !== null && (this._customCornerLastWithFirst(
|
|
255
|
+
this._nextCorner.radius,
|
|
256
|
+
this._nextCorner.mode
|
|
257
|
+
), this._nextCorner = null), L(this.pendingSegments, { ignoreChecks: t });
|
|
258
|
+
}
|
|
259
|
+
closeWithMirror(t = !1) {
|
|
260
|
+
if (!this.pendingSegments.length)
|
|
261
|
+
throw new Error("No segments to close");
|
|
262
|
+
const n = this.pendingSegments[0], e = this.pendingSegments.at(-1), r = P(
|
|
263
|
+
e.lastPoint,
|
|
264
|
+
n.firstPoint
|
|
265
|
+
), s = new B().mirrorLine(
|
|
266
|
+
r,
|
|
267
|
+
n.firstPoint
|
|
268
|
+
), o = this.pendingSegments.map(
|
|
269
|
+
(a) => a.transform(s).reverse()
|
|
270
|
+
);
|
|
271
|
+
return o.reverse(), L(
|
|
272
|
+
[...this.pendingSegments, ...o],
|
|
273
|
+
{ ignoreChecks: t }
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
asStrand() {
|
|
277
|
+
return new H([...this.pendingSegments]);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
function U(i = [0, 0]) {
|
|
281
|
+
return new z(i);
|
|
282
|
+
}
|
|
283
|
+
export {
|
|
284
|
+
m as D,
|
|
285
|
+
U as d,
|
|
286
|
+
T as o
|
|
287
|
+
};
|
|
288
|
+
//# sourceMappingURL=draw-a830827a.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"draw-a830827a.js","sources":["../src/algorithms/offsets/offsetSegment.ts","../src/algorithms/filletSegments.ts","../src/draw.ts"],"sourcesContent":["import { Line } from \"../../models/segments/Line.js\";\nimport { Arc } from \"../../models/segments/Arc.js\";\nimport { Segment } from \"../../models/segments/Segment.js\";\nimport {\n add,\n normalize,\n perpendicular,\n scalarMultiply,\n subtract,\n} from \"../../vectorOperations\";\nimport { Vector } from \"../../definitions.js\";\n\nexport class DegenerateSegment {\n constructor(\n public readonly firstPoint: Vector,\n public readonly lastPoint: Vector\n ) {}\n}\n\nexport function offsetSegment(\n segment: Segment,\n offset: number\n): Segment | DegenerateSegment {\n if (segment instanceof Line) {\n return offsetLine(segment, offset);\n }\n\n if (segment instanceof Arc) {\n return offsetArc(segment, offset);\n }\n\n throw new Error(\"Not implemented\");\n}\n\nexport function offsetLine(line: Line, offset: number): Line {\n const { firstPoint, lastPoint } = line;\n\n const normal = line.normalVector;\n return new Line(\n add(firstPoint, scalarMultiply(normal, offset)),\n add(lastPoint, scalarMultiply(normal, offset))\n );\n}\n\nexport function offsetArc(arc: Arc, offset: number): Arc | DegenerateSegment {\n const offsetStartPoint = add(\n arc.firstPoint,\n scalarMultiply(perpendicular(arc.tangentAtFirstPoint), offset)\n );\n const offsetEndPoint = add(\n arc.lastPoint,\n scalarMultiply(perpendicular(arc.tangentAtLastPoint), offset)\n );\n\n const orientedOffset = offset * (arc.clockwise ? 1 : -1);\n const newRadius = arc.radius + orientedOffset;\n if (newRadius < arc.precision) {\n return new DegenerateSegment(offsetStartPoint, offsetEndPoint);\n }\n\n return new Arc(offsetStartPoint, offsetEndPoint, arc.center, arc.clockwise);\n}\n","import { Vector } from \"../definitions.js\";\nimport { Line } from \"../models/segments/Line.js\";\nimport { tangentArc } from \"../models/segments/Arc.js\";\nimport type { Segment } from \"../models/segments/Segment.js\";\nimport {\n add,\n crossProduct,\n perpendicular,\n perpendicularClockwise,\n scalarMultiply,\n} from \"../vectorOperations\";\nimport { findIntersections } from \"./intersections\";\nimport { DegenerateSegment, offsetSegment } from \"./offsets/offsetSegment.js\";\nimport { exportJSON } from \"../main.js\";\n\nfunction removeCorner(\n firstSegment: Segment,\n secondSegment: Segment,\n radius: number\n) {\n const sinAngle = crossProduct(\n firstSegment.tangentAtLastPoint,\n secondSegment.tangentAtFirstPoint\n );\n\n // This cover the case when the segments are colinear\n if (Math.abs(sinAngle) < 1e-10) return null;\n\n const orientationCorrection = sinAngle > 0 ? 1 : -1;\n const offset = Math.abs(radius) * orientationCorrection;\n\n const firstOffset = offsetSegment(firstSegment, offset);\n const secondOffset = offsetSegment(secondSegment, offset);\n\n if (\n firstOffset instanceof DegenerateSegment ||\n secondOffset instanceof DegenerateSegment\n ) {\n return null;\n }\n\n let potentialCenter: Vector | undefined;\n try {\n const intersections = findIntersections(firstOffset, secondOffset, 1e-9);\n\n // We need to work on the case where there are more than one intersections\n potentialCenter = intersections.at(-1);\n } catch (e) {\n return null;\n }\n\n if (!potentialCenter) {\n return null;\n }\n const center = potentialCenter;\n\n const splitForFillet = (segment: Segment, offsetSegment: Segment) => {\n const tgt = offsetSegment.tangentAt(center);\n const normal = perpendicularClockwise(tgt);\n const splitPoint = add(center, scalarMultiply(normal, offset));\n return segment.splitAt(splitPoint);\n };\n\n const [first] = splitForFillet(firstSegment, firstOffset);\n const [, second] = splitForFillet(secondSegment, secondOffset);\n\n return { first, second, center };\n}\n\nexport function filletSegments(\n firstSegment: Segment,\n secondSegment: Segment,\n radius: number\n) {\n const cornerRemoved = removeCorner(firstSegment, secondSegment, radius);\n if (!cornerRemoved) {\n console.warn(\n \"Cannot fillet between segments\",\n firstSegment.repr,\n secondSegment.repr\n );\n return [firstSegment, secondSegment];\n }\n\n const { first, second } = cornerRemoved;\n\n return [\n first,\n tangentArc(first.lastPoint, second.firstPoint, first.tangentAtLastPoint),\n second,\n ];\n}\n\nexport function chamferSegments(\n firstSegment: Segment,\n secondSegment: Segment,\n radius: number\n) {\n const cornerRemoved = removeCorner(firstSegment, secondSegment, radius);\n if (!cornerRemoved) {\n console.warn(\n \"Cannot chamfer between segments\",\n firstSegment.repr,\n secondSegment.repr\n );\n return [firstSegment, secondSegment];\n }\n\n const { first, second } = cornerRemoved;\n\n return [first, new Line(first.lastPoint, second.firstPoint), second];\n}\n","import { chamferSegments, filletSegments } from \"./algorithms/filletSegments.js\";\nimport { Vector } from \"./definitions.js\";\nimport { Strand } from \"./models/Strand.js\";\nimport { Diagram } from \"./models/Diagram.js\";\nimport { Figure } from \"./models/Figure.js\";\nimport { Loop } from \"./models/Loop.js\";\nimport { tangentArc, threePointsArc } from \"./models/segments/Arc.js\";\nimport { Line } from \"./models/segments/Line.js\";\nimport { Segment } from \"./models/segments/Segment.js\";\nimport { TransformationMatrix } from \"./models/TransformationMatrix.js\";\nimport {\n polarToCartesian,\n DEG2RAD,\n subtract,\n sameVector,\n perpendicular,\n add,\n scalarMultiply,\n distance,\n cartesianToPolar,\n RAD2DEG,\n} from \"./vectorOperations\";\nimport { svgEllipse } from \"./models/segments/EllipseArc.js\";\n\nfunction loopySegmentsToDiagram(\n segments: Segment[],\n { ignoreChecks = false } = {}\n) {\n // Here we will need to do our best to fix cases where the drawing is\n // broken in some way (i.e. self-intersecting loops)\n\n return new Diagram([new Figure(new Loop([...segments], { ignoreChecks }))]);\n}\n\nexport class DrawingPen {\n pointer: Vector;\n protected firstPoint: Vector;\n protected pendingSegments: Segment[];\n\n protected _nextCorner: { radius: number; mode: \"fillet\" | \"chamfer\" } | null;\n\n constructor(origin: Vector = [0, 0]) {\n this.pointer = origin;\n this.firstPoint = origin;\n\n this.pendingSegments = [];\n this._nextCorner = null;\n }\n\n movePointerTo(point: Vector): this {\n if (this.pendingSegments.length)\n throw new Error(\n \"You can only move the pointer if there is no segment defined\"\n );\n\n this.pointer = point;\n this.firstPoint = point;\n return this;\n }\n\n protected saveSegment(segment: Segment) {\n if (sameVector(segment.firstPoint, segment.lastPoint)) {\n throw new Error(`Segment has no length, ${segment.repr}`);\n }\n\n if (!this._nextCorner) {\n this.pendingSegments.push(segment);\n return this;\n }\n\n const previousSegment = this.pendingSegments.pop();\n if (!previousSegment) throw new Error(\"bug in the custom corner algorithm\");\n\n const makeCorner =\n this._nextCorner.mode === \"chamfer\" ? chamferSegments : filletSegments;\n\n this.pendingSegments.push(\n ...makeCorner(previousSegment, segment, this._nextCorner.radius)\n );\n this._nextCorner = null;\n return this;\n }\n\n lineTo(point: Vector): this {\n const segment = new Line(this.pointer, point);\n this.pointer = point;\n return this.saveSegment(segment);\n }\n\n line(xDist: number, yDist: number): this {\n return this.lineTo([this.pointer[0] + xDist, this.pointer[1] + yDist]);\n }\n\n vLine(distance: number): this {\n return this.line(0, distance);\n }\n\n hLine(distance: number): this {\n return this.line(distance, 0);\n }\n\n vLineTo(yPos: number): this {\n return this.lineTo([this.pointer[0], yPos]);\n }\n\n hLineTo(xPos: number): this {\n return this.lineTo([xPos, this.pointer[1]]);\n }\n\n polarLineTo([r, theta]: Vector): this {\n const angleInRads = theta * DEG2RAD;\n const point = polarToCartesian(r, angleInRads);\n return this.lineTo(point);\n }\n\n polarLine(distance: number, angle: number): this {\n const angleInRads = angle * DEG2RAD;\n const [x, y] = polarToCartesian(distance, angleInRads);\n return this.line(x, y);\n }\n\n tangentLine(distance: number): this {\n const previousCurve = this.pendingSegments.at(-1);\n\n if (!previousCurve)\n throw new Error(\"You need a previous segment to sketch a tangent line\");\n\n const [xDir, yDir] = previousCurve.tangentAtLastPoint;\n return this.line(xDir * distance, yDir * distance);\n }\n\n threePointsArcTo(end: Vector, midPoint: Vector): this {\n this.saveSegment(threePointsArc(this.pointer, midPoint, end));\n this.pointer = end;\n return this;\n }\n\n threePointsArc(\n xDist: number,\n yDist: number,\n viaXDist: number,\n viaYDist: number\n ): this {\n const [x0, y0] = this.pointer;\n return this.threePointsArcTo(\n [x0 + xDist, y0 + yDist],\n [x0 + viaXDist, y0 + viaYDist]\n );\n }\n\n sagittaArcTo(end: Vector, sagitta: number): this {\n if (!sagitta) return this.lineTo(end);\n const chord = new Line(this.pointer, end);\n const norm = perpendicular(chord.tangentAtFirstPoint);\n\n const sagPoint: Vector = add(chord.midPoint, scalarMultiply(norm, sagitta));\n\n return this.threePointsArcTo(end, sagPoint);\n }\n\n sagittaArc(xDist: number, yDist: number, sagitta: number): this {\n return this.sagittaArcTo(\n [xDist + this.pointer[0], yDist + this.pointer[1]],\n sagitta\n );\n }\n\n vSagittaArc(distance: number, sagitta: number): this {\n return this.sagittaArc(0, distance, sagitta);\n }\n\n hSagittaArc(distance: number, sagitta: number): this {\n return this.sagittaArc(distance, 0, sagitta);\n }\n\n bulgeArcTo(end: Vector, bulge: number): this {\n if (!bulge) return this.lineTo(end);\n const halfChord = distance(this.pointer, end) / 2;\n const bulgeAsSagitta = -bulge * halfChord;\n\n return this.sagittaArcTo(end, bulgeAsSagitta);\n }\n\n bulgeArc(xDist: number, yDist: number, bulge: number): this {\n return this.bulgeArcTo(\n [xDist + this.pointer[0], yDist + this.pointer[1]],\n bulge\n );\n }\n\n vBulgeArc(distance: number, bulge: number): this {\n return this.bulgeArc(0, distance, bulge);\n }\n\n hBulgeArc(distance: number, bulge: number): this {\n return this.bulgeArc(distance, 0, bulge);\n }\n\n tangentArcTo(end: Vector, tangentAtStart?: Vector): this {\n const previousCurve = this.pendingSegments.at(-1);\n\n if (!previousCurve)\n throw new Error(\"You need a previous curve to sketch a tangent arc\");\n\n this.saveSegment(\n tangentArc(\n this.pointer,\n end,\n tangentAtStart ?? previousCurve.tangentAtLastPoint\n )\n );\n\n this.pointer = end;\n return this;\n }\n\n tangentArc(xDist: number, yDist: number, tangentAtStart?: Vector): this {\n const [x0, y0] = this.pointer;\n return this.tangentArcTo([xDist + x0, yDist + y0], tangentAtStart);\n }\n\n ellipseTo(\n end: Vector,\n r0: number,\n r1: number,\n xAxisRotation: number,\n longArc: boolean,\n sweepFlag: boolean\n ): this {\n this.saveSegment(\n svgEllipse(this.pointer, end, r0, r1, xAxisRotation, longArc, sweepFlag)\n );\n this.pointer = end;\n return this;\n }\n\n ellipse(\n xDist: number,\n yDist: number,\n r0: number,\n r1: number,\n xAxisRotation: number,\n longArc: boolean,\n sweepFlag: boolean\n ): this {\n return this.ellipseTo(\n [xDist + this.pointer[0], yDist + this.pointer[1]],\n r0,\n r1,\n xAxisRotation,\n longArc,\n sweepFlag\n );\n }\n\n halfEllipseTo(end: Vector, sagitta: number): this {\n const [distance, angle] = cartesianToPolar(subtract(end, this.pointer));\n\n return this.ellipseTo(\n end,\n distance / 2,\n Math.abs(sagitta),\n angle * RAD2DEG,\n true,\n sagitta > 0\n );\n }\n\n halfEllipse(xDist: number, yDist: number, sagitta: number): this {\n return this.halfEllipseTo(\n [xDist + this.pointer[0], yDist + this.pointer[1]],\n sagitta\n );\n }\n\n customCorner(radius: number, mode: \"fillet\" | \"chamfer\" = \"fillet\") {\n if (!this.pendingSegments.length)\n throw new Error(\"You need a segment defined to fillet the angle\");\n\n if (!radius) return this;\n\n this._nextCorner = { mode, radius };\n return this;\n }\n\n protected _customCornerLastWithFirst(\n radius: number,\n mode: \"fillet\" | \"chamfer\" = \"fillet\"\n ) {\n if (!radius) return;\n\n const lastSegment = this.pendingSegments.pop();\n const firstSegment = this.pendingSegments.shift();\n\n if (!lastSegment || !firstSegment)\n throw new Error(\"Not enough curves to close and fillet\");\n\n const makeCorner = mode === \"chamfer\" ? chamferSegments : filletSegments;\n\n this.pendingSegments.push(...makeCorner(lastSegment, firstSegment, radius));\n }\n\n close(ignoreChecks = false): Diagram {\n if (!this.pendingSegments.length) throw new Error(\"No segments to close\");\n const firstSegment = this.pendingSegments[0];\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const lastSegment = this.pendingSegments.at(-1)!;\n\n if (!sameVector(firstSegment.firstPoint, lastSegment.lastPoint)) {\n this.lineTo(firstSegment.firstPoint);\n }\n\n if (this._nextCorner !== null) {\n this._customCornerLastWithFirst(\n this._nextCorner.radius,\n this._nextCorner.mode\n );\n this._nextCorner = null;\n }\n\n return loopySegmentsToDiagram(this.pendingSegments, { ignoreChecks });\n }\n\n closeWithMirror(ignoreChecks = false): Diagram {\n if (!this.pendingSegments.length) throw new Error(\"No segments to close\");\n\n const firstSegment = this.pendingSegments[0];\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const lastSegment = this.pendingSegments.at(-1)!;\n\n const mirrorVector = subtract(\n lastSegment.lastPoint,\n firstSegment.firstPoint\n );\n const mirrorTranform = new TransformationMatrix().mirrorLine(\n mirrorVector,\n firstSegment.firstPoint\n );\n\n const mirroredSegments = this.pendingSegments.map((segment) =>\n segment.transform(mirrorTranform).reverse()\n );\n mirroredSegments.reverse();\n\n return loopySegmentsToDiagram(\n [...this.pendingSegments, ...mirroredSegments],\n { ignoreChecks }\n );\n }\n\n asStrand(): Strand {\n return new Strand([...this.pendingSegments]);\n }\n}\n\nexport function draw(origin: Vector = [0, 0]): DrawingPen {\n return new DrawingPen(origin);\n}\n"],"names":["DegenerateSegment","firstPoint","lastPoint","offsetSegment","segment","offset","Line","offsetLine","Arc","offsetArc","line","normal","add","scalarMultiply","arc","offsetStartPoint","perpendicular","offsetEndPoint","orientedOffset","removeCorner","firstSegment","secondSegment","radius","sinAngle","crossProduct","orientationCorrection","firstOffset","secondOffset","potentialCenter","findIntersections","center","splitForFillet","tgt","perpendicularClockwise","splitPoint","first","second","filletSegments","cornerRemoved","tangentArc","chamferSegments","loopySegmentsToDiagram","segments","ignoreChecks","Diagram","Figure","Loop","DrawingPen","origin","point","sameVector","previousSegment","makeCorner","xDist","yDist","distance","yPos","xPos","r","theta","angleInRads","DEG2RAD","polarToCartesian","angle","x","y","previousCurve","xDir","yDir","end","midPoint","threePointsArc","viaXDist","viaYDist","x0","y0","sagitta","chord","norm","sagPoint","bulge","halfChord","bulgeAsSagitta","tangentAtStart","r0","r1","xAxisRotation","longArc","sweepFlag","svgEllipse","cartesianToPolar","subtract","RAD2DEG","mode","lastSegment","mirrorVector","mirrorTranform","TransformationMatrix","mirroredSegments","Strand","draw"],"mappings":";AAYO,MAAMA,EAAkB;AAAA,EAC7B,YACkBC,GACAC,GAChB;AAFgB,SAAA,aAAAD,GACA,KAAA,YAAAC;AAAA,EACf;AACL;AAEgB,SAAAC,EACdC,GACAC,GAC6B;AAC7B,MAAID,aAAmBE;AACd,WAAAC,EAAWH,GAASC,CAAM;AAGnC,MAAID,aAAmBI;AACd,WAAAC,EAAUL,GAASC,CAAM;AAG5B,QAAA,IAAI,MAAM,iBAAiB;AACnC;AAEgB,SAAAE,EAAWG,GAAYL,GAAsB;AACrD,QAAA,EAAE,YAAAJ,GAAY,WAAAC,EAAc,IAAAQ,GAE5BC,IAASD,EAAK;AACpB,SAAO,IAAIJ;AAAA,IACTM,EAAIX,GAAYY,EAAeF,GAAQN,CAAM,CAAC;AAAA,IAC9CO,EAAIV,GAAWW,E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T8E,IAAmB,KAAK,gBAAgB;AAAA,MAAI,CAAC9F,MACjDA,EAAQ,UAAU4F,CAAc,EAAE,QAAQ;AAAA,IAAA;AAE5C,WAAAE,EAAiB,QAAQ,GAElBzD;AAAA,MACL,CAAC,GAAG,KAAK,iBAAiB,GAAGyD,CAAgB;AAAA,MAC7C,EAAE,cAAAvD,EAAa;AAAA,IAAA;AAAA,EAEnB;AAAA,EAEA,WAAmB;AACjB,WAAO,IAAIwD,EAAO,CAAC,GAAG,KAAK,eAAe,CAAC;AAAA,EAC7C;AACF;AAEO,SAASC,EAAKpD,IAAiB,CAAC,GAAG,CAAC,GAAe;AACjD,SAAA,IAAID,EAAWC,CAAM;AAC9B;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
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;
|
|
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\";\nimport type { Diagram } from \"../models/Diagram\";\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\";\nimport type { Diagram } from \"../models/Diagram\";\n\nexport function drawRect(width: number
|
|
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,24 +1,20 @@
|
|
|
1
|
-
import { d as
|
|
2
|
-
import "../Diagram-
|
|
3
|
-
function
|
|
4
|
-
return
|
|
1
|
+
import { d as s } from "../draw-a830827a.js";
|
|
2
|
+
import "../Diagram-d848c815.js";
|
|
3
|
+
function x(e) {
|
|
4
|
+
return s([-e, 0]).sagittaArc(2 * e, 0, e).sagittaArc(-2 * e, 0, e).close();
|
|
5
5
|
}
|
|
6
|
-
function L(
|
|
7
|
-
const { rx: m = 0, ry:
|
|
8
|
-
let
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
if (l)
|
|
14
|
-
i.tangentArc(y, p);
|
|
15
|
-
else
|
|
16
|
-
throw new Error("disymmetric radius not implemented yet");
|
|
6
|
+
function L(e, o, r = 0) {
|
|
7
|
+
const { rx: m = 0, ry: p = 0 } = typeof r == "number" ? { ry: r, rx: r } : r;
|
|
8
|
+
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));
|
|
17
13
|
};
|
|
18
|
-
return
|
|
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();
|
|
19
15
|
}
|
|
20
16
|
export {
|
|
21
|
-
|
|
17
|
+
x as drawCircle,
|
|
22
18
|
L as drawRect
|
|
23
19
|
};
|
|
24
20
|
//# 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\";\nimport type { Diagram } from \"../models/Diagram\";\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\";\nimport type { Diagram } from \"../models/Diagram\";\n\nexport function drawRect(width: number
|
|
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-
|
|
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;
|
|
2
2
|
//# sourceMappingURL=models.cjs.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { A as s, B as o, D as n, F as i,
|
|
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";
|
|
2
2
|
export {
|
|
3
3
|
s as Arc,
|
|
4
4
|
o as BoundingBox,
|
|
5
5
|
n as Diagram,
|
|
6
6
|
i as Figure,
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
e as Line,
|
|
8
|
+
m as Loop,
|
|
9
9
|
t as Strand,
|
|
10
10
|
x as Transformable,
|
|
11
11
|
f as TransformationMatrix
|
package/dist/pantograph.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./draw-25b9ed64.cjs"),e=require("./Diagram-c2ca1c3b.cjs");function d(t){if(t instanceof e.Figure)return[t];if(t instanceof e.Loop)return[new e.Figure(t)];if(t instanceof e.Diagram)return t.figures;throw new Error("Unknown shape")}function z(t,n,r=1e-9){let o=[];const s=[],i=new Array(n.segments.length).fill(0).map(()=>[]);n.segments.forEach((c,l)=>{t.segments.forEach(a=>{const{intersections:g,overlaps:m}=e.findIntersectionsAndOverlaps(c,a,r);o.push(...g),i[l].push(...g),s.push(...m);const p=m.flatMap(u=>[u.firstPoint,u.lastPoint]);o.push(...p),i[l].push(...p)})}),o=e.removeDuplicatePoints(o,r);const f=e.zip([n.segments,i]).flatMap(([c,l])=>l.length?c.splitAt(l):[c]);return Array.from(e.strandsBetweenIntersections(f,o,s))}function y(t,n,r=!1){return z(n,t).filter(s=>{const i=s.segments[0].midPoint;return n.onStroke(i)?!r:!n.contains(i)})}function E(t,n,r=!1){return z(n,t).filter(s=>{const i=s.segments[0].midPoint;return n.onStroke(i)?!r:n.contains(i)})}function V(t,n,r=!1){const o=y(t,n.contour,r),s=n.holes.flatMap(i=>E(t,i,r));return[...o,...s]}function C(t,n,r=!1){let o=E(t,n.contour,r);return n.holes.forEach(s=>{o=o.flatMap(i=>y(i,s,r))}),o}function J(t,n){return new e.Diagram(e.fuseFiguresLists(d(t),d(n)))}function S(t){return t.reduce((n,r)=>J(n,r),new e.Diagram)}function I(t,n){return new e.Diagram(e.cutFiguresLists(d(t),d(n)))}function tt(t,n){return new e.Diagram(e.intersectFiguresLists(d(t),d(n)))}function nt(t,n,r=!0){if(n instanceof e.Loop)return y(t,n,r);if(n instanceof e.Figure)return V(t,n,r);let o=[t];return n.figures.forEach(s=>{o=o.flatMap(i=>V(i,s,r))}),o}function et(t,n,r=!1){if(n instanceof e.Loop)return E(t,n,r);if(n instanceof e.Figure)return C(t,n,r);let o=[t];return n.figures.forEach(s=>{o=o.flatMap(i=>C(i,s,r))}),o}function G(t){return t<0?"before":t>1?"after":"between"}const T=(t,n,r)=>{if(r==="before")return t.distanceFrom(n.firstPoint);if(r==="after")return t.distanceFrom(n.lastPoint);throw new Error("Invalid position")};function rt(t,n){const r=e.lineLineParams(t,n);if(r==="parallel")return Math.min(t.distanceFrom(n.firstPoint),t.distanceFrom(n.lastPoint));const{intersectionParam1:o,intersectionParam2:s}=r,i=G(o),f=G(s);if(i==="between"&&f==="between")return 0;if(i==="between"&&f!=="between")return T(t,n,f);if(f==="between"&&i!=="between")return T(n,t,i);if(i==="before"&&f==="before")return e.distance(t.firstPoint,n.firstPoint);if(i==="after"&&f==="after")return e.distance(t.lastPoint,n.lastPoint);if(i==="before"&&f==="after")return e.distance(t.firstPoint,n.lastPoint);if(i==="after"&&f==="before")return e.distance(t.lastPoint,n.firstPoint);throw new Error("Invalid position")}function R(t,n){if(e.lineArcIntersection(t,n).length>0)return 0;const r=e.projectPointOnLine(t,n.center);if(t.isOnSegment(r)){const o=e.distance(r,n.center);if(Math.abs(o-n.radius)<t.precision&&n.isOnSegment(r))return 0;if(o-n.radius>t.precision){const s=e.normalize(e.subtract(r,n.center)),i=e.add(n.center,e.scalarMultiply(s,n.radius));if(n.isOnSegment(i))return e.distance(i,r)}}return Math.min(n.distanceFrom(t.firstPoint),n.distanceFrom(t.lastPoint),t.distanceFrom(n.firstPoint),t.distanceFrom(n.lastPoint))}const ot=(t,n)=>{const r=t.angleToParam(n.firstAngle);if(t.isValidParameter(r))return!0;const o=t.angleToParam(n.lastAngle);return!!t.isValidParameter(o)};function it(t,n){if(e.arcArcIntersection(t,n,!0).length>0)return 0;const r=e.distance(t.center,n.center);if(r<t.precision&&ot(t,n))return Math.abs(t.radius-n.radius);const o=e.normalize(e.subtract(n.center,t.center)),s=r-Math.abs(t.radius-n.radius)<t.precision;let i=e.polarAngle(o);s&&n.radius>t.radius&&(i+=Math.PI);const f=s?i:i+Math.PI,c=t.angleToParam(i),l=n.angleToParam(f);return t.isValidParameter(c)&&n.isValidParameter(l)?e.distance(t.paramPoint(c),n.paramPoint(l)):Math.min(t.distanceFrom(n.firstPoint),t.distanceFrom(n.lastPoint),n.distanceFrom(t.firstPoint),n.distanceFrom(t.lastPoint))}function st(t,n){if(t instanceof e.Line&&n instanceof e.Line)return rt(t,n);if(t instanceof e.Line&&n instanceof e.Arc)return R(t,n);if(t instanceof e.Arc&&n instanceof e.Line)return R(n,t);if(t instanceof e.Arc&&n instanceof e.Arc)return it(t,n);throw new Error("Not implemented")}const b=1e-8;function F(t,n,r=!0){const o=t.map(a=>({offset:h.offsetSegment(a,n),original:a})),s=[];let i=r?null:o.at(-1),f=r?o.at(-1):null;if(s.length===1)return s;const c=a=>{i?a.offset instanceof h.DegenerateSegment?e.sameVector(a.offset.firstPoint,a.offset.lastPoint)||s.push(new e.Line(a.offset.firstPoint,a.offset.lastPoint)):s.push(a.offset):i=a},l=function*(){for(const a of o.slice(0,-1))yield a;if(!i)throw new Error("Bug in the offset algorithm");yield i};for(const a of l()){if(!f){f=a;continue}const g=f.offset.lastPoint,m=a.offset.firstPoint;if(e.sameVector(g,m)){c(f),f=a;continue}let p=[];if(!(f.offset instanceof h.DegenerateSegment)&&!(a.offset instanceof h.DegenerateSegment)){const{intersections:P,overlaps:D}=e.findIntersectionsAndOverlaps(f.offset,a.offset,b/100);p=[...P,...D.flatMap(w=>[w.firstPoint,w.lastPoint])]}if(p.length>0){let P=p[0];if(p.length>1){const _=f==null?void 0:f.original.lastPoint,k=p.map(j=>e.squareDistance(j,_));P=p[k.indexOf(Math.min(...k))]}const D=f.offset.splitAt([P])[0],w=a.offset.splitAt([P]).at(-1);if(!w)throw new Error("Bug in the splitting algo in offset");c({offset:D,original:f.original}),f={offset:w,original:a.original};continue}const u=f.original.lastPoint,A=e.crossProduct(e.subtract(m,u),e.subtract(g,u))>0,Q=new e.Arc(g,m,u,A);c(f),s.push(Q),f=a}return c(f),s}function q(t){const n=new Map,r=(o,s)=>{const i=n.get(o)||[];n.set(o,[...i,...s])};return t.forEach((o,s)=>{t.slice(s+1).forEach((i,f)=>{const{intersections:c,overlaps:l}=e.findIntersectionsAndOverlaps(o,i,b),a=[...c,...l.flatMap(g=>[g.firstPoint,g.lastPoint])].filter(g=>{const m=e.sameVector(g,o.firstPoint)||e.sameVector(g,o.lastPoint),p=e.sameVector(g,i.firstPoint)||e.sameVector(g,i.lastPoint);return!(m&&p)});a.length&&(r(s,a),r(f+s+1,a))})}),n}function W(t,n){return n.flatMap((r,o)=>{if(!t.has(o))return r;const s=t.get(o);return s?r.splitAt(s):r})}function B(t,n,r){return t.filter(o=>!n.segments.some(i=>st(i,o)<Math.abs(r)-b))}function L(t,n){const r=t.clockwise?n:-n,o=F(t.segments,r);if(o.length<2)return new e.Diagram;const s=q(o);if(!s.size){const a=new e.Loop(o);return new e.Diagram([new e.Figure(a)])}const i=W(s,o),f=B(i,t,n);if(!f.length)return new e.Diagram;const l=e.stitchSegments(f).filter(a=>a.length>1).filter(a=>e.sameVector(a[0].firstPoint,a.at(-1).lastPoint)).map(a=>new e.Loop(a));return l.length?new e.Diagram(l.map(a=>new e.Figure(a))):new e.Diagram}function ft(t,n,r="round"){const o=n/2,s=F(t.segments,o,!1),i=F(t.segments,-o,!1).map(u=>u.reverse());i.reverse();const f=(u,A)=>r==="round"?e.tangentArc(u.lastPoint,A.firstPoint,u.tangentAtLastPoint):new e.Line(u.lastPoint,A.firstPoint),c=[...s,f(s[s.length-1],i[0]),...i,f(i[i.length-1],s[0])],l=q(c);if(!l.size){const u=new e.Loop(c);return new e.Diagram([new e.Figure(u)])}const a=W(l,c),g=B(a,t,o);if(!g.length)return new e.Diagram;const p=e.stitchSegments(g).filter(u=>u.length>1).filter(u=>e.sameVector(u[0].firstPoint,u.at(-1).lastPoint)).map(u=>new e.Loop(u));return p.length?new e.Diagram(p.map(u=>new e.Figure(u))):new e.Diagram}function at(t,n){const r=t.map(o=>{const s=S(o.holes.map(i=>L(i,n)));return I(L(o.contour,n),s)});return S(r)}function ct(t,n){const r=Math.abs(n/2),o=t.map(s=>S(s.allLoops.map(i=>I(L(i,r),L(i,-r)))));return S(o)}function ut(t,n){return at(d(t),n)}function lt(t,n,{endCap:r="round"}={}){return t instanceof e.Strand?ft(t,n,r):ct(d(t),n)}function O(t){if(t instanceof e.Line)return`L ${t.lastPoint.join(" ")}`;if(t instanceof e.Arc)return`A ${t.radius} ${t.radius} 0 ${t.angularLength>Math.PI?"1":"0"} ${t.clockwise?"0":"1"} ${t.lastPoint.join(" ")}`;throw new Error("Unknown segment type")}function X(t){const n=`M ${t.firstPoint.join(" ")}`,r=t.segments.map(O).join(" ");return`${n} ${r} Z`}function Y(t){return`<path d="${t.allLoops.map(X).join(" ")}" />`}function gt(t){return`<g>
|
|
2
|
-
${t.figures.map(
|
|
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
3
|
`)}
|
|
4
|
-
</g>`}function
|
|
5
|
-
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="${
|
|
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
6
|
${t}
|
|
7
|
-
</svg>`}function
|
|
8
|
-
`),
|
|
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;
|
|
9
9
|
//# sourceMappingURL=pantograph.cjs.map
|