pantograph2d 0.9.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/{QuadraticBezier-BKElJOgn.cjs → QuadraticBezier--UZr_xcV.cjs} +2 -2
  2. package/dist/QuadraticBezier--UZr_xcV.cjs.map +1 -0
  3. package/dist/{QuadraticBezier-PcRS9HZK.js → QuadraticBezier-DxieHk9z.js} +4 -2
  4. package/dist/QuadraticBezier-DxieHk9z.js.map +1 -0
  5. package/dist/{draw-L71G180-.cjs → draw-SMxwuKNJ.cjs} +2 -2
  6. package/dist/{draw-L71G180-.cjs.map → draw-SMxwuKNJ.cjs.map} +1 -1
  7. package/dist/{draw-N2ntigsw.js → draw-yb7FrCL_.js} +4 -3
  8. package/dist/{draw-N2ntigsw.js.map → draw-yb7FrCL_.js.map} +1 -1
  9. package/dist/{models-BXU-Gx3U.cjs → models-wvgj1vj2.cjs} +2 -2
  10. package/dist/{models-BXU-Gx3U.cjs.map → models-wvgj1vj2.cjs.map} +1 -1
  11. package/dist/{models-BjaFYsN2.js → models-zEMLdtLw.js} +2 -2
  12. package/dist/{models-BjaFYsN2.js.map → models-zEMLdtLw.js.map} +1 -1
  13. package/dist/pantograph/drawShape.cjs +1 -1
  14. package/dist/pantograph/drawShape.js +1 -1
  15. package/dist/pantograph/models.cjs +1 -1
  16. package/dist/pantograph/models.js +2 -2
  17. package/dist/pantograph/svg.cjs +1 -1
  18. package/dist/pantograph/svg.js +1 -1
  19. package/dist/pantograph.cjs +2 -2
  20. package/dist/pantograph.cjs.map +1 -1
  21. package/dist/pantograph.js +620 -425
  22. package/dist/pantograph.js.map +1 -1
  23. package/dist/{svg-hNHYuj_r.js → svg-BIphc_zE.js} +3 -3
  24. package/dist/{svg-hNHYuj_r.js.map → svg-BIphc_zE.js.map} +1 -1
  25. package/dist/{svg-ZTvNxsWu.cjs → svg-BY5h3CDD.cjs} +3 -3
  26. package/dist/{svg-ZTvNxsWu.cjs.map → svg-BY5h3CDD.cjs.map} +1 -1
  27. package/dist/types/src/featureOperations.d.ts +88 -0
  28. package/dist/types/src/main.d.ts +1 -1
  29. package/dist/types/src/operations.d.ts +1 -0
  30. package/dist/types/src/vectorOperations.d.ts +1 -1
  31. package/package.json +2 -2
  32. package/dist/QuadraticBezier-BKElJOgn.cjs.map +0 -1
  33. package/dist/QuadraticBezier-PcRS9HZK.js.map +0 -1
