Kasmir
October 11, 2025, 12:55pm
1
I have the following code from here :
#import "@preview/cetz:0.4.2"
#cetz.canvas({
import cetz.draw: *
grid((0,0), (3,2), help-lines: true)
circle((3,2), name: "a", radius: 2pt)
circle((1,1), name: "c", radius: (1,0.75))
content("c", $ c $, anchor: "north-east", padding: .1)
stroke(red)
line("a.center", (element: "c", point: "a", solution: 1),
"c", (element: "c", point: "a", solution: 2),
close: true)
})
But the "a.center"
didn’t exactly locate at (3,2)
.
Is this a bug, or I need other anchor?
This seems to be only related to the thickness of the stroke.
Try adding stroke(0.1pt)
at the beginning, you will see the measurement is taken from (3,2). I agree that visually it doesn’t look like it.
1 Like
The edge looks sharp because of the way the stroke corners are joined.
The center of the stroke lies exactly on that point, which causes the line to stick out and form a sharp, spiky edge.
You can make them smoother by changing the join property of the stroke.
Check the stroke documentation for details:
Example:
#import "@preview/cetz:0.4.2"
#cetz.canvas({
import cetz.draw: *
set-style(line: (stroke: (join: "round")))
grid((0,0), (3,2), help-lines: true)
circle((3,2), name: "a", radius: 2pt)
circle((1,1), name: "c", radius: (1,0.75))
content("c", $ c $, anchor: "north-east", padding: .1)
stroke(red)
line("a.center", (element: "c", point: "a", solution: 1),
"c", (element: "c", point: "a", solution: 2),
close: true)
})
This makes the edges smooth and rounded instead of pointy.
1 Like
Kasmir
October 11, 2025, 1:35pm
4
Thanks to remind me check the stroke
’s documentation, it works
1 Like