enclose
Draws a rounded rectangle around the union of its children's bounding boxes, padded by padding. Use it to group elements of a diagram visually.
python
from gofish import enclose, stack, rect
enclose(
[
stack(
[rect(w=40, h=40, fill="#a0c4e8"), rect(w=40, h=60, fill="#e8a0a0")],
dir="x",
)
],
padding=10,
stroke="#4e79a7",
).render(w=160, h=120)Signature
python
enclose(children, *, padding=None, rx=None, ry=None, fill=None,
stroke=None, stroke_width=None, stroke_dasharray=None,
opacity=None) -> Markbackground is an alias for the same function: it takes the same arguments and produces the same node.
The enclosure is the children's bbox union grown by padding, so it draws nothing of its own beyond that box — reach for position when one child needs a precise absolute offset with its own styling instead.
Parameters
Draw a rounded-rect enclosure around the union of the children's bboxes, padded by padding.
| Option | Type | Default | Description |
|---|---|---|---|
padding | float | 2 | Pixels of slack between the children's bbox union and the drawn enclosure. |
rx | float | 2 | Corner radius, x. |
ry | float | 2 | Corner radius, y. |
fill | str | "none" | Fill color of the enclosure. |
stroke | str | "#D1D9E2" | Stroke color of the enclosure. |
stroke_width | float | 1 | Stroke width in pixels. |
stroke_dasharray | str | Raw SVG stroke-dasharray (e.g. "4 2") for a dashed enclosure. | |
opacity | float | 1 | Opacity, 0 to 1. |
