Curves¶
⚙️ Spec sheet → — visual schematic and metrics measured from a real rendered STL.
Stars, teardrops, eggs, squircles and supershapes.
-
pybosl2.shapes2d.curves.star(tips=
None, radius=None, inner_radius=None, diameter=None, outer_radius=None, outer_diameter=None, inner_diameter=None, step=None, realign=False, align_tip=None, align_pit=None, anchor=Anchor.CENTER, spin=0, atype=AnchorType.HULL)[source]¶ Return an N-pointed star polygon, built directly with polygon().
Note: BOSL2’s outer-radius parameter is named or, which collides with the Python keyword or; it is exposed here as outer_radius instead.
- Parameters:¶
- tips : int | None¶
number of stellate tips
- radius : float | None¶
radius to the tips of the star
- outer_radius : float | None¶
radius to the tips of the star (BOSL2 or); alias for radius
- inner_radius : float | None¶
radius to the inner corners of the star
- diameter : float | None¶
diameter to the tips of the star
- outer_diameter : float | None¶
diameter to the tips of the star; alias for diameter
- inner_diameter : float | None¶
diameter to the inner corners of the star
- step : int | None¶
compute inner radius by virtually drawing a line step tips around the star (2 <= step < tips)
- realign : bool¶
put the midpoint of the last edge (instead of vertex 0) on the X+ axis (default False)
- align_tip : Sequence[float] | None¶
rotate so the first tip points in this 2-D direction (applied before spin)
- align_pit : Sequence[float] | None¶
rotate so the first inner corner points in this 2-D direction (applied before spin)
- anchor : Anchor | Sequence[float]¶
anchor point (default CENTER)
- spin : float¶
Z-axis rotation in degrees after anchor (default 0)
- atype : str | AnchorType¶
anchor method (default AnchorType.HULL)
- Return type:¶
Bosl2Shape2D
Examples
from pybosl2 import shapes2d as s2 s2.star(tips=5, radius=20, inner_radius=8).linear_extrude(height=5).show()Loading 3-D preview…
-
pybosl2.shapes2d.curves.teardrop2d(radius=
None, angle=45, cap_height=None, diameter=None, circumscribe=False, realign=False, anchor=Anchor.CENTER, spin=0, fn=None, fa=None, fs=None)[source]¶ Return a 2-D teardrop shape, useful for 3D-printable horizontal holes, built directly with polygon().
Note: circumscribe is approximated the same way as the inscribed case here.
- Parameters:¶
- radius : float | None¶
radius of the circular part (default 1)
- angle : float¶
angle of the hat walls from the Y axis in degrees (default 45)
- cap_height : float | None¶
height above center to truncate the shape (default: no truncation)
- diameter : float | None¶
diameter of the circular portion (alternative to radius)
- circumscribe : bool¶
produce a circumscribing teardrop (default False)
- realign : bool¶
flip whether the bottom is a point or a flat (default False)
- anchor : Anchor | Sequence[float]¶
anchor point (default CENTER)
- spin : float¶
Z-axis rotation in degrees after anchor (default 0)
- fn : int | None¶
arc smoothness overrides
- fa : float | None¶
arc smoothness overrides
- fs : float | None¶
arc smoothness overrides
- Return type:¶
Bosl2Shape2D
Examples
from pybosl2 import shapes2d as s2 s2.teardrop2d(radius=15, angle=45).linear_extrude(height=5).show()Loading 3-D preview…
-
pybosl2.shapes2d.curves.egg(length=
None, radius1=None, radius2=None, arc_radius=None, diameter1=None, diameter2=None, arc_diameter=None, anchor=Anchor.CENTER, spin=0, fn=None, fa=None, fs=None)[source]¶ Return an egg-shaped 2-D outline, made of two circles joined by tangent arcs, built directly with polygon().
- Parameters:¶
- length : float | None¶
length of the egg
- radius1 : float | None¶
radius of the left-hand circle
- radius2 : float | None¶
radius of the right-hand circle
- arc_radius : float | None¶
radius of the joining arcs
- diameter1 : float | None¶
diameter of the left-hand circle (alternative to radius1)
- diameter2 : float | None¶
diameter of the right-hand circle (alternative to radius2)
- arc_diameter : float | None¶
diameter of the joining arcs (alternative to arc_radius)
- anchor : Anchor | Sequence[float]¶
anchor point (default CENTER)
- spin : float¶
Z-axis rotation in degrees after anchor (default 0)
- fn : int | None¶
arc smoothness overrides
- fa : float | None¶
arc smoothness overrides
- fs : float | None¶
arc smoothness overrides
- Return type:¶
Bosl2Shape2D
Examples
from pybosl2 import shapes2d as s2 s2.egg(length=30, radius1=10, radius2=8, arc_radius=20).linear_extrude(height=5).show()Loading 3-D preview…
-
pybosl2.shapes2d.curves.supershape(step=
0.5, count=None, m1=4, m2=None, n1=None, n2=None, n3=None, a=1, b=None, radius=None, diameter=None, anchor=Anchor.CENTER, spin=0, atype=AnchorType.HULL)[source]¶ Return a 2-D shape from the superformula, built directly with polygon().
- Parameters:¶
- step : float¶
angle step size for sampling the superformula (smaller = slower, more accurate) (default 0.5)
- count : int | None¶
number of output points, an alternative to step
- m1 : float¶
superformula m1 argument (default 4)
- m2 : float | None¶
superformula m2 argument (default: same as m1)
- n1 : float | None¶
superformula n1 argument (default 1)
- n2 : float | None¶
superformula n2 argument (default: same as n1)
- n3 : float | None¶
superformula n3 argument (default: same as n2)
- a : float¶
superformula a argument (default 1)
- b : float | None¶
superformula b argument (default: same as a)
- radius : float | None¶
scale the shape to fit in a circle of this radius
- diameter : float | None¶
scale the shape to fit in a circle of this diameter
- anchor : Anchor | Sequence[float]¶
anchor point (default CENTER)
- spin : float¶
Z-axis rotation in degrees after anchor (default 0)
- atype : str | AnchorType¶
anchor method (default AnchorType.HULL)
- Return type:¶
Bosl2Shape2D
Examples
from pybosl2 import shapes2d as s2 s2.supershape(m1=3, radius=20).linear_extrude(height=5).show()Loading 3-D preview…
- pybosl2.shapes2d.curves.squircle_radius_fg(squareness, radius, angle)[source]¶
Return the Fong-Garcia squircle radius at angle degrees for squareness squareness and size.
radius.
-
pybosl2.shapes2d.curves.squircle(size, squareness=
0.5, style='fg', anchor=Anchor.CENTER, spin=0, fn=None, fa=None, fs=None)[source]¶ Return a squircle – a rounded square that morphs between a square and a circle (BOSL2 squircle()).
squareness runs 0 (a circle) to 1 (a square). Only the default
"fg"(Fong-Garcia) style is ported; the"superellipse"and"bezier"styles are not.- Parameters:¶
- size : float | Sequence[float]¶
scalar or [x, y] size of the bounding box
- squareness : float¶
0 (circle) .. 1 (square); default 0.5
- style : str¶
only “fg” is supported
- anchor : Anchor | Sequence[float]¶
standard BOSL2 2-D anchor
- spin : float¶
standard BOSL2 2-D spin
- fn : int | None¶
smoothness overrides
- fa : float | None¶
smoothness overrides
- fs : float | None¶
smoothness overrides
- Return type:¶
Bosl2Shape2D
Examples
from pybosl2 import shapes2d as s2 s2.squircle(40, squareness=0.7).linear_extrude(height=5).show()Loading 3-D preview…