svgutils-0.1: Helper functions for dealing with SVG files

Data.SVG.Tile

Description

A module with a helper function for tiling several SVG files (which can vary in size) into a group of SVG files of a specific size.

Synopsis

Documentation

data TileItem Source

An item to be tiled, with an SVG image for the front, and an optional SVG for the back. If the two images are different sizes, the smallest size that can accommodate both is used for tiling. This means that if you have a larger back image, the front will have enough space left to match up with the back (and vice versa).

The label is currently only used for error reporting.

Constructors

TileItem 

tileSVGs :: DPI -> TileSettings -> [TileItem] -> Either String [(SVG, Maybe SVG)]Source

Tiles the given items.

This function takes a list of front (and optional back) SVG images, then arranges them using the given paper size, margin and gaps between items. The return is a list of front images (with back images where needed).

This method is intended to be used to put multiple small SVG items onto a single page for printing.

The layout algorithm is very simple. It places the first item in the top-left, then attempts to fill the rest of the row with the next items in the list. Once a row is full, it moves down to make more rows, until the page is full. Thus, list items will always appear in the order they are given, and you can potentially get some wasted space, especially if the items vary wildly in size, and are not sorted by size first.

This method can fail because it cannot get the sizes of the items to tile using getSVGSize, because there are conflicts between the namespaces of the files, or because there are one or more items in the list that cannot fit on a single page by themselves.

data TileSettings Source

The settings for tiling: the paper size, margin (same on all sides) and gap (between tiled items)