Drawing: path generators & renderers¶
The drawing functions are distributed across the modules where they naturally live. Path generators return points; path renderers turn points into geometry.
Arc & catenary¶
-
pybosl2.shapes2d.arc(count=
None, radius=None, angle=None, diameter=None, center=None, points=None, corner=None, width=None, thickness=None, start=None, wedge=False, long=False, clockwise=False, counterclockwise=False, endpoint=True, fn=None, fa=None, fs=None)[source]¶ Return a 2-D arc, returned as a
Path2Dof points (BOSL2’sarc()).All of BOSL2’s 2-D arc specifications are supported (3-D arcs, which project onto a plane, are not):
arc(radius=, angle=, [start=], [center=])– radius about center, sweeping angle degrees from start (orangle=[start, end]for an explicit range).arc(width=, thickness=)– a circular segment starting and ending on the X axis.arc(center=, points=[P0, P1])– around center fromP0toward the direction ofP1; the short way by default, or the long/clockwise/counterclockwiseway.arc(points=[P0, P1, P2])– through three points, fromP0viaP1toP2.arc(corner=[P0, P1, P2], radius=)– the fillet arc of radius tangent to both legs of the cornerP0-P1-P2.
Set
wedge=Trueto prepend the centre point, giving a closed pie/sector path. When count is omitted the point count follows OpenSCAD’s $fn/$fa/$fs rules, matching BOSL2.- Parameters:¶
- count : int | None¶
number of points (default: from $fn/$fa/$fs)
- radius : float | None¶
radius of the arc
- diameter : float | None¶
diameter of the arc
- angle : float | Sequence[float] | None¶
degrees to sweep from start, or
[start, end]- center : Sequence[float] | None¶
centre point (default
[0, 0])- points : Sequence[Sequence[float]] | None¶
two points (with center) or three points the arc passes through
- corner : Sequence[Sequence[float]] | None¶
three points; the arc is the radius fillet tangent to both legs
- width : float | None¶
chord width for the width/thickness form
- thickness : float | None¶
height of the circular segment for the width/thickness form
- start : float | None¶
starting angle in degrees (default 0)
- wedge : bool¶
prepend the centre point, producing a closed sector (default False)
- long : bool¶
for the two-point form, take the long way / a given handedness
- clockwise : bool¶
for the two-point form, take the long way / a given handedness
- counterclockwise : bool¶
for the two-point form, take the long way / a given handedness
- endpoint : bool¶
include the final point (default True)
- fn : int | None¶
number of fragments for circle resolution.
- fa : float | None¶
minimum fragment angle for circle resolution.
- fs : float | None¶
minimum fragment size for circle resolution.
- Returns:¶
A
Path2D(closed when wedge is set).- Return type:¶
Path2D
-
classmethod Path2D.catenary(width, droop=
None, sides=100, angle=None)[source]¶ Return the catenary (hanging-chain) curve of the given width, as a
Path2D.Give exactly one of droop (how far the middle hangs below the endpoints) or angle (the slope in degrees at the endpoints). The curve passes through
[-width/2, 0]and[width/2, 0]and hangs downward (negative droop/angle flips it upward). This is BOSL2’scatenary().Examples
A hanging arch, stroked into a 2-mm ribbon and extruded into a wall:
from pybosl2 import Path2D Path2D.catenary(width=80, droop=30).stroke(width=2).linear_extrude(height=6).show()Loading 3-D preview…
Helix¶
pybosl2.path3d.Path3D.helix() — see the Paths reference for full documentation.
2-D Turtle¶
The 2-D turtle is a standalone function that returns a Path2D:
-
pybosl2.turtle.turtle2d(commands, state=
None, repeat=1)[source]¶ Build a 2-D path from
TurtleCommandobjects — BOSL2’sturtle2d().Creates a
Turtle2D, runs commands (optionally repeat times), and returns the turtle. Access the path viaTurtle2D.points()or the state viaTurtle2D.full_state().Examples
A rounded-corner square drawn with arcs:
from pybosl2.turtle import turtle2d from pybosl2.points import Point from pybosl2.turtle import TurtleCommand, TurtleCommandType as Tct path = turtle2d([ TurtleCommand(Tct.MOVE, size=40), TurtleCommand(Tct.ARCLEFT, radius=8), TurtleCommand(Tct.MOVE, size=40), TurtleCommand(Tct.ARCLEFT, radius=8), TurtleCommand(Tct.MOVE, size=40), TurtleCommand(Tct.ARCLEFT, radius=8), TurtleCommand(Tct.MOVE, size=40), TurtleCommand(Tct.ARCLEFT, radius=8), ]).points() path.stroke(width=3, closed=True).linear_extrude(height=4).show()Loading 3-D preview…
3-D Turtle¶
The 3-D turtle is documented in Turtle (3-D).
Stroke & dashed stroke¶
Both 2-D and 3-D paths carry stroke and dashed_stroke as methods:
pybosl2.path2d.Path2D.stroke()/pybosl2.path2d.Path2D.dashed_stroke()pybosl2.path3d.Path3D.stroke()/pybosl2.path3d.Path3D.dashed_stroke()
Coverage of BOSL2 drawing.scad¶
BOSL2 function |
Status |
Notes |
|---|---|---|
|
ported |
|
|
ported |
|
|
ported |
|
|
ported |
|
|
ported |
|
|
ported |
|
|
ported |
Turtle (3-D) — the 3-D turtle as a |
|
not ported |
annotated debugging modules (vertex/edge labels); no geometry payload. |