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
923 stars 38 forks source link

Lines between contents do not work properly in 0.3 #753

Open TimotheAlbouy opened 5 days ago

TimotheAlbouy commented 5 days ago

In cetz 0.3, when we draw a line between two contents, the line starts from the center of the content instead of the edge of the content.

#import "@preview/cetz:0.3.1": canvas, draw

#canvas({
  import draw: *

  content((0, 0), [Content 1], name: "C1")
  content((4, 0), [Content 2], name: "C2")
  line("C1", "C2")
})

image

This is a regression as this worked properly in cetz 0.2.

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

#canvas({
  import draw: *

  content((0, 0), [Content 1], name: "C1")
  content((4, 0), [Content 2], name: "C2")
  line("C1", "C2")
})

image

johannes-wolf commented 5 days ago

Question is, if content should have a default frame "rect" that is invisible by default.

TimotheAlbouy commented 4 days ago

In cetz 0.2, content had an implicit "rect" frame? Then IMHO, cetz 0.3 should also have that.

The simplicity of having line("C1", "C2") work directly without having to specify an invisible frame was really convenient in 0.2. That's also the default behaviour in TikZ (even though this is not really comparable as there is no equivalent to content() in TikZ/LaTeX).

In practice, implementing that change would just require adding default values for the parameters of the draw.content() function: frame: "rect" and stroke: 0pt.