mermaid.pixel

index · mermaid

Overview

The pixel painter: a frame's strokes as strips of pixels, one strip a text row. A terminal that shows images lays each strip under its row's text, so the frame's labels stay text and only the lines are a picture.

A cell centre is where the glyph painter's box characters meet, and it is where every stroke runs here. The two painters therefore agree on what each cell holds, and a diagram takes the same rows and columns either way.

A stroke's centre is snapped to the pixel grid, so a line along a row or a column fills whole pixels and stays sharp. Only curves, slants and markers are smoothed.

A text marked knockout lies on a stroke. Its cells are cleared last, so the text is read on a clean ground.

Functions

NameSignature
paintpaint(frame, opts) -> strips

paint(frame, opts) -> strips

Paint a frame's strokes into pixel strips

Returns one entry per row of the frame: { w, h, cols, rgba }, or false for a row with no ink. rgba is w * h * 4 bytes of straight RGBA, w pixels wide and h tall, to be shown over cols columns and one row.

opts:

FieldHolds
cell_w, cell_ha cell's size in pixels; 10 by 20 when not given
inksa colour for each style name, { r, g, b, a } from 0 to 255
strokea line's width in pixels; a tenth of cell_h when not given

An element is drawn in the ink of its style. inks["node.fill"] and inks["group.fill"], when given, fill a box and a group before their outlines are drawn. A style with no ink is drawn in light grey.

The frame must pass mermaid.frame.check. A text is not drawn: it is the caller's to write over the strips.