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

Zero-width stroke acts as fill #662

Open
dominikh opened this issue Aug 9, 2024 · 4 comments
Open

Zero-width stroke acts as fill #662

dominikh opened this issue Aug 9, 2024 · 4 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@dominikh
Copy link

dominikh commented Aug 9, 2024

This

let stroke = Stroke::new(0.0);
let rect = RoundedRect::new(10.0, 10.0, 240.0, 240.0, 20.0);
let rect_stroke_color = Color::rgb(0.9804, 0.702, 0.5294);
self.scene.stroke(&stroke, Affine::IDENTITY, rect_stroke_color, None, &rect);

renders as
image

@waywardmonkeys waywardmonkeys added this to the Vello 0.3 release milestone Aug 12, 2024
@DJMcNab DJMcNab added the bug Something isn't working label Aug 12, 2024
@DJMcNab
Copy link
Member

DJMcNab commented Aug 12, 2024

Thanks for the report! I suspect what's happening here is that the expanded lines overlap, and that confuses something.

But I think @raphlinus will be more likely to give an easy answer.

For the moment, I'd recommend capping your strokes to be at least 0.01 units, presuming that the issue occurs only exactly at 0.

@dfrg
Copy link
Collaborator

dfrg commented Aug 12, 2024

I think the easy fix is to just detect this in Scene::stroke and encode nothing. We’d need to do the same for glyph runs.

@raphlinus
Copy link
Contributor

Yeah, internally we use a special value of 0.0 of the stroke width to indicate fill. I agree with @dfrg that the easiest thing is to encode nothing. Alternatively, we could switch to using a value of -1.0 (which I believe we did in the past), and have the predicate in the shaders that that the value is negative.

@TheNachoBIT
Copy link
Contributor

I've made tests and i found out that every Style (source code just in case) that had a line_width of 0.0 gets automatically rendered as a fill no matter what flags in flags_and_miter_limit has.

Maybe this is a dumb/not a good idea, but perhaps there could've be a flag for Style that explicitly sets if its a fill or a stroke?

@waywardmonkeys waywardmonkeys added the help wanted Extra attention is needed label Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

6 participants