Tile directive

Tiled Rendering
Context Free/CFDG is good at creating stand-alone shapes, but shapes that that need to repeat in the X and Y directions can be hard. If the shapes do not overlap themselves or if the overlapping parts are all the same color then it is possible to take a stand-alone shape and manipulate it in a bitmap editor to produce the tiled overlapping that is needed for the bitmap to be seamlessly repeated. If the overlapping parts are not all the same color then it is not possible to make a shape repeating using a bitmap editor because some component primitive shapes need to be drawn on top of others and all of the primitive shape information is lost when a cfdg file is saved as a bitmap.

The Tile Directive
Adding a tile directive to a cfdg file makes it a tiled cfdg shape. A tiled cfdg is drawn as if the whole shape were replicated on each point of a tiling grid. The resulting PNG file can be tiled to produce a seamless mosaic of the original cfdg shape. A tile directive consists of the word tile followed by a shape adjustment. The shape adjustment defines an affine transform that is applied to the default tiling grid to produce the tiling grid that you want. The default tiling grid is 1 unit spacing in both axes.

If we want to take the tangle.cfdg file included in the examples and make a tiled version we would write: The s 60 in the tile directive shape adjustment expands the tiling grid from 1x1 units to 60x60 units. Since tangles.cfdg tends to be about 120x120 units this causes about a 50% self-overlap. If you replicate this image you see that it seamlessly tiles the plane.

The tile directive changes the rendering process in two ways: If the aspect ratio of the drawing canvas is different than the aspect ratio of the tiling grid then either the width or height of the drawing canvas is shrunk so that the aspect ratios match.
 * 1) It fixes the scale of the output such that exactly one unit of the tiling grid fits into the rendering canvas.
 * 2) It draws a copy of the shape at each point of the tiling grid. The tiling grid is infinite in extent, but only pixels that fit into the drawing canvas are drawn.