Style & Rendering¶
sewpat.style
¶
Style options and named presets for rendering sewing pattern elements.
DEFAULT_STROKE_WIDTH: float = 0.5
module-attribute
¶
DEFAULT_STROKE_WIDTH_GRAIN: float = 0.2
module-attribute
¶
STYLE_GRAINLINE = StyleOptions(stroke_color='grey', stroke_width=DEFAULT_STROKE_WIDTH_GRAIN, marker_start=(Marker.ARROW), marker_end=(Marker.ARROW), dash_array=[3, 2])
module-attribute
¶
STYLE_FOLD = StyleOptions(stroke_color='grey', dash_array=[10.0, 2.0], no_notch=True)
module-attribute
¶
STYLE_HEM = StyleOptions(stroke_color='black', seam_allowance=25.0, dash_array=[10.0, 2.0], no_notch=True)
module-attribute
¶
STYLE_STITCH = StyleOptions(stroke_color='black', stroke_width=DEFAULT_STROKE_WIDTH, dash_array=[5.0, 2.0])
module-attribute
¶
STYLE_STITCH_BEVEL = StyleOptions(stroke_color='black', stroke_width=DEFAULT_STROKE_WIDTH, dash_array=[5.0, 2.0], corner_join='bevel')
module-attribute
¶
STYLE_CUT = StyleOptions(stroke_color='black', marker_end=(Marker.SCISSOR))
module-attribute
¶
STYLE_WAISTBAND = StyleOptions(stroke_color='black', marker_start=(Marker.STOP), marker_end=(Marker.STOP), seam_allowance=30.0)
module-attribute
¶
STYLE_CENTER_LINE = StyleOptions(stroke_color='black', stroke_width=DEFAULT_STROKE_WIDTH, dash_array=[10.0, 2.0, 2.0, 2.0], no_notch=True, corner_join='bevel')
module-attribute
¶
STYLE_SEAM_ALLOWANCE = StyleOptions(stroke_color='black', stroke_width=DEFAULT_STROKE_WIDTH)
module-attribute
¶
STYLE_CONSTRUCTION_GRID = StyleOptions(stroke_color='lightgrey', stroke_width=0.8, opacity=0.8, dash_array=[3.0, 2.0])
module-attribute
¶
STYLE_DEBUG_RED = StyleOptions(stroke_color='red', stroke_width=1.5, opacity=0.7)
module-attribute
¶
STYLE_DART_STITCH = StyleOptions(stroke_color='black', stroke_width=DEFAULT_STROKE_WIDTH, dash_array=[5.0, 2.0], seam_allowance=0.0)
module-attribute
¶
STYLE_DART_FOLD = StyleOptions(stroke_color='black', stroke_width=DEFAULT_STROKE_WIDTH, dash_array=[10.0, 2.0, 2.0, 2.0], no_notch=True)
module-attribute
¶
STYLE_PRECISION_POINT = StyleOptions(stroke_color='grey', stroke_width=DEFAULT_STROKE_WIDTH_GRAIN)
module-attribute
¶
StyleOptions(stroke_color: str = 'black', stroke_width: float = DEFAULT_STROKE_WIDTH, fill_color: str = 'none', dash_array: list[float] | None = None, dash_offset: float = 0.0, opacity: float = 1.0, stroke_linejoin: str = 'miter', stroke_miterlimit: float = 4.0, marker_start: Marker | None = None, marker_end: Marker | None = None, font_size_mm: float = DEFAULT_FONT_SIZE_MM, font_weight: str = 'normal', font_style: str = 'normal', seam_allowance: float | None = None, corner_join: str | None = None, no_notch: bool = False)
¶
Style options for rendering pattern elements.
Initialise with the given visual properties.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stroke_color
|
str
|
SVG stroke colour string. |
'black'
|
stroke_width
|
float
|
Stroke width in mm. |
DEFAULT_STROKE_WIDTH
|
fill_color
|
str
|
SVG fill colour string. |
'none'
|
dash_array
|
list[float] | None
|
Dash pattern lengths in mm. |
None
|
dash_offset
|
float
|
Dash pattern start offset. |
0.0
|
opacity
|
float
|
Stroke opacity (0–1). |
1.0
|
stroke_linejoin
|
str
|
SVG stroke-linejoin value. |
'miter'
|
stroke_miterlimit
|
float
|
SVG stroke-miterlimit value. |
4.0
|
marker_start
|
Marker | None
|
Optional marker at the segment start. |
None
|
marker_end
|
Marker | None
|
Optional marker at the segment end. |
None
|
font_size_mm
|
float
|
Label font size in mm. |
DEFAULT_FONT_SIZE_MM
|
font_weight
|
str
|
CSS font-weight string. |
'normal'
|
font_style
|
str
|
CSS font-style string. |
'normal'
|
seam_allowance
|
float | None
|
Per-element SA override in mm. |
None
|
corner_join
|
str | None
|
Per-element corner-join override ( |
None
|
no_notch
|
bool
|
When |
False
|
Marker
¶
Bases: StrEnum
Named markers placed at line endpoints.
String values match <marker id="…"> definitions in the SVG renderer.
sewpat.render
¶
SVG rendering for sewing patterns.
Marker
¶
Bases: StrEnum
Named markers placed at line endpoints.
String values match <marker id="…"> definitions in the SVG renderer.
StyleOptions(stroke_color: str = 'black', stroke_width: float = DEFAULT_STROKE_WIDTH, fill_color: str = 'none', dash_array: list[float] | None = None, dash_offset: float = 0.0, opacity: float = 1.0, stroke_linejoin: str = 'miter', stroke_miterlimit: float = 4.0, marker_start: Marker | None = None, marker_end: Marker | None = None, font_size_mm: float = DEFAULT_FONT_SIZE_MM, font_weight: str = 'normal', font_style: str = 'normal', seam_allowance: float | None = None, corner_join: str | None = None, no_notch: bool = False)
¶
Style options for rendering pattern elements.
Initialise with the given visual properties.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stroke_color
|
str
|
SVG stroke colour string. |
'black'
|
stroke_width
|
float
|
Stroke width in mm. |
DEFAULT_STROKE_WIDTH
|
fill_color
|
str
|
SVG fill colour string. |
'none'
|
dash_array
|
list[float] | None
|
Dash pattern lengths in mm. |
None
|
dash_offset
|
float
|
Dash pattern start offset. |
0.0
|
opacity
|
float
|
Stroke opacity (0–1). |
1.0
|
stroke_linejoin
|
str
|
SVG stroke-linejoin value. |
'miter'
|
stroke_miterlimit
|
float
|
SVG stroke-miterlimit value. |
4.0
|
marker_start
|
Marker | None
|
Optional marker at the segment start. |
None
|
marker_end
|
Marker | None
|
Optional marker at the segment end. |
None
|
font_size_mm
|
float
|
Label font size in mm. |
DEFAULT_FONT_SIZE_MM
|
font_weight
|
str
|
CSS font-weight string. |
'normal'
|
font_style
|
str
|
CSS font-style string. |
'normal'
|
seam_allowance
|
float | None
|
Per-element SA override in mm. |
None
|
corner_join
|
str | None
|
Per-element corner-join override ( |
None
|
no_notch
|
bool
|
When |
False
|
export_pattern_part_svg_mm(pattern_part: PatternPart, filename: str, width_mm: float = 210, height_mm: float = 297, margin_mm: float = 10, style_map: dict[str, StyleOptions] | None = None, show_construction: bool = True, show_bezier_control_points: bool = False, show_seam_allowance: bool = True, dark_mode: bool = True) -> None
¶
Export a single PatternPart as an SVG file with mm units.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern_part
|
PatternPart
|
Part to export. |
required |
filename
|
str
|
Output SVG path. |
required |
width_mm
|
float
|
Canvas width in mm. |
210
|
height_mm
|
float
|
Canvas height in mm. |
297
|
margin_mm
|
float
|
Canvas margin in mm. |
10
|
style_map
|
dict[str, StyleOptions] | None
|
Element-type → StyleOptions overrides; unknown keys warn. |
None
|
show_construction
|
bool
|
Render elements flagged |
True
|
show_bezier_control_points
|
bool
|
Render Bézier control-point handles. |
False
|
show_seam_allowance
|
bool
|
Include SA offset lines (default True). |
True
|
dark_mode
|
bool
|
When |
True
|
export_pattern_svg_mm(pattern: Pattern, filename: str, width_mm: float = 210, height_mm: float = 297, margin_mm: float = 10, style_map: dict[str, StyleOptions] | None = None, show_construction: bool = True, show_bezier_control_points: bool = False, parts: list[str] | None = None, show_seam_allowance: bool = True, dark_mode: bool = True) -> None
¶
Export a Pattern (all or selected parts) as a single SVG file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
Pattern
|
Pattern to export. |
required |
filename
|
str
|
Output SVG path. |
required |
width_mm
|
float
|
Canvas width in mm. |
210
|
height_mm
|
float
|
Canvas height in mm. |
297
|
margin_mm
|
float
|
Canvas margin in mm. |
10
|
style_map
|
dict[str, StyleOptions] | None
|
Element-type → StyleOptions overrides; unknown keys warn. |
None
|
show_construction
|
bool
|
Render elements flagged |
True
|
show_bezier_control_points
|
bool
|
Render Bézier control-point handles. |
False
|
parts
|
list[str] | None
|
Part names to include. When |
None
|
show_seam_allowance
|
bool
|
Include SA offset lines (default True). |
True
|
dark_mode
|
bool
|
When |
True
|