cetz icon indicating copy to clipboard operation
cetz copied to clipboard

[Feature Request] Extract x, y coordinates from anchors

Open xoconoch opened this issue 1 year ago • 3 comments

I regularly find myself in situations where I need this and I don't think there is a way, I searched through the docs and wasn't able to find anything similar or a workaround. If it is already possible, please show me how.

xoconoch avatar Nov 23 '25 15:11 xoconoch

There already is a way: let (_, vec) = cetz.coordinate.resolve(ctx, <your anchor>) returs the vector to vec.

Example:

get-ctx(ctx => {
  let (_, vec) = cetz.coordinate.resolve(ctx, pt)
  content(at, [#vec])
})

johannes-wolf avatar Nov 23 '25 15:11 johannes-wolf

Thank you very much my friend.

xoconoch avatar Nov 23 '25 15:11 xoconoch

~~Is there a way to add custom anchors? I'd like to allow for, say, the "circle.south.x" anchor to exist inside my canvas using this get-ctx function.~~ I just realized what I said makes no sense lol

xoconoch avatar Nov 23 '25 15:11 xoconoch