Skip to main content

for-each-anchor

for-each-anchor() 

Iterates through all named anchors of an element and calls a callback for each one.

// Label nodes anchors
rect((0, 0), (2,2), name: "my-rect")
for-each-anchor("my-rect", exclude: ("start", "mid", "end"), (name) => {
content((), box(inset: 1pt, fill: white, text(8pt, [#name])), angle: -30deg)
})

name:

The name of the element with the anchors to loop through.

callback:

A function that takes the anchor name and can return elements.

exclude:

Default: ()

An array of anchor names to not include in the loop.