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

canvas debug inverts fill area of merge-path #575

Open
raphCode opened this issue Apr 30, 2024 · 1 comment · May be fixed by #593
Open

canvas debug inverts fill area of merge-path #575

raphCode opened this issue Apr 30, 2024 · 1 comment · May be fixed by #593
Labels
bug 🐛 Something isn't working

Comments

@raphCode
Copy link

I noticed a very special edge case of using canvas(debug: true) together with fills in merge-path and some relative coordinates. I did not perform any further testing to minimize the repro code, so it is possible that the bug can be triggered in more general situations.

When activating the canvas debug plots in the following code, the fill areas of the triangle are inverted:

#import "@preview/cetz:0.2.2"

#cetz.canvas(debug: false, {  // toggle debug here
  import cetz.draw: *
  
  let end-pos = (0.1, 1)
  let (tri-w, tri-h) = (0.5em, 1em)
  merge-path(
    {
      rect((0,0), end-pos)
      line(
        end-pos,
        (rel: (y: -tri-h)),
        (rel: (tri-w, tri-h / 2)),
        close: true,
      )
    },
    stroke: none,
    fill: blue,
  )
})

Without debug, expected form:
image
With debug: true, unexpected fill area inversion:
image

Maybe I am also abusing the merge-path function here since the rect line draw order is not specified in the manual?
My goal was to avoid the fine white line between the rect and the triangle, which happens without merge-path in some PDF viewers.

@johannes-wolf
Copy link
Member

Note: Mark debug elements as such and exclude them from merge-path.

@johannes-wolf johannes-wolf linked a pull request May 17, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants