Square¶
⚙️ Spec sheet → — visual schematic and metrics measured from a real rendered STL.
Rectangles, squares, polygons, ngons and trapezoid shapes.
-
pybosl2.shapes2d.square.square(size=
1, center=None, rounding=0, chamfer=0, anchor=Anchor.CENTER, spin=None, fn=None, fa=None, fs=None)[source]¶ Return a rectangle, built via polygon() with BOSL2-style anchor/spin support.
- Parameters:¶
- size : float | Sequence[float]¶
size of the square; a scalar uses the same size for X and Y
- center : bool | None¶
if given, overrides anchor (True -> CENTER, False -> FRONT+LEFT)
- rounding : float | Sequence[float]¶
corner rounding radius, or per-corner list [X+Y+,X-Y+,X-Y-,X+Y-] (default 0)
- chamfer : float | Sequence[float]¶
corner chamfer size, or per-corner list [X+Y+,X-Y+,X-Y-,X+Y-] (default 0)
- anchor : Anchor | Sequence[float]¶
anchor point (default CENTER)
- spin : float | None¶
Z-axis rotation in degrees after anchor (default 0)
- fn : int | None¶
arc smoothness overrides for rounded corners
- fa : float | None¶
arc smoothness overrides for rounded corners
- fs : float | None¶
arc smoothness overrides for rounded corners
- Return type:¶
Bosl2Shape2D
Examples
from pybosl2 import shapes2d as s2 s2.square(20).linear_extrude(height=5).show()Loading 3-D preview…
-
pybosl2.shapes2d.square.rect(size=
1, rounding=0, atype='box', chamfer=0, anchor=Anchor.CENTER, spin=0, fn=None, fa=None, fs=None)[source]¶ Return a rectangle with optional rounded or chamfered corners.
Note: negative rounding/chamfer (BOSL2’s “external roundover spikes”) is not supported here.
- Parameters:¶
- size : float | Sequence[float]¶
size of the rectangle; a scalar uses the same size for X and Y
- rounding : float | Sequence[float]¶
corner rounding radius, or per-corner list [X+Y+,X-Y+,X-Y-,X+Y-] (default 0)
- atype : str¶
anchor type, “box” (bounding box) or “perim” (rounded/chamfered perimeter) (default “box”)
- chamfer : float | Sequence[float]¶
corner chamfer size, or per-corner list [X+Y+,X-Y+,X-Y-,X+Y-] (default 0)
- 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 for rounded corners
- fa : float | None¶
arc smoothness overrides for rounded corners
- fs : float | None¶
arc smoothness overrides for rounded corners
- Return type:¶
Bosl2Shape2D
-
pybosl2.shapes2d.square.rect_path(size=
1, rounding=0, chamfer=0, anchor=Anchor.CENTER, fn=None, fa=None, fs=None)[source]¶ Return the points of a (optionally rounded/chamfered) rectangle – BOSL2’s
rect()in its.function form, as opposed to
rect()which returns 2-D geometry (aBosl2Shape2D).Use this when the rectangle is an input to further path math (e.g. a profile fed to
base_bgtk.PolygonPrism()), not something to draw.Usage:
rect_path([20, 4], rounding=[-3, -3, 0, 0], anchor=TOP + LEFT)- Parameters:¶
- size : float | Sequence[float]¶
[x, y] size (or a single number for a square)
- rounding : float | Sequence[float]¶
corner radius; a single value or per-corner list. Negative = concave.
- chamfer : float | Sequence[float]¶
corner chamfer; a single value or per-corner list
- anchor : Anchor | Sequence[float]¶
BOSL2 anchor the path is translated onto (default CENTER)
- 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.
- Return type:¶
list[list[float]]
Note
For small radii this can emit one more point per corner than the real BOSL2 does (BOSL2 rounds the corner-arc segment count, this rounds up); the arc geometry is identical, only the sampling differs.
-
pybosl2.shapes2d.square.polygon(path, anchor=
Anchor.CENTER, spin=0)[source]¶ Return a polygon, built with the builtin polygon(), with anchor/spin support.
-
pybosl2.shapes2d.square.regular_ngon(sides=
6, radius=None, diameter=None, outer_radius=None, outer_diameter=None, inner_radius=None, inner_diameter=None, side=None, rounding=0, chamfer=0, realign=False, align_tip=None, align_side=None, anchor=Anchor.CENTER, spin=0, fn=None, fa=None, fs=None)[source]¶ Return a regular N-gon (equilateral, equiangular 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:¶
- sides : int¶
number of sides (default 6)
- radius : float | None¶
outside radius, at the points
- outer_radius : float | None¶
outside radius, at the points (BOSL2
or)- diameter : float | None¶
outside diameter, at the points
- outer_diameter : float | None¶
outside diameter, at the points
- inner_radius : float | None¶
inside radius, at the center of the sides
- inner_diameter : float | None¶
inside diameter, at the center of the sides
- side : float | None¶
length of each side
- rounding : float¶
rounding radius for the tips of the polygon (default 0)
- chamfer : float¶
chamfer size for the tips of the polygon (default 0)
- 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 vertex points in this 2-D direction (applied before spin)
- align_side : Sequence[float] | None¶
rotate so the normal of side 0 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)
- fn : int | None¶
arc smoothness overrides for rounded tips
- fa : float | None¶
arc smoothness overrides for rounded tips
- fs : float | None¶
arc smoothness overrides for rounded tips
- Return type:¶
Bosl2Shape2D
Examples
from pybosl2 import shapes2d as s2 s2.regular_ngon(sides=6, radius=15).linear_extrude(height=5).show()Loading 3-D preview…
-
pybosl2.shapes2d.square.pentagon(radius=
None, diameter=None, outer_radius=None, outer_diameter=None, inner_radius=None, inner_diameter=None, side=None, rounding=0, chamfer=0, realign=False, align_tip=None, align_side=None, anchor=Anchor.CENTER, spin=0, fn=None, fa=None, fs=None)[source]¶ Return a regular pentagon. See regular_ngon() for argument details.
- Parameters:¶
- radius : float | None¶
- diameter : float | None¶
- outer_radius : float | None¶
- outer_diameter : float | None¶
- inner_radius : float | None¶
- inner_diameter : float | None¶
- side : float | None¶
- rounding : float¶
- chamfer : float¶
- realign : bool¶
- align_tip : Sequence[float] | None¶
- align_side : Sequence[float] | None¶
- anchor : Anchor | Sequence[float]¶
- spin : float¶
- fn : int | None¶
- fa : float | None¶
- fs : float | None¶
- Return type:¶
Bosl2Shape2D
-
pybosl2.shapes2d.square.hexagon(radius=
None, diameter=None, outer_radius=None, outer_diameter=None, inner_radius=None, inner_diameter=None, side=None, rounding=0, chamfer=0, realign=False, align_tip=None, align_side=None, anchor=Anchor.CENTER, spin=0, fn=None, fa=None, fs=None)[source]¶ Return a regular hexagon. See regular_ngon() for argument details.
- Parameters:¶
- radius : float | None¶
- diameter : float | None¶
- outer_radius : float | None¶
- outer_diameter : float | None¶
- inner_radius : float | None¶
- inner_diameter : float | None¶
- side : float | None¶
- rounding : float¶
- chamfer : float¶
- realign : bool¶
- align_tip : Sequence[float] | None¶
- align_side : Sequence[float] | None¶
- anchor : Anchor | Sequence[float]¶
- spin : float¶
- fn : int | None¶
- fa : float | None¶
- fs : float | None¶
- Return type:¶
Bosl2Shape2D
-
pybosl2.shapes2d.square.octagon(radius=
None, diameter=None, outer_radius=None, outer_diameter=None, inner_radius=None, inner_diameter=None, side=None, rounding=0, chamfer=0, realign=False, align_tip=None, align_side=None, anchor=Anchor.CENTER, spin=0, fn=None, fa=None, fs=None)[source]¶ Return a regular octagon. See regular_ngon() for argument details.
- Parameters:¶
- radius : float | None¶
- diameter : float | None¶
- outer_radius : float | None¶
- outer_diameter : float | None¶
- inner_radius : float | None¶
- inner_diameter : float | None¶
- side : float | None¶
- rounding : float¶
- chamfer : float¶
- realign : bool¶
- align_tip : Sequence[float] | None¶
- align_side : Sequence[float] | None¶
- anchor : Anchor | Sequence[float]¶
- spin : float¶
- fn : int | None¶
- fa : float | None¶
- fs : float | None¶
- Return type:¶
Bosl2Shape2D
-
pybosl2.shapes2d.square.right_triangle(size=
[1, 1], center=None, rounding=0, chamfer=0, anchor=None, spin=0, fn=None, fa=None, fs=None)[source]¶ Return a right triangle, built directly with polygon().
- Parameters:¶
- size : Sequence[float]¶
[width, length] of the right triangle
- center : bool | None¶
True forces anchor=CENTER, False forces anchor=[-1,-1] (default: use anchor=)
- rounding : float¶
corner rounding radius (default 0)
- chamfer : float¶
corner chamfer size (default 0)
- anchor : Anchor | Sequence[float] | None¶
anchor point (default: [-1,-1], the right-angle corner)
- spin : float¶
Z-axis rotation in degrees after anchor (default 0)
- fn : int | None¶
arc smoothness overrides for rounded corners
- fa : float | None¶
arc smoothness overrides for rounded corners
- fs : float | None¶
arc smoothness overrides for rounded corners
- Return type:¶
Bosl2Shape2D
Examples
from pybosl2 import shapes2d as s2 s2.right_triangle(size=[30, 20]).linear_extrude(height=5).show()Loading 3-D preview…
-
pybosl2.shapes2d.square.trapezoid(height=
None, width1=None, width2=None, angle=None, shift=0, chamfer=0, rounding=0, flip=False, anchor=Anchor.CENTER, spin=0, fn=None, fa=None, fs=None)[source]¶ Return a trapezoid with parallel front and back sides, built directly with polygon().
- Parameters:¶
- height : float | None¶
Y-axis height of the trapezoid
- width1 : float | None¶
X-axis width of the front end
- width2 : float | None¶
X-axis width of the back end
- angle : float | None¶
if given in place of height/width1/width2, the missing value is derived from this angle
- shift : float¶
X-axis shift of the back of the trapezoid (default 0)
- rounding : float | Sequence[float]¶
corner rounding radius, or per-corner list [X+Y+,X-Y+,X-Y-,X+Y-] (default 0)
- chamfer : float | Sequence[float]¶
corner chamfer length, or per-corner list [X+Y+,X-Y+,X-Y-,X+Y-] (default 0)
- flip : bool¶
point negative roundings/chamfers forward/back instead of left/right (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 for rounded corners
- fa : float | None¶
arc smoothness overrides for rounded corners
- fs : float | None¶
arc smoothness overrides for rounded corners
- Return type:¶
Bosl2Shape2D
Examples
from pybosl2 import shapes2d as s2 s2.trapezoid(height=20, width1=30, width2=15).linear_extrude(height=5).show()Loading 3-D preview…