How to Draw a Custom Mark at Specific Points on the CetZ Canvas?

Hi everyone!

I’m trying to draw individual marks, such as a circle, at specific points on a canvas. However, I’ve run into a challenge: it seems there’s no direct way to place a mark exactly where I want.

Initially, I tried drawing an invisible line with a mark at the endpoint, but the mark doesn’t align precisely with the line’s endpoint coordinates. As a temporary solution, I used a Unicode character for the mark, as shown below:

content(X, anchor:"center", text(size:size, fill:color)[⬤])

This works, but it doesn’t scale properly when I change the canvas scale.

Is there a better way to achieve this? Any advice would be greatly appreciated!

Thanks in advance!

Using marks anchor style-attribute (possible values are: center, tip, base), you should be able to control the positioning:

#canvas({
  import draw: *

  grid((-1,-1), (1,1), stroke: .25pt + gray)

  //            ,---- Direction to point at
  mark((0, 0), (1,0), symbol: "o", anchor: "center")
  //   ^--- Position of the mark
})

Gives:
grafik

1 Like