/absvgen

Abstract generator of SVG files from a YAML specification

Primary LanguageGoGNU Affero General Public License v3.0AGPL-3.0

absvgen (abstract svg generator)

absvgen is a command line tool to specify a set of rules and to get an SVG back that can then be converted to different formats using other tools.

Usage

The command absvgen requires the configuration flag --spec with a path to a valid specification file. It also accepts the flag --debug to enable debug output.

So basic usage goes like this:

absvgen --spec path/to/spec.yaml [--debug]

One can also give the special filename - to the spec flag to make it read the config file from stdin, either of these variations is fine:

cat path/to/spec.yaml | absvgen --spec - [--debug]

absvgen --spec - [--debug] < path/to/spec.yaml

This will output the resulting SVG to stdout, if you have the debug flag enabled, the debug messages will be on stderr.

Save file as SVG:

absvgen --spec path/to/spec.yaml [--debug] > target-file.svg

You can also choose to convert it to PNG on the fly:

absvgen --spec path/to/spec.yaml [--debug] | rsvg-convert > target-file.png

Basic YAML config file structure

So the configuration file is a YAML file. The basic file looks like this:

width: 500
height: 300
layers: []

The layers key is a list of layers to render into your SVG, the layers should consist of modules. The modules uses different options to make different patterns on the resulting image.

Modules

Hexagons (Also known as Bestagons)

https://raw.githubusercontent.com/etu/absvgen/main/.github/hexagons.svg

The hexagons module generates a polygon object in shapes of hexagons that takes up the full image, it also accepts size as a parameter to determine how many percentage of the image width the hexagons should be in size. It also accepts a list of colors as input to use as colors for the hexagons, when the list runs out it starts over.

This is the configuration used for the hexagons module rendered above:

width: 500
height: 300
layers:
  - module: hexagons
    size: 10
    colors:
      - '#0f1784'
      - '#420f84'
      - '#0f5284'
      - '#0f3284'
      - '#270f84'

Squares

https://raw.githubusercontent.com/etu/absvgen/main/.github/squares.svg

The squares module generates squares that covers the full image, it also accepts size as a parameter to determine how many percentage of the image width the squares should be in size and a color list that it will pick from and start over when the list runs out.

This is the configuration used for the squares module rendered above:

width: 500
height: 300
layers:
  - module: squares
    size: 10
    colors:
      - '#0f1784'
      - '#420f84'
      - '#0f5284'
      - '#0f3284'
      - '#270f84'
      - '#0f6d84'
      - '#5d0f84'

Triangles

https://raw.githubusercontent.com/etu/absvgen/main/.github/triangles.svg

The triangles module generates a polygon objects that covers the full image, it also accepts size as a parameter to determine how many percentage of the image width the triangles should be in size and a color list that it will pick from and start over when the list runs out.

This is the configuration used for the triangles module rendered above:

width: 500
height: 300
layers:
  - module: triangles
    size: 10
    colors:
      - '#0f1784'
      - '#420f84'
      - '#0f5284'
      - '#0f3284'
      - '#270f84'
      - '#0f6d84'

Solid

https://raw.githubusercontent.com/etu/absvgen/main/.github/solid.svg

The solid module generates a rectangle object that takes up the full image, it also accepts a color as input to use as color for the rectangle.

This is the configuration used for the solid module rendered above:

width: 500
height: 300
layers:
  - module: solid
    colors:
      - '#1f4294'

This module only reads the first color in the colors list, this is the intention so the colors list can be re-used for modules that wants more than one color.

Stripes

https://raw.githubusercontent.com/etu/absvgen/main/.github/stripes.svg

The stripes modules generates vertical stripes on top of a background, it accepts a size as a parameter to determine how many percentage of the image with each stripe should be, this is also used for spacing between each stripe. Then it accepts the colors list and will make a single stripe for each color once.

This is the configuration used for the stripes module on top of a solid module rendered above:

width: 500
height: 300
layers:
  - module: solid
    colors:
      - '#1f4294'
  - module: stripes
    size: 4
    colors:
      - '#0f3284'
      - '#0f3284'
      - '#0f3284'

Dummy

There’s a dummy module that only emits a comment block that it was used. The purpose of this was mostly to have a fallback if no valid module was selected.

The layers specification for a dummy module can look like this:

- module: dummy