geometrix 0.5.10 → 0.5.11
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/index.d.ts +505 -0
- package/dist/index.js +3848 -0
- package/dist/index.js.map +1 -0
- package/package.json +6 -1
- package/.eslintignore +0 -17
- package/.eslintrc.cjs +0 -24
- package/.prettierignore +0 -15
- package/.prettierrc +0 -8
- package/src/aaExportContent.ts +0 -213
- package/src/aaExportFile.ts +0 -141
- package/src/aaParamGeom.ts +0 -62
- package/src/angle_utils.test.ts +0 -83
- package/src/angle_utils.ts +0 -98
- package/src/arc_to_stroke.ts +0 -73
- package/src/canvas_utils.test.ts +0 -28
- package/src/canvas_utils.ts +0 -159
- package/src/contour.test.ts +0 -37
- package/src/contour.ts +0 -806
- package/src/designParams.ts +0 -178
- package/src/figure.test.ts +0 -21
- package/src/figure.ts +0 -400
- package/src/index.ts +0 -16
- package/src/line.test.ts +0 -78
- package/src/line.ts +0 -359
- package/src/paramFile.ts +0 -52
- package/src/point.test.ts +0 -36
- package/src/point.ts +0 -246
- package/src/prepare_pax.ts +0 -102
- package/src/segment.test.ts +0 -26
- package/src/segment.ts +0 -701
- package/src/sub_design.ts +0 -16
- package/src/triangle_utils.test.ts +0 -38
- package/src/triangle_utils.ts +0 -112
- package/src/vector.test.ts +0 -28
- package/src/vector.ts +0 -122
- package/src/volume.ts +0 -50
- package/src/write_dxf.ts +0 -100
- package/src/write_openjscad.ts +0 -284
- package/src/write_openscad.ts +0 -305
- package/src/write_pax.ts +0 -73
- package/src/write_svg.ts +0 -101
- package/svg/any_triangle.svg +0 -156
- package/svg/arc_definition.svg +0 -506
- package/svg/construct_corner_rounded_ext_arc_ext_arc.svg +0 -378
- package/svg/construct_corner_rounded_int_arc_ext_arc.svg +0 -359
- package/svg/construct_corner_rounded_int_arc_int_arc.svg +0 -356
- package/svg/construct_corner_rounded_stroke_ext_arc.svg +0 -374
- package/svg/construct_corner_rounded_stroke_ext_arc_obtuse.svg +0 -370
- package/svg/construct_corner_rounded_stroke_ext_arc_obtuse_method2.svg +0 -311
- package/svg/construct_corner_rounded_stroke_int_arc.svg +0 -364
- package/svg/construct_corner_rounded_stroke_int_arc_obtuse.svg +0 -358
- package/svg/construct_corner_rounded_stroke_int_arc_obtuse_method2.svg +0 -237
- package/svg/construct_corner_rounded_stroke_stroke.svg +0 -280
- package/svg/construct_corner_wideacc.svg +0 -286
- package/svg/construct_corner_widened.svg +0 -278
- package/svg/construction_of_line_intersection_1.svg +0 -187
- package/svg/construction_of_line_intersection_2.svg +0 -189
- package/svg/contour_arc_definition_options.svg +0 -324
- package/svg/contour_point_absolute_relative.svg +0 -258
- package/svg/contour_tangential_two_arcs.svg +0 -531
- package/svg/contour_tangential_two_arcs_impossible_case.svg +0 -175
- package/svg/contour_tangential_two_arcs_requirements.svg +0 -364
- package/svg/corner_rounded_ext_arc_ext_arc.svg +0 -281
- package/svg/corner_rounded_int_arc_ext_arc.svg +0 -281
- package/svg/corner_rounded_int_arc_int_arc.svg +0 -279
- package/svg/corner_rounded_stroke_ext_arc.svg +0 -218
- package/svg/corner_rounded_stroke_int_arc.svg +0 -225
- package/svg/corner_rounded_stroke_stroke.svg +0 -174
- package/svg/geom_dev.svg +0 -14708
- package/svg/geom_modules.svg +0 -246
- package/svg/geom_user.svg +0 -58
- package/svg/line_axis_x_cases.svg +0 -1408
- package/svg/line_axis_y_cases.svg +0 -1369
- package/svg/line_distanceOrig.svg +0 -318
- package/svg/line_getAxisXIntersection.svg +0 -262
- package/svg/line_getAxisXIntersection_2.svg +0 -244
- package/svg/line_getAxisYIntersection.svg +0 -304
- package/svg/line_getAxisYIntersection_2.svg +0 -285
- package/svg/line_getAxisYIntersection_3.svg +0 -277
- package/svg/line_intersection.svg +0 -346
- package/svg/line_projectPoint.svg +0 -311
- package/svg/point_1.svg +0 -243
- package/svg/point_2.svg +0 -409
- package/svg/point_3.svg +0 -298
- package/svg/point_4.svg +0 -272
- package/svg/point_5.svg +0 -356
- package/svg/right_triangle.svg +0 -194
- package/svg/vector_definition.svg +0 -130
- package/tsconfig.json +0 -13
- package/vitest.config.ts +0 -7
package/src/write_svg.ts
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
// write_svg.ts
|
|
2
|
-
|
|
3
|
-
// floating precision for svg export
|
|
4
|
-
function ff(ifloat: number): string {
|
|
5
|
-
return ifloat.toFixed(4);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
function svgCircleString(cx: number, cy: number, radius: number, color = ''): string {
|
|
9
|
-
let sColor = color;
|
|
10
|
-
if (sColor === '') {
|
|
11
|
-
sColor = 'black';
|
|
12
|
-
}
|
|
13
|
-
const rSvg = `<circle cx="${ff(cx)}" cy="${ff(cy)}" r="${ff(
|
|
14
|
-
radius
|
|
15
|
-
)}" stroke="${sColor}" stroke-width="1" fill="none" />`;
|
|
16
|
-
return rSvg;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
class SvgPath {
|
|
20
|
-
pathD: string;
|
|
21
|
-
constructor() {
|
|
22
|
-
this.pathD = '';
|
|
23
|
-
}
|
|
24
|
-
addStart(px: number, py: number) {
|
|
25
|
-
this.pathD = `M ${ff(px)} ${ff(py)}`;
|
|
26
|
-
}
|
|
27
|
-
addStroke(px: number, py: number) {
|
|
28
|
-
this.pathD += ` L ${ff(px)} ${ff(py)}`;
|
|
29
|
-
}
|
|
30
|
-
addArc(px: number, py: number, radius: number, large: boolean, ccw: boolean) {
|
|
31
|
-
const aRadius = ff(radius);
|
|
32
|
-
const aLarge = large ? 1 : 0;
|
|
33
|
-
const aCcw = ccw ? 1 : 0;
|
|
34
|
-
this.pathD += ` A ${aRadius} ${aRadius} 0 ${aLarge} ${aCcw} ${ff(px)} ${ff(py)}`;
|
|
35
|
-
}
|
|
36
|
-
stringify(color = ''): string {
|
|
37
|
-
let sColor = color;
|
|
38
|
-
if (sColor === '') {
|
|
39
|
-
sColor = 'black';
|
|
40
|
-
}
|
|
41
|
-
const rSvg = `<path d="${this.pathD} Z" stroke="${sColor}" stroke-width="1" fill="none" />`;
|
|
42
|
-
return rSvg;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
function svgPath(): SvgPath {
|
|
46
|
-
const rSvgPath = new SvgPath();
|
|
47
|
-
return rSvgPath;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
class SvgWriter {
|
|
51
|
-
svgStr: string;
|
|
52
|
-
payloadStr: string;
|
|
53
|
-
groupActive: boolean;
|
|
54
|
-
constructor() {
|
|
55
|
-
this.payloadStr = '';
|
|
56
|
-
this.svgStr = '';
|
|
57
|
-
this.groupActive = false;
|
|
58
|
-
}
|
|
59
|
-
addHeader(xMin: number, xWidth: number, yMin: number, yHeight: number) {
|
|
60
|
-
const viewBoxValues = `${xMin} ${yMin} ${xWidth} ${yHeight}`;
|
|
61
|
-
this.svgStr = `<svg width="${xWidth}" height="${yHeight}" viewBox="${viewBoxValues}" xmlns="http://www.w3.org/2000/svg">`;
|
|
62
|
-
}
|
|
63
|
-
addSvgString(svgString: string) {
|
|
64
|
-
this.payloadStr += svgString;
|
|
65
|
-
}
|
|
66
|
-
addGroup(groupId: string) {
|
|
67
|
-
if (this.groupActive) {
|
|
68
|
-
throw `err321: group must be closed before opening a new one`;
|
|
69
|
-
}
|
|
70
|
-
this.groupActive = true;
|
|
71
|
-
this.payloadStr += `<g id="${groupId}">`;
|
|
72
|
-
}
|
|
73
|
-
closeGroup() {
|
|
74
|
-
if (!this.groupActive) {
|
|
75
|
-
throw `err331: group is not active so can not be closed`;
|
|
76
|
-
}
|
|
77
|
-
this.groupActive = false;
|
|
78
|
-
this.payloadStr += `</g>`;
|
|
79
|
-
}
|
|
80
|
-
closeSvg() {
|
|
81
|
-
if (this.svgStr === '') {
|
|
82
|
-
throw `err301: no header set for the svg`;
|
|
83
|
-
}
|
|
84
|
-
if (this.groupActive) {
|
|
85
|
-
throw `err311: group is not closed`;
|
|
86
|
-
}
|
|
87
|
-
this.svgStr += this.payloadStr;
|
|
88
|
-
this.svgStr += '</svg>';
|
|
89
|
-
}
|
|
90
|
-
stringify(): string {
|
|
91
|
-
this.closeSvg();
|
|
92
|
-
return this.svgStr;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
function svgWriter(): SvgWriter {
|
|
96
|
-
const rSvgWrite = new SvgWriter();
|
|
97
|
-
return rSvgWrite;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export type { SvgWriter };
|
|
101
|
-
export { svgWriter, svgPath, svgCircleString };
|
package/svg/any_triangle.svg
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
2
|
-
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
|
3
|
-
|
|
4
|
-
<svg
|
|
5
|
-
width="460.39359"
|
|
6
|
-
height="259.42465"
|
|
7
|
-
viewBox="0 0 121.81247 68.639438"
|
|
8
|
-
version="1.1"
|
|
9
|
-
id="svg5"
|
|
10
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
11
|
-
xmlns:svg="http://www.w3.org/2000/svg">
|
|
12
|
-
<defs
|
|
13
|
-
id="defs2">
|
|
14
|
-
<rect
|
|
15
|
-
x="87.276482"
|
|
16
|
-
y="1607.4351"
|
|
17
|
-
width="173.18967"
|
|
18
|
-
height="33.099987"
|
|
19
|
-
id="rect10539" />
|
|
20
|
-
<rect
|
|
21
|
-
x="96.984451"
|
|
22
|
-
y="1526.132"
|
|
23
|
-
width="449.84814"
|
|
24
|
-
height="90.778786"
|
|
25
|
-
id="rect10088" />
|
|
26
|
-
<rect
|
|
27
|
-
x="249.72469"
|
|
28
|
-
y="1486.9099"
|
|
29
|
-
width="49.603531"
|
|
30
|
-
height="34.091686"
|
|
31
|
-
id="rect10082" />
|
|
32
|
-
<rect
|
|
33
|
-
x="107.98836"
|
|
34
|
-
y="1446.2595"
|
|
35
|
-
width="32.484531"
|
|
36
|
-
height="20.270607"
|
|
37
|
-
id="rect10076" />
|
|
38
|
-
<rect
|
|
39
|
-
x="189.86275"
|
|
40
|
-
y="1392.5359"
|
|
41
|
-
width="60.001274"
|
|
42
|
-
height="29.567495"
|
|
43
|
-
id="rect10070" />
|
|
44
|
-
<rect
|
|
45
|
-
x="79.375404"
|
|
46
|
-
y="1381.2556"
|
|
47
|
-
width="49.382896"
|
|
48
|
-
height="33.743313"
|
|
49
|
-
id="rect10064" />
|
|
50
|
-
<rect
|
|
51
|
-
x="333.58478"
|
|
52
|
-
y="1440.7738"
|
|
53
|
-
width="30.296755"
|
|
54
|
-
height="32.721424"
|
|
55
|
-
id="rect10058" />
|
|
56
|
-
<rect
|
|
57
|
-
x="156.53516"
|
|
58
|
-
y="1496.7665"
|
|
59
|
-
width="52.288319"
|
|
60
|
-
height="39.788731"
|
|
61
|
-
id="rect10052" />
|
|
62
|
-
</defs>
|
|
63
|
-
<g
|
|
64
|
-
id="layer1"
|
|
65
|
-
transform="translate(-18.145084,-364.43451)">
|
|
66
|
-
<rect
|
|
67
|
-
style="fill:#ffffff;stroke:#ffffff;stroke-width:0.264583;stroke-dasharray:none;stroke-dashoffset:0"
|
|
68
|
-
id="rect10548"
|
|
69
|
-
width="121.54787"
|
|
70
|
-
height="68.374863"
|
|
71
|
-
x="18.277376"
|
|
72
|
-
y="364.5668" />
|
|
73
|
-
<path
|
|
74
|
-
style="fill:none;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
|
75
|
-
d="m 29.961281,369.86802 18.225146,26.59079 38.761383,-11.9211 z"
|
|
76
|
-
id="path10048" />
|
|
77
|
-
<text
|
|
78
|
-
xml:space="preserve"
|
|
79
|
-
transform="matrix(0.26458333,0,0,0.26458333,4.4544346,0.5106408)"
|
|
80
|
-
id="text10050"
|
|
81
|
-
style="font-size:14.6667px;line-height:1.25;font-family:sans-serif;white-space:pre;shape-inside:url(#rect10052);display:inline"><tspan
|
|
82
|
-
x="156.53516"
|
|
83
|
-
y="1509.7422"
|
|
84
|
-
id="tspan26335">A</tspan></text>
|
|
85
|
-
<text
|
|
86
|
-
xml:space="preserve"
|
|
87
|
-
transform="matrix(0.26458333,0,0,0.26458333,0.36500678,1.822576)"
|
|
88
|
-
id="text10056"
|
|
89
|
-
style="font-size:14.6667px;line-height:1.25;font-family:sans-serif;white-space:pre;shape-inside:url(#rect10058);display:inline"><tspan
|
|
90
|
-
x="333.58398"
|
|
91
|
-
y="1453.75"
|
|
92
|
-
id="tspan26337">B</tspan></text>
|
|
93
|
-
<text
|
|
94
|
-
xml:space="preserve"
|
|
95
|
-
transform="matrix(0.26458333,0,0,0.26458333,5.2262335,2.2011015)"
|
|
96
|
-
id="text10062"
|
|
97
|
-
style="font-size:14.6667px;line-height:1.25;font-family:sans-serif;white-space:pre;shape-inside:url(#rect10064);display:inline"><tspan
|
|
98
|
-
x="79.375"
|
|
99
|
-
y="1394.2325"
|
|
100
|
-
id="tspan26339">C</tspan></text>
|
|
101
|
-
<text
|
|
102
|
-
xml:space="preserve"
|
|
103
|
-
transform="matrix(0.26458333,0,0,0.26458333,8.4719672,4.6977725)"
|
|
104
|
-
id="text10068"
|
|
105
|
-
style="font-size:14.6667px;line-height:1.25;font-family:sans-serif;white-space:pre;shape-inside:url(#rect10070);display:inline"><tspan
|
|
106
|
-
x="189.86328"
|
|
107
|
-
y="1405.5117"
|
|
108
|
-
id="tspan26341">a</tspan></text>
|
|
109
|
-
<text
|
|
110
|
-
xml:space="preserve"
|
|
111
|
-
transform="matrix(0.26458333,0,0,0.26458333,8.105117,-0.22674664)"
|
|
112
|
-
id="text10074"
|
|
113
|
-
style="font-size:14.6667px;line-height:1.25;font-family:sans-serif;white-space:pre;shape-inside:url(#rect10076);display:inline"><tspan
|
|
114
|
-
x="107.98828"
|
|
115
|
-
y="1459.2364"
|
|
116
|
-
id="tspan26343">b</tspan></text>
|
|
117
|
-
<text
|
|
118
|
-
xml:space="preserve"
|
|
119
|
-
transform="matrix(0.26458333,0,0,0.26458333,-1.4839922,-2.933573)"
|
|
120
|
-
id="text10080"
|
|
121
|
-
style="font-size:14.6667px;line-height:1.25;font-family:sans-serif;white-space:pre;shape-inside:url(#rect10082);display:inline"><tspan
|
|
122
|
-
x="249.72461"
|
|
123
|
-
y="1499.8867"
|
|
124
|
-
id="tspan26345">c</tspan></text>
|
|
125
|
-
<text
|
|
126
|
-
xml:space="preserve"
|
|
127
|
-
transform="matrix(0.26458333,0,0,0.26458333,-0.87196065,1.7881646)"
|
|
128
|
-
id="text10086"
|
|
129
|
-
style="font-size:14.6667px;line-height:1.25;font-family:sans-serif;white-space:pre;shape-inside:url(#rect10088);display:inline"><tspan
|
|
130
|
-
x="96.984375"
|
|
131
|
-
y="1539.1094"
|
|
132
|
-
id="tspan26347">A + B + C = Math.PI
|
|
133
|
-
</tspan><tspan
|
|
134
|
-
x="96.984375"
|
|
135
|
-
y="1557.4428"
|
|
136
|
-
id="tspan26355">c<tspan
|
|
137
|
-
style="font-size:65%;baseline-shift:super"
|
|
138
|
-
id="tspan26349">2</tspan> = a<tspan
|
|
139
|
-
style="font-size:65%;baseline-shift:super"
|
|
140
|
-
id="tspan26351">2</tspan> + b<tspan
|
|
141
|
-
style="font-size:65%;baseline-shift:super"
|
|
142
|
-
id="tspan26353">2</tspan> - 2*a*b*cos(C) [Al-Kashi or Law of cosinus]
|
|
143
|
-
</tspan><tspan
|
|
144
|
-
x="96.984375"
|
|
145
|
-
y="1575.7762"
|
|
146
|
-
id="tspan26357">a / sin(A) = b / sin(B) = c / sin(C) [Law of sinus]</tspan></text>
|
|
147
|
-
<text
|
|
148
|
-
xml:space="preserve"
|
|
149
|
-
transform="matrix(0.26458333,0,0,0.26458333,-2.3117096,1.1005508)"
|
|
150
|
-
id="text10537"
|
|
151
|
-
style="font-size:14.6667px;line-height:1.25;font-family:sans-serif;white-space:pre;shape-inside:url(#rect10539);display:inline"><tspan
|
|
152
|
-
x="87.277344"
|
|
153
|
-
y="1620.4121"
|
|
154
|
-
id="tspan26359">any triangle</tspan></text>
|
|
155
|
-
</g>
|
|
156
|
-
</svg>
|