#[CeTZ] How to rotate of a calculated angle?
5 messages · Page 1 of 1 (latest)
This is not that easy right now, but doable:
#import "@preview/cetz:0.1.1"
#cetz.canvas({
import cetz.draw: *
line((0,0), (2,2), name: "l")
get-ctx(ctx => {
let (x,y,..) = cetz.coordinate.resolve(ctx, "l.start")
let (x2,y2,..) = cetz.coordinate.resolve(ctx, "l.end")
let a = calc.atan2(y2 - y, x2 - x)
rotate(a)
rect((1,0), (2,1), fill: blue)
})
})
You can use cetz.coordinate.resolve with get-ctx (or group(ctx => {...}) to resolve an anchor to a vector.
Wonderful! Thanks a lot, it was very difficult to get it without your help.
the resolve function and such dont seem to be part of the manual so it is hard to find
Yes, that is true. I'll add them.