#Is there a way to pre-calculate the size a Cetz object might take?

2 messages · Page 1 of 1 (latest)

urban tusk
#

My use case is something like the following.

    cetz.canvas({
        let (x, y) = (0, 0)
        let shape = my-custom-shape((x, y))
        // the shape will take up some space
        let (dx, dy) = cetz-measure(shape)
        x += dx
        y += dy

        shape
        circle((x, y)) // where we end up
    })

iron ingot
#

Yes, you can calculate the size (using process.many(...) and use the returned bounds), but I guess a simpler solution could work for you:
Use anchors of your shape. Wrap your shape in a group(name: "my-shape", ...) and use border anchors of that group. E.g. circle("my-shape.south-east").