SVG-native
momapy.rendering.svg_native
Classes for rendering in the SVG format
Classes:
| Name | Description |
|---|---|
SVGElement |
Class for SVG elements |
SVGNativeCompatRenderer |
Class for SVG native compat renderers |
SVGNativeRenderer |
Class for SVG native renderers |
SVGElement
dataclass
SVGElement(
name: str,
value: Optional[str] = None,
attributes: dict = dict(),
elements: list[SVGElement] = list(),
)
Bases: object
Class for SVG elements
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
|
required |
value
|
str | None
|
|
None
|
attributes
|
dict
|
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2) |
<class 'dict'>
|
elements
|
list[str]
|
Built-in mutable sequence. If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified. |
<dynamic>
|
Methods:
| Name | Description |
|---|---|
add_element |
Add an sub-element to the SVG element |
to_string |
Return the SVG string representing the element |
add_element
to_string
Return the SVG string representing the element
Source code in src/momapy/rendering/svg_native.py
SVGNativeCompatRenderer
dataclass
SVGNativeCompatRenderer(
svg: SVGElement,
config: dict = dict(),
_filter_elements: list[SVGElement] = list(),
)
Bases: SVGNativeRenderer
Class for SVG native compat renderers
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
svg
|
SVGElement
|
|
required |
config
|
dict
|
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2) |
<class 'dict'>
|
Methods:
| Name | Description |
|---|---|
begin_session |
Begin a session |
end_session |
End a session |
get_bolder_font_weight |
Return the lightest font weight bolder than the given font weight |
get_lighter_font_weight |
Return the boldest font weight lighter than the given font weight |
new_page |
Make a new page |
render_drawing_element |
Render a drawing element |
render_layout_element |
Render a layout element |
render_map |
Render a map |
begin_session
end_session
End a session
Source code in src/momapy/rendering/svg_native.py
get_bolder_font_weight
classmethod
get_bolder_font_weight(
font_weight: FontWeight | float,
) -> float
Return the lightest font weight bolder than the given font weight
Source code in src/momapy/rendering/core.py
get_lighter_font_weight
classmethod
get_lighter_font_weight(
font_weight: FontWeight | float,
) -> float
Return the boldest font weight lighter than the given font weight
Source code in src/momapy/rendering/core.py
new_page
render_drawing_element
render_layout_element
SVGNativeRenderer
dataclass
SVGNativeRenderer(
svg: SVGElement,
config: dict = dict(),
_filter_elements: list[SVGElement] = list(),
)
Bases: Renderer
Class for SVG native renderers
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
svg
|
SVGElement
|
|
required |
config
|
dict
|
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2) |
<class 'dict'>
|
Methods:
| Name | Description |
|---|---|
begin_session |
Begin a session |
end_session |
End a session |
get_bolder_font_weight |
Return the lightest font weight bolder than the given font weight |
get_lighter_font_weight |
Return the boldest font weight lighter than the given font weight |
new_page |
Make a new page |
render_drawing_element |
Render a drawing element |
render_layout_element |
Render a layout element |
render_map |
Render a map |
begin_session
end_session
End a session
Source code in src/momapy/rendering/svg_native.py
get_bolder_font_weight
classmethod
get_bolder_font_weight(
font_weight: FontWeight | float,
) -> float
Return the lightest font weight bolder than the given font weight
Source code in src/momapy/rendering/core.py
get_lighter_font_weight
classmethod
get_lighter_font_weight(
font_weight: FontWeight | float,
) -> float
Return the boldest font weight lighter than the given font weight