Caps¶
End-cap specifications shared by sweep, skin, bezier, and stroke drawing
End-cap specifications shared by sweep, skin, bezier, and stroke drawing.
Provides the CapType enum, the CapSpec dataclass for
controlling cap appearance, and the normaliser shared by pybosl2.skin,
pybosl2.beziers, and pybosl2.drawing.
- Cap types
NONE– no cap (open end)BUTT– default flat end cap (FLATis a module-level backward-compatible alias)ROUND/SPHERE– spherical end cap (planned)CIRCLE– round-over end cap (planned)ARROW/DIAMOND/DOT… – stroke endcap stylesCUSTOM– user-supplied path shape (requires path on CapSpec)
Note
Fancy sweep cap shapes (ROUND, SPHERE, CIRCLE) are
scaffolding only – they resolve to flat caps. Full BOSL2 cap profiles
need the sweep’s 3-D end-profile geometry exported into
VNF and are not yet ported.
- class pybosl2.caps.CapType(*values)[source]¶
Bases:
EnumEnd-cap or stroke-endcap style.
- Sweep/skin cap types:
NONE– no cap (open end)BUTT– flat end capROUND/SPHERE– spherical (planned)CIRCLE– round-over (planned)CUSTOM– user-suppliedCapSpec.pathshape- Stroke endcap/joint types:
ARROW/ARROW2/ARROW3– arrow headsDIAMOND– diamond shapeDOT– circular dotBLOCK/SQUARE– rectangular blockCHISEL– chisel edgeTAIL/TAIL2– tail shapesCROSS/X/LINE– line markers
Examples
from pybosl2 import Path3D, CapType spine = Path3D([[0,0,0],[0,0,30],[30,0,30]], closed=False) spine.stroke(width=4, endcaps=CapType.ARROW).show()Loading 3-D preview…-
NONE =
'none'¶
-
BUTT =
'butt'¶
-
ROUND =
'round'¶
-
SPHERE =
'sphere'¶
-
CIRCLE =
'circle'¶
-
CUSTOM =
'custom'¶
-
ARROW =
'arrow'¶
-
ARROW2 =
'arrow2'¶
-
ARROW3 =
'arrow3'¶
-
BLOCK =
'block'¶
-
CHISEL =
'chisel'¶
-
CROSS =
'cross'¶
-
DIAMOND =
'diamond'¶
-
DOT =
'dot'¶
-
LINE =
'line'¶
-
SQUARE =
'square'¶
-
TAIL =
'tail'¶
-
TAIL2 =
'tail2'¶
-
X =
'x'¶
-
class pybosl2.caps.CapSpec(cap_type=
CapType.BUTT, length=0.0, width=0.0, height=0.0, extent=0.0, angle=0.0, color=None, path=None)[source]¶ Bases:
objectCustomisable end-cap specification.
Used wherever a cap type is accepted. The cap_type field selects the shape; length, width, and height control the dimensions; angle rotates the cap; color overrides the path colour when set.
When cap_type is
CapType.CUSTOM, the path field must hold a custom 2-D polygon to use as the endcap shape.- Parameters:¶
- cap_type : CapType¶
The
CapTypestyle.- length : float¶
Cap length multiplier (along the path direction).
- width : float¶
Cap width multiplier (perpendicular scale).
- height : float¶
Cap height multiplier (0 means use the computed default from width/length).
- extent : float¶
Extent multiplier for the cap shape.
- angle : float¶
Rotation angle of the cap in degrees.
- color : str | None¶
Override colour for the cap, or
Nonefor the path colour.- path : Sequence[Sequence[float]] | None¶
Custom polygon path for
CapType.CUSTOM; ignored otherwise.
Examples
from pybosl2 import Path3D, CapSpec, CapType spine = Path3D([[0,0,0],[0,0,40]], closed=False) cap = CapSpec(CapType.ARROW, length=2, width=3) spine.stroke(width=4, endcaps=cap).show()Loading 3-D preview…-
length : float =
0.0¶
-
width : float =
0.0¶
-
height : float =
0.0¶
-
extent : float =
0.0¶
-
angle : float =
0.0¶
-
color : str | None =
None¶
-
path : Sequence[Sequence[float]] | None =
None¶
-
pybosl2.caps.CapsSpec : TypeAlias =
'CapType | CapSpec | str | Sequence[CapType | CapSpec | str]'¶ A cap specification used by sweep/skin entry points. Can be:
a single
CapTypeenum member (same cap on both ends)a
CapSpecwith custom dimensionsa
Sequence[CapType | CapSpec]pair (per-end caps)
Use
CapType.NONEto request no cap;CapType.BUTTfor a flat cap.
- pybosl2.caps.endcap_polys(spec, lw)[source]¶
Return the local-frame polygon(s) for an endcap (BOSL2
_shape_path()).Dimensions are taken directly from the
CapSpecwhich has already been resolved bynormalize_one()against_DEFAULTS.
- pybosl2.caps.endcap_trim(spec, width)[source]¶
How far to pull the line back under an arrow endcap so it doesn’t poke through the tip.
- pybosl2.caps.has_decorative_caps(cap_specs)[source]¶
Return True if any endcap is a decorative (non-flat/non-dome/non-none) type.
-
pybosl2.caps.norm_caps(caps, closed=
False)[source]¶ Normalize a
CapsSpecto a[CapSpec, CapSpec]pair.Returns a list of two fully-resolved
CapSpecobjects for the start and end caps.CapSpec(cap_type=CapType.NONE)means no cap. When closed is True, both caps areCapType.NONE.
- pybosl2.caps.vnf_with_decorative_caps(vnf, cap_specs, closed, profile_centers, profile_outdirs, profile_radius)[source]¶
Convert VNF to CSG polyhedron, add decorative endcaps, return Bosl2Solid.
- Parameters:¶
- vnf : VNF¶
The body VNF (already volume-checked and corrected).
- cap_specs : list[CapSpec]¶
Normalised cap pair.
- closed : bool¶
Whether the sweep is closed (no caps expected).
- profile_centers : list[Sequence[float]]¶
Centroids of the first and last profiles.
- profile_outdirs : list[Sequence[float]]¶
Outward directions for the first and last caps.
- profile_radius : float¶
Bounding radius of the profile (half the width passed to endcap geometry).
- Returns:¶
A Bosl2Solid with the body polyhedron and any decorative endcaps unioned.
- Return type:¶