svgen.element package#
Subpackages#
Submodules#
svgen.element.circle module#
svgen - A module for the ‘circle’ element.
- class svgen.element.circle.Circle(circle: Circle, attrs: dict[str, str | int | float | bool] | list[Attribute] | Attribute = None, **extra)[source]#
Bases:
Element
A class for circle elements.
- static centered(box: ViewBox | Rectangle, radius_scale: float = 1.0, color: str | Hsl | Rgb | Color = None, prop: str = 'fill', **kwargs) Circle [source]#
From a viewBox, create a circle that is centered with an appropriately scaled radius.
- static create(center: Point, radius: float, color: str | Hsl | Rgb | Color = None, prop: str = 'fill', **kwargs) Circle [source]#
Create a circle from a point and radius.
- property radius: float#
Get this circle’s radius.
- translate(move: Translation) Circle [source]#
Move this circle by a given translation.
svgen.element.line module#
svgen - A module for the ‘line’ element.
- class svgen.element.line.Line(p1: Point, p2: Point, attrs: dict[str, str | int | float | bool] | list[Attribute] | Attribute = None, **extra)[source]#
Bases:
Element
A definition of a line.
- static create(x2: float, y2: float, x1: float = 0.0, y1: float = 0.0, attrs: dict[str, str | int | float | bool] | list[Attribute] | Attribute = None, **extra) Line [source]#
Create a line.
- translate(move: Translation | float, *args, **kwargs) Line [source]#
Move a rectangle by a given translation.
svgen.element.rect module#
svgen - A module for the ‘rect’ element.
- class svgen.element.rect.Rect(rect: Rectangle, rx: float = 0.0, ry: float = 0.0, attrs: dict[str, str | int | float | bool] | list[Attribute] | Attribute = None, **extra)[source]#
Bases:
FillColorMixin
,RectangularMixin
,RadiusXyMixin
A class for rect elements.
- static centered(box: ViewBox | Rectangle, width_scale: float = 1.0, height_scale: float = 1.0, color: str | Hsl | Rgb | Color = None, prop: str = 'fill', square: bool = False, **kwargs) Rect [source]#
From a viewBox, created a centered-and-scaled rectangle.
- corner(corner: RectangleCorner) Point [source]#
Get a specific corner of a rectangle.
- static create(width: float, height: float, point: Point = (0.0, 0.0, False, -1), **kwargs) Rect [source]#
Create a rectangle element.
- grid(columns: int, rows: int) RectangleGrid [source]#
Create a grid from this rectangle.
- property height: float#
Get the height of this rectangle element.
- scale(width_scale: float = 1.0, height_scale: float = 1.0) Rect [source]#
Scale this rectangle’s width and height.
- property square: bool#
Determine if this rectangle is square.
- translate(move: Translation) Rect [source]#
Move this rectangle by a given translation.
- property width: float#
Get the width of this rectangle element.
svgen.element.svg module#
svgen - A module for the ‘svg’ element.
svgen.element.text module#
A module for the ‘text’ element.
- class svgen.element.text.Text(text: str, rect: Rect, attrs: dict[str, str | int | float | bool] | list[Attribute] | Attribute = None, **extra)[source]#
Bases:
FillColorMixin
,RectangularMixin
A class for text elements
- has_dimensions = False#
Module contents#
svgen - Common interfaces and assets for SVG elements.
- class svgen.element.Element(tag: str = None, text: str = '', attrib: List[Attribute] = None, children: List[Element] = None, allow_no_end_tag: bool = True, class_str: str = None, preformatted: bool = False, **extra)[source]#
Bases:
object
A basic interface for an SVG element.
- encode(output: TextIO, quote: str = '"', indent: int = 0, newlines: bool = True) None [source]#
Encode this element to a string stream.
- encode_str(quote: str = '"', indent: int = 0, newlines: bool = True) str [source]#
Encode this element to a string.
- property xml: Element#
Get this element as an xml element.