Skip to content

Layout options ​

These options shape every layout, whatever the pattern. The pictures use hexagons in a 160 × 110 region.

Gap ​

gap is the space between neighboring tiles: the grout. The renderers show the layout's background through it.

gap: 0
gap: 0
gap: 2
gap: 2
gap: 6
gap: 6

Margin ​

margin keeps a border clear along the region's edge and round any holes.

margin: 0
margin: 0
margin: 10
margin: 10

Rounded corners ​

cornerRadius rounds every corner. A corner too small for the full radius gets the largest radius that fits, so short edges and sharp corners stay tidy. SVG and canvas draw true arcs, and the HTML renderers approximate them in the clip-path.

cornerRadius: 0
cornerRadius: 0
cornerRadius: 4
cornerRadius: 4
cornerRadius: 12
cornerRadius: 12

Rotation, origin and scale ​

  • rotation: turns the pattern, in degrees.
  • origin: shifts the pattern. For Penrose, the hat and the spectre it's the fixed center the pattern grows from.
  • tileScale: scales the whole pattern, whatever its size settings are called. This is how fit sizes tiles to the content.

The random patterns and flow ignore rotation and origin.

runningBond, rotation: 0
runningBond, rotation: 0
rotation: 30
rotation: 30
tileScale: 0.5
tileScale: 0.5

Slivers at the edge ​

Where the region's edge cuts a tile, a small piece can be left behind. minFill drops cut tiles smaller than that fraction of a whole tile.

minFill: 0
minFill: 0
minFill: 0.6
minFill: 0.6

The code for these pictures:

ts
import { createLayout, hexagonal, runningBond, type LayoutOptions } from "@andamento/core";
import { renderToString } from "@andamento/svg";

const fill = ["#2a9d8f", "#e9c46a", "#f4a261", "#e76f51"];
const draw = (options: Partial<LayoutOptions>) =>
  renderToString(
    createLayout({ region: { x: 0, y: 0, width: 160, height: 110 }, tiling: hexagonal({ size: 20 }), ...options }),
    { fill, background: "#264653" },
  );

/** `gap`: the grout between tiles. */
export const gaps = () => ({ "gap-0": draw({ gap: 0 }), "gap-2": draw({ gap: 2 }), "gap-6": draw({ gap: 6 }) });

/** `margin`: a border kept clear along the region's edge. */
export const margins = () => ({ "margin-0": draw({ gap: 2, margin: 0 }), "margin-10": draw({ gap: 2, margin: 10 }) });

/** `cornerRadius`: rounded tiles (it shrinks to fit small corners). */
export const corners = () => ({
  "radius-0": draw({ gap: 3, cornerRadius: 0 }),
  "radius-4": draw({ gap: 3, cornerRadius: 4 }),
  "radius-12": draw({ gap: 3, cornerRadius: 12 }),
});

/** `rotation` (degrees) and `tileScale`. */
export const transforms = () => {
  const bricks = (o: Partial<LayoutOptions>) => draw({ tiling: runningBond({ width: 40, height: 18 }), gap: 2, ...o });
  return { "rotation-0": bricks({}), "rotation-30": bricks({ rotation: 30 }), "scale-half": bricks({ tileScale: 0.5 }) };
};

/** `minFill`: drop slivers at the edge smaller than this share of a tile. */
export const slivers = () => ({ "minfill-0": draw({ gap: 2, minFill: 0 }), "minfill-60": draw({ gap: 2, minFill: 0.6 }) });

All the options ​

OptionDefault
region(required)A rectangle { x, y, width, height } or a simple polygon. See Regions.
tiling(required)The pattern spec. See Patterns.
holesnoneRectangles or polygons to leave empty.
gap0Space between tiles.
margin0Border kept clear along the region's edge and round holes.
cornerRadius0Radius of every tile corner.
rotation0Pattern rotation, in degrees.
originregion's top leftWhere the pattern is anchored.
edges"clip""clip", "inside", "overflow" or "window". See Edges.
minFill0Drop edge tiles smaller than this fraction of a tile.
tileScale1Scale the whole pattern.
featuresnoneGroups of tiles merged into bigger cells. See Featured tiles.
sizeAtnoneVary the tile size across the region. See Tile size by density.
maxTiles20000A safety cap on the number of tiles generated.

Hat tiling and isohedral tilings after Craig S. Kaplan's hatviz and Tactile (BSD 3-Clause).