fletcher.flexigrid()
A βflexibleβ coordinate system to be placed in CeTZ canvas which adapts to nodes contained therein.
Objects drawn inside a flexigrid have access to a coordinate system, which is a nonlinear grid of rows and columns which stretch to fit nodes, like a table. Only content placed in node() can affect the grid; edge()s and plain CeTZ objects in a flexigrid never affect the layout.
By default, nodes and edges use coordinates while CeTZ objects use the default coordinates. Use the coordinate expressions (uv: ..) and (xy: ..) to specify the system. Both systems can be mixed in coordinate expressions like ((uv: (1,2)), 50%, (xy: (0,0))).
#cetz.canvas({
import cetz.draw: *
fletcher.flexigrid(debug: "grid", {
set-style(node: (fill: yellow))
node((0,0))[Nodes...]
node((2,1))[...in $u v$ system]
circle((uv: (2,0)), radius: 5pt, fill: blue)
content((3,2))[Content in $x y$ system]
})
})The main diagram() function is essentially equivalent to flexigrid() wrapped in cetz.canvas().
fletcher.flexigrid( ..args, spacing: number length pair, axes: array, max-layout-iterations: int, debug, )
spacing
1.0Gutter between cells.
Numbers are interpreted in CeTZ units. Column and row gutter can be controlled independently as the first and last numbers in a pair, (col-gutter, row-gutter).
axes
(ltr, ttb)The physical orientation of the axes.
This affects the elastic coordinate system used by nodes and edges. By default, the coordinate increases and increases . To use , which is what CeTZ uses by default, set axes: (ltr, btt).
max-layout-iterations
20Maximum number of layout iterations used to find row and column sizes before converging.
Diagrams with nodes at fractional coordinates may require more iterations of the layout algorithm until the flexigrid stabilizes. You can see how many iterations were used with the debug: "grid.iters" option.