@@ -0,0 +1,88 @@
1
+ import { Vector } from './definitions';
2
+ import { Diagram, Figure, Loop, Segment, Strand } from './models/exports';
3
+ export type FilterFcn<Type> = {
4
+ element: Type;
5
+ };
6
+ export declare abstract class FilterList<Type> {
7
+ protected filters: (({ element }: FilterFcn<Type>) => boolean)[];
8
+ abstract shouldKeep(t: Type): boolean;
9
+ constructor();
10
+ delete(): void;
11
+ /**
12
+ * Combine logically a set of filter with an AND operation.
13
+ *
14
+ */
15
+ and(findersList: ((f: this) => this)[]): this;
16
+ /**
17
+ * Invert the result of a particular filter
18
+ *
19
+ */
20
+ not(finderFun: (f: this) => this): this;
21
+ /**
22
+ * Combine logically a set of filter with an OR operation.
23
+ *
24
+ */
25
+ either(findersList: ((f: this) => this)[]): this;
26
+ }
27
+ export type Corner = {
28
+ firstCurve: Segment;
29
+ secondCurve: Segment;
30
+ point: Vector;
31
+ };
32
+ export declare class CornerFilter extends FilterList<Corner> {
33
+ clone(): CornerFilter;
34
+ /**
35
+ * Filter to find corner that have their point are in the list.
36
+ *
37
+ */
38
+ inList(elementList: Vector[]): this;
39
+ /**
40
+ * Filter to find elements that are at a specified distance from a point.
41
+ *
42
+ */
43
+ atDistance(dist: number, point?: Vector): this;
44
+ /**
45
+ * Filter to find elements that contain a certain point
46
+ *
47
+ * @category Filter
48
+ */
49
+ atPoint(point: Vector): this;
50
+ /**
51
+ * Filter to find elements that are within a box
52
+ *
53
+ * @category Filter
54
+ */
55
+ inBox(corner1: Vector, corner2: Vector): this;
56
+ /**
57
+ * Filter to find corner that a certain angle between them - only between
58
+ * 0 and 180.
59
+ *
60
+ */
61
+ ofAngle(theta: number): this;
62
+ above(yValue?: number): this;
63
+ below(yValue?: number): this;
64
+ leftOf(xValue?: number): this;
65
+ rightOf(xValue?: number): this;
66
+ shouldKeep(element: Corner): boolean;
67
+ asFilterFun(): (element: Corner) => boolean;
68
+ }
69
+ export type Shape = Loop | Strand | Figure | Diagram;
70
+ export type FilterArg = CornerFilter | ((c: CornerFilter) => CornerFilter);
71
+ declare function fillet<T extends Shape>(shape: T, radius: number, filter?: FilterArg): T;
72
+ declare function fillet(shape: Loop, radius: number, filter?: FilterArg): Loop;
73
+ declare function fillet(shape: Strand, radius: number, filter?: FilterArg): Strand;
74
+ declare function fillet(shape: Figure, radius: number, filter?: FilterArg): Figure;
75
+ declare function fillet(shape: Diagram, radius: number, filter?: FilterArg): Diagram;
76
+ declare function chamfer<T extends Shape>(shape: T, radius: number, filter?: FilterArg): T;
77
+ declare function chamfer(shape: Loop, radius: number, filter?: FilterArg): Loop;
78
+ declare function chamfer(shape: Strand, radius: number, filter?: FilterArg): Strand;
79
+ declare function chamfer(shape: Figure, radius: number, filter?: FilterArg): Figure;
80
+ declare function chamfer(shape: Diagram, radius: number, filter?: FilterArg): Diagram;
81
+ declare class CornerSelector<T extends Shape> extends CornerFilter {
82
+ private readonly shape;
83
+ constructor(shape: T);
84
+ fillet(radius: number): T;
85
+ chamfer(radius: number): T;
86
+ }
87
+ declare function selectCorners<T extends Shape>(s: T): CornerSelector<T>;
88
+ export { fillet, chamfer, selectCorners };
@@ -6,7 +6,7 @@ export declare function polarToCartesian(r: number, theta: number): Vector;
6
6
  export declare function cartesianToPolar([x, y]: Vector): [number, number];
7
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
- export { fuseAll, fuse, cut, intersect, eraseStrand, confineStrand, offset, outlineStroke, } from './operations.js';
9
+ export { fuseAll, fuse, cut, intersect, eraseStrand, confineStrand, offset, outlineStroke, fillet, chamfer, selectCorners, } from './operations.js';
10
10
  export { exportSVG, svgBody } from './export/svg/exportSVG.js';
11
11
  export { exportJSON } from './export/json/exportJSON.js';
12
12
  export { importJSON } from './import/json/importJSON.js';
@@ -1,2 +1,3 @@
1
1
  export * from './booleanOperations.js';
2
2
  export * from './offsetOperations.js';
3
+ export * from './featureOperations.js';
@@ -12,7 +12,7 @@ export declare const squareDistance: ([x0, y0]: Vector, [x1, y1]?: Vector) => nu
12
12
  export declare const distance: (p0: Vector, p1?: Vector) => number;
13
13
  export declare function crossProduct([x0, y0]: Vector, [x1, y1]: Vector): number;
14
14
  export declare function dotProduct([x0, y0]: Vector, [x1, y1]: Vector): number;
15
- export declare const angle: ([x0, y0]: Vector, [x1, y1]?: Vector) => number;
15
+ export declare function angle([x0, y0]: Vector, [x1, y1]?: Vector): number;
16
16
  export declare function normalize([x0, y0]: Vector): Vector;
17
17
  export declare function polarToCartesian(r: number, theta: number): Vector;
18
18
  export declare function polarAngle([x, y]: Vector): number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pantograph2d",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "Pantograph, the pure JS 2D CAD library",
5
5
  "type": "module",
6
6
  "main": "./dist/pantograph.cjs",
@@ -77,7 +77,7 @@
77
77
  "vitest": "^2.1.3",
78
78
  "xmldom": "^0.6.0"
79
79
  },
80
- "gitHead": "ec23efee0bc0f6058b55fad89b4424faafad0e1e",
80
+ "gitHead": "c215d4bdc85c6f95e1c8807c1930df869de34b42",
81
81
  "dependencies": {
82
82
  "@types/flatbush": "^4.2.2",
83
83
  "flatbush": "^4.4.0",