cetz-package / cetz

CeTZ: ein Typst Zeichenpaket - A library for drawing stuff with Typst.
https://cetz-package.github.io
GNU Lesser General Public License v3.0
733 stars 34 forks source link

[feature request] Support angle border anchors for `content()` elements #603

Open tapyu opened 1 month ago

tapyu commented 1 month ago

In


#import "@preview/cetz:0.2.2": canvas, draw
#import draw: *

#let i = 50
#canvas({
  content(
    (),
    [hello world],
    name: "hello",
  )
  line(
    "hello.south",
    (rel : (y: -2)),
  )
})

We are able to use compass border anchors (“north”, “north-east”, etc), but we cannot anchor by passing an angles (e.g. "hello.30deg"):

error: assertion failed: Element 'hello' does not support border anchors.

This would be a very helpful feature for more complex Cetz figures.

johannes-wolf commented 1 month ago

Yes, this should be implemented. Since anchors of content do not get transformed by the current transformation, this is a bit more complicated, though.

johannes-wolf commented 1 month ago

What makes things really complicated is that content stays untransformed. Maybe we should propagate adding something like transform(<matrix>) into Typst, allowing to set any transformation matrix for native Typst elements. This would then allow transforming content correctly with cetz current transformation. @fenjalien?