svgen package — docs

Skip to main content
`Ctrl`+`K`

# svgen package

## Subpackages

- svgen.attribute package
  - Submodules
  - svgen.attribute.style module
    - `CssProperty`
      - `CssProperty.color()`
      - `CssProperty.decode()`
      - `CssProperty.encode()`
      - `CssProperty.encoded`
      - `CssProperty.from_dict()`
      - `CssProperty.key`
      - `CssProperty.value`
    - `Style`
      - `Style.add()`
      - `Style.add_color()`
      - `Style.decode()`
      - `Style.properties`
      - `Style.value`
    - `properties()`
  - svgen.attribute.viewbox module
    - `ViewBox`
      - `ViewBox.center`
      - `ViewBox.decode()`
      - `ViewBox.dimensions`
      - `ViewBox.from_dict()`
      - `ViewBox.height`
      - `ViewBox.key`
      - `ViewBox.new_grid()`
      - `ViewBox.origin`
      - `ViewBox.translate()`
      - `ViewBox.value`
      - `ViewBox.width`
    - `ViewBoxData`
      - `ViewBoxData.center`
      - `ViewBoxData.from_dict()`
      - `ViewBoxData.height`
      - `ViewBoxData.min_x`
      - `ViewBoxData.min_y`
      - `ViewBoxData.origin`
      - `ViewBoxData.translate()`
      - `ViewBoxData.width`
  - Module contents
    - `Attribute`
      - `Attribute.decode()`
      - `Attribute.encode()`
      - `Attribute.key`
      - `Attribute.value`
    - `SimpleAttribute`
      - `SimpleAttribute.decode()`
      - `SimpleAttribute.from_dict()`
      - `SimpleAttribute.value`
    - `attributes()`
- svgen.cartesian package
  - Subpackages
    - svgen.cartesian.rectangle package
      - Submodules
      - svgen.cartesian.rectangle.corner module
      - svgen.cartesian.rectangle.grid module
      - Module contents
  - Submodules
  - svgen.cartesian.angle module
    - `DegreePrimitive`
      - `DegreePrimitive.arc()`
      - `DegreePrimitive.rotate()`
    - `Rotatable`
      - `Rotatable.arc()`
  - svgen.cartesian.circle module
    - `Circle`
      - `Circle.attrs`
      - `Circle.center`
      - `Circle.center_attrs`
      - `Circle.radius`
      - `Circle.radius_attr`
      - `Circle.scale()`
      - `Circle.translate()`
    - `CircleAttrs`
      - `CircleAttrs.center`
      - `CircleAttrs.radius`
      - `CircleAttrs.radius_val`
  - svgen.cartesian.mutate module
    - `Angle`
      - `Angle.cos`
      - `Angle.degrees`
      - `Angle.from_degrees()`
      - `Angle.from_radians()`
      - `Angle.radians`
      - `Angle.sin`
    - `Translation`
      - `Translation.dx`
      - `Translation.dy`
      - `Translation.normalize()`
      - `Translation.polar()`
      - `Translation.rotate()`
  - svgen.cartesian.plane module
    - `Plane`
      - `Plane.origin`
  - svgen.cartesian.point module
    - `Point`
      - `Point.attrs`
      - `Point.center`
      - `Point.distance()`
      - `Point.idx`
      - `Point.polar()`
      - `Point.to_center()`
      - `Point.translate()`
      - `Point.with_index()`
      - `Point.x`
      - `Point.x_attr`
      - `Point.y`
      - `Point.y_attr`
    - `PointAttrs`
      - `PointAttrs.x`
      - `PointAttrs.x_val`
      - `PointAttrs.y`
      - `PointAttrs.y_val`
    - `PointManager`
      - `PointManager.add_point()`
      - `PointManager.get_point()`
      - `PointManager.translate()`
    - `to_center()`
  - Module contents
    - `DimensionAttrs`
      - `DimensionAttrs.height`
      - `DimensionAttrs.height_val`
      - `DimensionAttrs.width`
      - `DimensionAttrs.width_val`
    - `Dimensions`
      - `Dimensions.attrs`
      - `Dimensions.dx`
      - `Dimensions.dy`
      - `Dimensions.height`
      - `Dimensions.height_attr`
      - `Dimensions.scale()`
      - `Dimensions.square`
      - `Dimensions.to_centered_square()`
      - `Dimensions.to_square()`
      - `Dimensions.width`
      - `Dimensions.width_attr`
    - `distance()`
