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
848 stars 35 forks source link

Wrong marks in merged paths #511

Open Wallbreaker5th opened 7 months ago

Wallbreaker5th commented 7 months ago
#import "@preview/cetz:0.2.0"

#cetz.canvas({
  import cetz.draw: *
  merge-path({
    line((0,1), (1,1), mark: (symbol: ">"))
  })
  line((0,0), (1,0), mark: (symbol: ">"))
})

b

johannes-wolf commented 7 months ago

This is a known problem, for now you must not use marks inside merge-path.

jason-s commented 4 months ago

Is there another way to draw a polyline with an arrowhead?

johannes-wolf commented 4 months ago

It is possible with the current version by implementing the mark placement in a custom element. I will post an example later. But you can take a look into cetz source code how it is done: src/draw/shapes.typ has calls to drawables = mark_.place-marks-along-path(ctx, style.mark, transform, drawables). You need to do add that to your custom merge-path like element.

johannes-wolf commented 4 months ago

If you mean multiple connected straight lines by polyline: this is possible. You can pass > 2 coordinates to line.

fenjalien commented 2 months ago

This would be fixed by #463