@logomarks/patterns
v0.1.0
Published
Seamless brand patterns from a logomark (or two or three): grid, brick, half-drop, diamond, hex, scattered, striped, tight and checkered layouts, turned, mirrored, sized and outlined by rule, in one ink, two or tones. Pure SVG tiles that repeat by constru
Maintainers
Readme
@logomarks/patterns
Seamless brand patterns from a logomark (or two or three). Pure SVG out, seeded, no dependencies beyond
@logomarks/core; runs in the browser and in Node.
import { pattern, patterns, fill } from '@logomarks/patterns';
const p = pattern(markSvg, { layout: 'halfdrop', gap: 0.4, colors: { ink: '#111', ground: '#f4f3ef' } });
p.svg; // one tile: repeat it in both directions
fill(p, { width: 1170, height: 2532 }); // a phone wallpaper: the tile repeated, `density` marks across
patterns([markA, markB], { count: 24 }); // a page of 24 different patterns, each with a `name`What it draws
| Setting | Choices |
| --- | --- |
| layout | grid, brick, halfdrop, diamond, hex, scatter (evenly spread, seeded), stripes (rows of marks), tight (edge to edge on the mark's own box), blocks (a checkerboard, the mark knocked out of every other square) |
| turn | none, alternate (every other upside down), quarter, mirror (pairs across), rows (pairs down), spin (sixths), random |
| sizes | uniform, alternate, steps (three sizes), random |
| style | solid, outline, mix |
| colour | mono, duo (ink and accent turn about), tonal (the ink at three strengths) |
| accent | none, dot, ring between the marks of a grid |
| numbers | gap, scale (the small marks), angle, density (marks across a filled preview), stroke, and rules (thin lines between rows) |
CONTROLS lists every setting with its range and default, for building a panel; resolve() clamps anything given.
colors is { ink, accent, ground }; without a ground the tile is transparent.
Seamless by construction
A mark whose reach crosses the tile's edge is drawn again one tile away, so cut halves always meet. The tile's size is
the lattice's cell times the least number of cells every rule (turns, sizes, inks, the marks given) needs to come round.
The tests render each layout, lay the tile 2 × 2 and compare the middle with the same pattern cut half a tile along
(shift).
Rasters
The library only writes SVG. tileSize(p, 1024) gives the pixel size for a tile that wide (tiles are not always
square: a hex tile is shorter than it is wide); render p.svg at that size with any SVG rasteriser.
Give each pattern on one page its own id (the prefix of the ids inside the SVG); patterns() does.
MIT. Part of Logomarks.