- svgen.color package
  - Subpackages
    - svgen.color.theme package
      - Submodules
      - svgen.color.theme.manager module
      - svgen.color.theme.visualize module
      - Module contents
  - Submodules
  - svgen.color.alpha module
    - `Alpha`
      - `Alpha.hex_str`
  - svgen.color.conversion module
    - `hsl_to_rgb()`
    - `rgb_to_hsl()`
  - svgen.color.hsl module
    - `Hsl`
      - `Hsl.alpha`
      - `Hsl.animate()`
      - `Hsl.arc()`
      - `Hsl.from_ctor()`
      - `Hsl.hue`
      - `Hsl.lightness`
      - `Hsl.saturation`
    - `PercentPrimitive`
      - `PercentPrimitive.arc()`
      - `PercentPrimitive.ratio`
    - `hsl()`
    - `hsla()`
  - svgen.color.numbers module
    - `css_number_to_ratio()`
    - `parse_ctor()`
  - svgen.color.resolve module
    - `get_color()`
  - svgen.color.rgb module
    - `Rgb`
      - `Rgb.alpha`
      - `Rgb.animate()`
      - `Rgb.blue`
      - `Rgb.from_ctor()`
      - `Rgb.from_hex()`
      - `Rgb.green`
      - `Rgb.red`
      - `Rgb.rgb`
      - `Rgb.rgba`
    - `RgbPrimitive`
      - `RgbPrimitive.ratio`
    - `rgb()`
    - `rgba()`
  - Module contents
    - `Color`
      - `Color.animate()`
      - `Color.create()`
      - `Color.from_ctor()`
      - `Color.from_hex()`
      - `Color.from_hsl()`
      - `Color.from_rgb()`
      - `Color.hsl`
      - `Color.hsl_arc()`
      - `Color.rgb`
- svgen.element package
  - Subpackages
    - svgen.element.html package
      - Module contents
    - svgen.element.mixins package
      - Module contents
  - Submodules
  - svgen.element.circle module
    - `Circle`
      - `Circle.center`
      - `Circle.centered()`
      - `Circle.create()`
      - `Circle.radius`
      - `Circle.scale()`
      - `Circle.translate()`
  - svgen.element.line module
    - `Line`
      - `Line.create()`
      - `Line.translate()`
    - `line()`
  - svgen.element.path module
    - `Path`
      - `Path.create()`
    - `PathBuilder`
      - `PathBuilder.close()`
      - `PathBuilder.horizontal()`
      - `PathBuilder.path()`
      - `PathBuilder.point()`
      - `PathBuilder.translation()`
      - `PathBuilder.vertical()`
    - `PathCmd`
      - `PathCmd.LINE`
      - `PathCmd.MOVE`
    - `compose_borders()`
  - svgen.element.rect module
    - `Rect`
      - `Rect.bottom_left`
      - `Rect.bottom_right`
      - `Rect.centered()`
      - `Rect.corner()`
      - `Rect.create()`
      - `Rect.grid()`
      - `Rect.height`
      - `Rect.scale()`
      - `Rect.scale_whole()`
      - `Rect.square`
      - `Rect.to_square()`
      - `Rect.top_left`
      - `Rect.top_right`
      - `Rect.translate()`
      - `Rect.width`
  - svgen.element.svg module
    - `Svg`
      - `Svg.app()`
    - `add_background_grid()`
  - svgen.element.text module
    - `Text`
      - `Text.has_dimensions`
  - Module contents
    - `Element`
      - `Element.add_attribute()`
      - `Element.add_class()`
      - `Element.attributes`
      - `Element.booleans`
      - `Element.children`
      - `Element.closing()`
      - `Element.encode()`
      - `Element.encode_str()`
      - `Element.has_children()`
      - `Element.style`
      - `Element.xml`
