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:
NamedTupleA 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:
AttributeAn 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:
AttributeAn 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:
NamedTuplePrimitive 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:
ABCAn 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:
AttributeA 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.