svgen.attribute package#
Submodules#
svgen.attribute.style module#
svgen - A module for the ‘style’ attribute.
- class svgen.attribute.style.CssProperty(key: str, value: str)[source]#
Bases:
NamedTuple
A class for interacting with css properties.
- static color(color: str | Hsl | Rgb | Color, prop: str = 'fill', **kwargs) CssProperty [source]#
Get a CSS property for a color.
- static decode(value: str) List[CssProperty] [source]#
Create css properties from a string.
- static encode(props: List[CssProperty]) str [source]#
Encode a list of css properties to a string.
- property encoded: str#
Convert this css property to a string.
- static from_dict(data: Dict[str, str | int | float]) List[CssProperty] [source]#
Get a list of attributes from dictionary data.
- key: str#
Alias for field number 0
- value: str#
Alias for field number 1
- class svgen.attribute.style.Style(props: Dict[str, str | int | float] | List[CssProperty] | CssProperty = None)[source]#
Bases:
Attribute
An interface for style attributes.
- add(props: Dict[str, str | int | float] | List[CssProperty] | CssProperty) None [source]#
Add CSS properties to this style instance.
- add_color(color: str | Hsl | Rgb | Color, prop: str = 'fill', **kwargs) Style [source]#
Set a style property to a color.
- property value: str#
Get the string value for this attribute.
- svgen.attribute.style.properties(data: Dict[str, str | int | float] | List[CssProperty] | CssProperty = None) List[CssProperty] [source]#
Get properties from either an existing list of properties, or dictionary data.
svgen.attribute.viewbox module#
svgen - A module for the ‘viewBox’ attribute.
- class svgen.attribute.viewbox.ViewBox(min_x: int, min_y: int, width: int, height: int)[source]#
Bases:
Attribute
An interface for viewBox attributes.
- property dimensions: Dimensions#
Get this viewBox’s dimensions.
- property height: int#
Get the height of this viewbox.
- property key: str#
Get the string key for this attribute.
- new_grid(rect: Rectangle = None, columns: int = None, rows: int = None) RectangleGrid [source]#
Create a grid from this viewBox.
- translate(dx: Translation | float, *args, **kwargs) None [source]#
Apply a translation to this viewBox.
- property value: str#
Get the string value for this attribute.
- property width: int#
Get the width of this viewbox.
- class svgen.attribute.viewbox.ViewBoxData(min_x: int, min_y: int, width: int, height: int)[source]#
Bases:
NamedTuple
Primitive data for a viewBox attribute.
- static from_dict(data: Dict[str, Any]) ViewBoxData [source]#
Create viewBox data from a dictionary.
- height: int#
Alias for field number 3
- min_x: int#
Alias for field number 0
- min_y: int#
Alias for field number 1
- translate(dx: int, dy: int) ViewBoxData [source]#
Translate this viewBox.
- width: int#
Alias for field number 2
Module contents#
svgen - A module for XML-style attribute interfaces.
- class svgen.attribute.Attribute[source]#
Bases:
ABC
An interface for an XML-style attribute.
- abstractmethod classmethod decode(key: str, value: str) T [source]#
Create this attribute from a string.
- property key: str#
Get the string key for this attribute.
- abstract property value: str#
Get the string value for this attribute.
- class svgen.attribute.SimpleAttribute(name: str, value: str | int | float | bool)[source]#
Bases:
Attribute
A simple, concrete implementation for attribute.
- classmethod decode(key: str, value: str) SimpleAttribute [source]#
Create this attribute from a string.
- static from_dict(data: dict[str, str | int | float]) list[Attribute] [source]#
Get a list of attributes from dictionary data.
- property value: str#
Get the string value for this attribute.