- svgen.generation package
  - Submodules
  - svgen.generation.images module
    - `generate_icon()`
    - `generate_images()`
  - Module contents
- svgen.shapes package
  - Submodules
  - svgen.shapes.chip module
    - `add_chip()`
    - `add_outline_chip()`
    - `add_outline_pins()`
    - `handle_debug()`
  - svgen.shapes.pins module
    - `add_pins()`
    - `corners_translated()`
    - `translate_maps()`
  - Module contents

## Submodules

## svgen.app module

svgen - This package’s command-line entry-point application.

svgen.app.add_app_args(parser: ArgumentParser) → None

  Add application-specific arguments to the command-line parser.

svgen.app.entry(args: Namespace) → int

  Execute the requested task.

svgen.app.generate(config: Config, output: Path, cwd: Path, scripts: Iterable[Path], images: bool = True) → None

  Generate a single SVG document.

## svgen.config module

A module implementing package configuration data interfaces.

svgen.config.add_dimension_args(parser: ArgumentParser) → None

  Add dimension-related arguments to the command-line parser.

svgen.config.initialize_config(config: Config | dict[str, Any], default_height: int = 100, default_width: int = 100, default_theme: str = 'gray') → None

  Set initial values for SVG document configurations.

## svgen.display module

A module for working with common display assets.

class svgen.display.AspectRatio(width: int, height: int, final: bool = False)

  Bases: `NamedTuple`

  A class to storge a width and height ratio.

  property args: list[str]

    Get inkscape command-line arguments.

  as_str(delim: str = ':') → str

    Get this aspect ratio as a string.

  static create(wxh: str, delim: str = ':') → AspectRatio

    Create an aspect ration from a string.

  final: bool

    Alias for field number 2

  height: int

    Alias for field number 1

  property landscape: bool

    Determine if this ratio is landscape.

  property over_height: float

    Express this ratio as one of width over height.

  property portrait: bool

    Determine if this ratio is portrait.

  rotate() → AspectRatio

    Get this aspect ratio rotated.

  property square: bool

    Determine if this is a square aspect ratio.

  width: int

    Alias for field number 0

svgen.display.common_sizes(ratio: str | AspectRatio | ViewBox) → Iterator[AspectRatio]

  Iterate over common sizes for a given aspect ratio.

## svgen.entry module

This package’s command-line entry-point (boilerplate).

svgen.entry.main(argv: list[str] = None) → int

  Program entry-point.

## svgen.inkscape module

A module for generating image outputs from SVG via Inkscape.

inkscape/inkscape

class svgen.inkscape.InkscapeTask(name: str, *args, execute: Callable[[dict[str, dict[str, Any]], dict[str, Any]], Coroutine[Any, Any, bool]] = None, log: Logger = None, timer: Timer = None, target: Target = None, **kwargs)

  Bases: `SubprocessExecStreamed`

  A task implementation for invoking inkscape at command-line.

  async invoke(*cli_args, entry: str = 'inkscape') → bool

    Invoke inkscape.

async svgen.inkscape.invoke(*cli_args: str, entry: str = 'inkscape') → bool

  Run an inkscape command-line command.

async svgen.inkscape.invoke_multiple(args: list[list[str]], entry: str = 'inkscape') → bool

  Run multiple inkscape invocations at the same time.

## svgen.script module

svgen - A module for working with external scripts.

svgen.script.invoke_script(path: Path, svg: Svg, config: Config) → None

  Invoke an external script’s ‘compose’ function.

## Module contents

Useful defaults and other package metadata.