Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

line is drawn with wrong offset for coordinates that are content with a non-center anchor #621

Open
kram-tm opened this issue Jun 2, 2024 · 0 comments
Labels
bug 🐛 Something isn't working

Comments

@kram-tm
Copy link

kram-tm commented Jun 2, 2024

When using draw.line to draw a line between the border of a content node and another element, the resulting line seems to be drawn with a proper angle, but unexpected offset relative to the content's border. The issue is visible in the following example:

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

#stack(
  dir: ltr,
  canvas({
    draw.content(name: "test1", frame: "rect", (0,0))[Test 1]
    draw.content(name: "test2", frame: "rect", (-1,-1))[Test 2]
    draw.line("test1", "test2")
  }),
  canvas({
    draw.content(name: "test1", (0,0))[Test 1]
    draw.content((-1,-1))[#box(stroke: 1pt + red, hide[Test 2])]
    draw.content(name: "test2", frame: "rect", anchor: "north-east", (-1,-1))[Test 2]
    draw.line("test1", "test2")
  }),
  canvas({
    draw.content(name: "test1", (0,0))[Test 1]
    draw.content((-1,-1))[#box(stroke: 1pt + red, hide[Test 2])]
    draw.content(name: "test2", frame: "rect", anchor: "south", (-1,-1))[Test 2]
    draw.line("test1", "test2")
  }),
)

image
As evident in the image, line considers both the actual content node and a variant of it with anchor: center, drawing the line towards the center of the former and stopping at the first intersection with the border of either of the nodes. The error is seemingly absent in other shapes (circle and rect, at least).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants