From c66f23577ad5bd3ce6bdaeeff4c5cd2d290dcea2 Mon Sep 17 00:00:00 2001 From: gumyr Date: Sun, 30 Jul 2023 10:39:29 -0400 Subject: [PATCH] Updated to adapt to svg line_weight change --- docs/assets/bezier_curve_example.svg | 4 +- docs/assets/buildline_example_1.svg | 4 +- docs/assets/buildline_example_5.svg | 6 +- docs/assets/buildline_example_6.svg | 4 +- docs/assets/buildline_example_7.svg | 10 +-- docs/assets/buildline_example_8.svg | 4 +- docs/assets/center_arc_example.svg | 4 +- docs/assets/elliptical_center_arc_example.svg | 4 +- docs/assets/filletpolyline_example.svg | 8 +- docs/assets/helix_example.svg | 4 +- docs/assets/jern_arc_example.svg | 8 +- docs/assets/line_example.svg | 4 +- docs/assets/polar_line_example.svg | 6 +- docs/assets/polyline_example.svg | 4 +- docs/assets/radius_arc_example.svg | 4 +- docs/assets/sagitta_arc_example.svg | 4 +- docs/assets/spline_example.svg | 4 +- docs/assets/tangent_arc_example.svg | 8 +- docs/assets/three_point_arc_example.svg | 4 +- docs/objects_1d.py | 82 +++++++++++-------- 20 files changed, 97 insertions(+), 83 deletions(-) diff --git a/docs/assets/bezier_curve_example.svg b/docs/assets/bezier_curve_example.svg index 3890c8e..1f506f8 100644 --- a/docs/assets/bezier_curve_example.svg +++ b/docs/assets/bezier_curve_example.svg @@ -1,7 +1,7 @@ - + - + diff --git a/docs/assets/buildline_example_1.svg b/docs/assets/buildline_example_1.svg index 2e6ab0c..26ed31f 100644 --- a/docs/assets/buildline_example_1.svg +++ b/docs/assets/buildline_example_1.svg @@ -1,7 +1,7 @@ - + - + diff --git a/docs/assets/buildline_example_5.svg b/docs/assets/buildline_example_5.svg index fcf6a80..eeb26d8 100644 --- a/docs/assets/buildline_example_5.svg +++ b/docs/assets/buildline_example_5.svg @@ -1,7 +1,7 @@ - + - + @@ -10,7 +10,7 @@ - + diff --git a/docs/assets/buildline_example_6.svg b/docs/assets/buildline_example_6.svg index 33425ad..6c31c81 100644 --- a/docs/assets/buildline_example_6.svg +++ b/docs/assets/buildline_example_6.svg @@ -1,7 +1,7 @@ - + - + diff --git a/docs/assets/buildline_example_7.svg b/docs/assets/buildline_example_7.svg index 94313e0..2f4428a 100644 --- a/docs/assets/buildline_example_7.svg +++ b/docs/assets/buildline_example_7.svg @@ -1,16 +1,16 @@ - + - + - - - + + + diff --git a/docs/assets/buildline_example_8.svg b/docs/assets/buildline_example_8.svg index 113a494..4684488 100644 --- a/docs/assets/buildline_example_8.svg +++ b/docs/assets/buildline_example_8.svg @@ -1,7 +1,7 @@ - + - + diff --git a/docs/assets/center_arc_example.svg b/docs/assets/center_arc_example.svg index 7843431..fbe13dc 100644 --- a/docs/assets/center_arc_example.svg +++ b/docs/assets/center_arc_example.svg @@ -1,7 +1,7 @@ - + - + diff --git a/docs/assets/elliptical_center_arc_example.svg b/docs/assets/elliptical_center_arc_example.svg index ee73050..ae7426e 100644 --- a/docs/assets/elliptical_center_arc_example.svg +++ b/docs/assets/elliptical_center_arc_example.svg @@ -1,7 +1,7 @@ - + - + diff --git a/docs/assets/filletpolyline_example.svg b/docs/assets/filletpolyline_example.svg index 77d830d..0b582e1 100644 --- a/docs/assets/filletpolyline_example.svg +++ b/docs/assets/filletpolyline_example.svg @@ -1,12 +1,12 @@ - + - + - + - + diff --git a/docs/assets/helix_example.svg b/docs/assets/helix_example.svg index 1335335..5ab24c7 100644 --- a/docs/assets/helix_example.svg +++ b/docs/assets/helix_example.svg @@ -1,7 +1,7 @@ - + - + diff --git a/docs/assets/jern_arc_example.svg b/docs/assets/jern_arc_example.svg index acfe1ec..13dcbf3 100644 --- a/docs/assets/jern_arc_example.svg +++ b/docs/assets/jern_arc_example.svg @@ -1,11 +1,11 @@ - + - - + + - + diff --git a/docs/assets/line_example.svg b/docs/assets/line_example.svg index 772df6e..baab452 100644 --- a/docs/assets/line_example.svg +++ b/docs/assets/line_example.svg @@ -1,7 +1,7 @@ - + - + diff --git a/docs/assets/polar_line_example.svg b/docs/assets/polar_line_example.svg index 8595ec0..bee604b 100644 --- a/docs/assets/polar_line_example.svg +++ b/docs/assets/polar_line_example.svg @@ -1,11 +1,11 @@ - + - + - + diff --git a/docs/assets/polyline_example.svg b/docs/assets/polyline_example.svg index 9c005f3..7ce7215 100644 --- a/docs/assets/polyline_example.svg +++ b/docs/assets/polyline_example.svg @@ -1,7 +1,7 @@ - + - + diff --git a/docs/assets/radius_arc_example.svg b/docs/assets/radius_arc_example.svg index 124e96f..862220a 100644 --- a/docs/assets/radius_arc_example.svg +++ b/docs/assets/radius_arc_example.svg @@ -1,7 +1,7 @@ - + - + diff --git a/docs/assets/sagitta_arc_example.svg b/docs/assets/sagitta_arc_example.svg index d8d3d5b..1af4ab2 100644 --- a/docs/assets/sagitta_arc_example.svg +++ b/docs/assets/sagitta_arc_example.svg @@ -1,7 +1,7 @@ - + - + diff --git a/docs/assets/spline_example.svg b/docs/assets/spline_example.svg index 1dfa20d..2d6885e 100644 --- a/docs/assets/spline_example.svg +++ b/docs/assets/spline_example.svg @@ -1,7 +1,7 @@ - + - + diff --git a/docs/assets/tangent_arc_example.svg b/docs/assets/tangent_arc_example.svg index 864b3e1..53903ed 100644 --- a/docs/assets/tangent_arc_example.svg +++ b/docs/assets/tangent_arc_example.svg @@ -1,12 +1,12 @@ - + - - + + - + diff --git a/docs/assets/three_point_arc_example.svg b/docs/assets/three_point_arc_example.svg index f6daa92..6e88996 100644 --- a/docs/assets/three_point_arc_example.svg +++ b/docs/assets/three_point_arc_example.svg @@ -1,7 +1,7 @@ - + - + diff --git a/docs/objects_1d.py b/docs/objects_1d.py index 76f2345..939cbde 100644 --- a/docs/objects_1d.py +++ b/docs/objects_1d.py @@ -9,7 +9,8 @@ with BuildLine() as example_1: Line((0, 0), (2, 0)) ThreePointArc((0, 0), (1, 1), (2, 0)) # [Ex. 1] -svg = ExportSVG(scale=50, line_weight=0.005) +s = 100 / max(*example_1.line.bounding_box().size) +svg = ExportSVG(scale=s) svg.add_shape(example_1.line) svg.write("assets/buildline_example_1.svg") # [Ex. 2] @@ -37,8 +38,9 @@ with BuildLine() as example_5: l3 = JernArc(start=l2 @ 1, tangent=l2 % 1, radius=0.5, arc_size=90) l4 = Line(l3 @ 1, (0, l2.length + l3.radius)) # [Ex. 5] -svg = ExportSVG(scale=15, line_weight=0.01) -svg.add_layer("dashed", line_type=LineType.DASHED, line_weight=0.01) +s = 100 / max(*example_5.line.bounding_box().size) +svg = ExportSVG(scale=s) +svg.add_layer("dashed", line_type=LineType.DASHED) svg.add_shape(example_5.line) svg.add_shape(dot.moved(Location(l1 @ 1))) svg.add_shape(dot.moved(Location(l2 @ 1))) @@ -56,7 +58,8 @@ with BuildSketch() as example_6: mirror(about=Plane.YZ) make_face() # [Ex. 6] -svg = ExportSVG(scale=0.25, margin=5, line_weight=1) +s = 100 / max(*example_6.sketch.bounding_box().size) +svg = ExportSVG(scale=s, margin=5) svg.add_shape(example_6.sketch) svg.write("assets/buildline_example_6.svg") @@ -71,12 +74,10 @@ with BuildPart() as example_7: sweep() # [Ex. 7] visible, hidden = example_7.part.project_to_viewport((100, -50, 100)) -max_dimension = max(*Compound(children=visible + hidden).bounding_box().size) -exporter = ExportSVG(scale=100 / max_dimension) -exporter.add_layer("Visible", line_weight=0.01) -exporter.add_layer( - "Hidden", line_color=(99, 99, 99), line_type=LineType.ISO_DOT, line_weight=0.01 -) +s = 100 / max(*Compound(children=visible + hidden).bounding_box().size) +exporter = ExportSVG(scale=s) +exporter.add_layer("Visible") +exporter.add_layer("Hidden", line_color=(99, 99, 99), line_type=LineType.ISO_DOT) exporter.add_shape(visible, layer="Visible") exporter.add_shape(hidden, layer="Hidden") exporter.write("assets/buildline_example_7.svg") @@ -89,10 +90,9 @@ with BuildLine(Plane.YZ) as example_8: # [Ex. 8] scene = Compound.make_compound(example_8.line) + Compound.make_triad(2) visible, _hidden = scene.project_to_viewport((100, -50, 100)) -bottom_left = Compound.make_compound(visible).bounding_box().min -max_dimension = max(*Compound(children=visible + hidden).bounding_box().size) -exporter = ExportSVG(scale=100 / max_dimension) -exporter.add_layer("Visible", line_weight=0.01) +s = 100 / max(*Compound(children=visible + hidden).bounding_box().size) +exporter = ExportSVG(scale=s) +exporter.add_layer("Visible") exporter.add_shape(visible, layer="Visible") exporter.write("assets/buildline_example_8.svg") @@ -101,7 +101,9 @@ pts = [(0, 0), (2 / 3, 2 / 3), (0, 4 / 3), (-4 / 3, 0), (0, -2), (4, 0), (0, 3)] wts = [1.0, 1.0, 2.0, 3.0, 4.0, 2.0, 1.0] with BuildLine() as bezier_curve: Bezier(*pts, weights=wts) -svg = ExportSVG(scale=50, line_weight=0.01) + +s = 100 / max(*bezier_curve.line.bounding_box().size) +svg = ExportSVG(scale=s) svg.add_shape(bezier_curve.line) for pt in pts: svg.add_shape(dot.moved(Location(Vector(pt)))) @@ -109,14 +111,16 @@ svg.write("assets/bezier_curve_example.svg") with BuildLine() as center_arc: CenterArc((0, 0), 3, 0, 90) -svg = ExportSVG(scale=50, line_weight=0.01) +s = 100 / max(*center_arc.line.bounding_box().size) +svg = ExportSVG(scale=s) svg.add_shape(center_arc.line) svg.add_shape(dot.moved(Location(Vector((0, 0))))) svg.write("assets/center_arc_example.svg") with BuildLine() as elliptical_center_arc: EllipticalCenterArc((0, 0), 2, 3, 0, 90) -svg = ExportSVG(scale=50, line_weight=0.01) +s = 100 / max(*elliptical_center_arc.line.bounding_box().size) +svg = ExportSVG(scale=s) svg.add_shape(elliptical_center_arc.line) svg.add_shape(dot.moved(Location(Vector((0, 0))))) svg.write("assets/elliptical_center_arc_example.svg") @@ -125,16 +129,17 @@ with BuildLine() as helix: Helix(1, 3, 1) scene = Compound.make_compound(helix.line) + Compound.make_triad(0.5) visible, _hidden = scene.project_to_viewport((1, 1, 1)) -max_dimension = max(*Compound(children=visible + hidden).bounding_box().size) -exporter = ExportSVG(scale=100 / max_dimension) -exporter.add_layer("Visible", line_weight=0.01) +s = 100 / max(*Compound(children=visible).bounding_box().size) +exporter = ExportSVG(scale=s) +exporter.add_layer("Visible") exporter.add_shape(visible, layer="Visible") exporter.write("assets/helix_example.svg") with BuildLine() as jern_arc: JernArc((1, 1), (1, 0.5), 2, 100) -svg = ExportSVG(scale=30, line_weight=0.01) -svg.add_layer("dashed", line_type=LineType.DASHED, line_weight=0.01) +s = 100 / max(*jern_arc.line.bounding_box().size) +svg = ExportSVG(scale=s) +svg.add_layer("dashed", line_type=LineType.DASHED) svg.add_shape(jern_arc.line) svg.add_shape(dot.moved(Location(Vector((1, 1))))) svg.add_shape(PolarLine((1, 1), 0.5, direction=(1, 0.5)), "dashed") @@ -142,7 +147,8 @@ svg.write("assets/jern_arc_example.svg") with BuildLine() as line: Line((1, 1), (3, 3)) -svg = ExportSVG(scale=50, line_weight=0.01) +s = 100 / max(*line.line.bounding_box().size) +svg = ExportSVG(scale=s) svg.add_shape(line.line) svg.add_shape(dot.moved(Location(Vector((1, 1))))) svg.add_shape(dot.moved(Location(Vector((3, 3))))) @@ -150,8 +156,9 @@ svg.write("assets/line_example.svg") with BuildLine() as polar_line: PolarLine((1, 1), 2.5, 60) -svg = ExportSVG(scale=50, line_weight=0.01) -svg.add_layer("dashed", line_type=LineType.DASHED, line_weight=0.01) +s = 100 / max(*polar_line.line.bounding_box().size) +svg = ExportSVG(scale=s) +svg.add_layer("dashed", line_type=LineType.DASHED) svg.add_shape(polar_line.line) svg.add_shape(dot.moved(Location(Vector((1, 1))))) svg.add_shape(PolarLine((1, 1), 4, angle=60), "dashed") @@ -159,7 +166,8 @@ svg.write("assets/polar_line_example.svg") with BuildLine() as polyline: Polyline((1, 1), (1.5, 2.5), (3, 3)) -svg = ExportSVG(scale=50, line_weight=0.01) +s = 100 / max(*polyline.line.bounding_box().size) +svg = ExportSVG(scale=s) svg.add_shape(polyline.line) svg.add_shape(dot.moved(Location(Vector((1, 1))))) svg.add_shape(dot.moved(Location(Vector((1.5, 2.5))))) @@ -171,14 +179,16 @@ with BuildLine(Plane.YZ) as filletpolyline: show(filletpolyline) scene = Compound.make_compound(filletpolyline.line) + Compound.make_triad(2) visible, _hidden = scene.project_to_viewport((0, 0, 1), (0, 1, 0)) -svg = ExportSVG(scale=50, line_weight=0.01) +s = 100 / max(*Compound(children=visible).bounding_box().size) +svg = ExportSVG(scale=s) svg.add_shape(visible) svg.write("assets/filletpolyline_example.svg") with BuildLine() as radius_arc: RadiusArc((1, 1), (3, 3), 2) -svg = ExportSVG(scale=50, line_weight=0.01) -svg.add_layer("dashed", line_type=LineType.DASHED, line_weight=0.01) +s = 100 / max(*radius_arc.line.bounding_box().size) +svg = ExportSVG(scale=s) +svg.add_layer("dashed", line_type=LineType.DASHED) svg.add_shape(radius_arc.line) svg.add_shape(dot.moved(Location(Vector((1, 1))))) svg.add_shape(dot.moved(Location(Vector((3, 3))))) @@ -186,7 +196,8 @@ svg.write("assets/radius_arc_example.svg") with BuildLine() as sagitta_arc: SagittaArc((1, 1), (3, 1), 1) -svg = ExportSVG(scale=50, line_weight=0.01) +s = 100 / max(*sagitta_arc.line.bounding_box().size) +svg = ExportSVG(scale=s) svg.add_shape(sagitta_arc.line) svg.add_shape(dot.moved(Location(Vector((1, 1))))) svg.add_shape(dot.moved(Location(Vector((3, 1))))) @@ -194,7 +205,8 @@ svg.write("assets/sagitta_arc_example.svg") with BuildLine() as spline: Spline((1, 1), (2, 1.5), (1, 2), (2, 2.5), (1, 3)) -svg = ExportSVG(scale=50, line_weight=0.01) +s = 100 / max(*spline.line.bounding_box().size) +svg = ExportSVG(scale=s) svg.add_shape(spline.line) svg.add_shape(dot.moved(Location(Vector((1, 1))))) svg.add_shape(dot.moved(Location(Vector((2, 1.5))))) @@ -205,8 +217,9 @@ svg.write("assets/spline_example.svg") with BuildLine() as tangent_arc: TangentArc((1, 1), (3, 3), tangent=(1, 0)) -svg = ExportSVG(scale=50, line_weight=0.01) -svg.add_layer("dashed", line_type=LineType.DASHED, line_weight=0.01) +s = 100 / max(*tangent_arc.line.bounding_box().size) +svg = ExportSVG(scale=s) +svg.add_layer("dashed", line_type=LineType.DASHED) svg.add_shape(tangent_arc.line) svg.add_shape(dot.moved(Location(Vector((1, 1))))) svg.add_shape(dot.moved(Location(Vector((3, 3))))) @@ -215,7 +228,8 @@ svg.write("assets/tangent_arc_example.svg") with BuildLine() as three_point_arc: ThreePointArc((1, 1), (1.5, 2), (3, 3)) -svg = ExportSVG(scale=50, line_weight=0.01) +s = 100 / max(*three_point_arc.line.bounding_box().size) +svg = ExportSVG(scale=s) svg.add_shape(three_point_arc.line) svg.add_shape(dot.moved(Location(Vector((1, 1))))) svg.add_shape(dot.moved(Location(Vector((1.5, 2)))))