nested group anchors aren't working correctly
I want to put some kind of box with a title on arbitrary cetz canvas elements.
I saw that you can position a group as a whole by setting the group(anchor: "...") parameter, but it doesn't seem to work correctly in my specific case.
Example code:
#import "@preview/cetz:0.4.2"
#let apartment(pos, title: "", name: none, anchor: none, body) = {
let anchor-input = anchor
import cetz.draw: *
let box-size = (rel: (2, 1.2em))
move-to(pos)
group({
group(name: "body", padding: 0.15, body)
rect("body.north-west", box-size)
content("body.north-west", box-size, name: "title")[#box(inset: 0.2em, height: 1em)[#title]]
rect-around("body")
}, anchor: anchor-input, name: name)
}
#box(stroke: 2pt + red, cetz.canvas({
import cetz.draw: *
grid((-3, -3), (3, 3), help-lines: true)
move-to((0,0))
circle((), radius: 0.1, fill: blue)
apartment((), name: "2", anchor: "west", title: [Title], {
circle((), radius: 0.1, fill: green)
})
circle("2.west", radius: 0.1, fill: red)
line("2.west", (0,0), mark: (end: ">"))
}))
if i understand the feature correctly, the specified anchor of the group should be exactly at the position where we started drawing the group. In my case, the start point is marked with a blue circle and the corresponding anchor with a red circle. if you render this document, you can see that the two circles are not in fact at the same position.
Okay, i figured out that the group anchor always calculates the transform relative to the default anchor, which is "center" if nothing else is specified.
so if i add a anchor("default", ...) inside the group, i can get my desired transform.
maybe put this somewhere in the group anchor documentation?