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

Allow using different fill methods for Rasterizer (odd, positive/negative) #56

Open
LoganDark opened this issue Jan 11, 2022 · 3 comments

Comments

@LoganDark
Copy link

Right now the rasterizer uses a nonzero filling method, which is convenient for many cases. It would be nice if it also provided an odd filling method, as well as positive/negative

@alexheretic
Copy link
Owner

The rasterizer returns [0.0, 1.0] f32 coverage to represent how much a glyph covers any given square in a grid.

Can you explain what odd, positive/negative means in this context?

@LoganDark
Copy link
Author

Can you explain what odd, positive/negative means in this context?

Winding count. AFAICT, counter-clockwise winding order causes the area inside the shape to increase by one in winding count, and then creating another shape inside with clockwise winding order decreases the winding count again. Pixel coverage is calculated by what percentage of the pixel has the winding count you want (in this case, nonzero - winding counts 1,2,3.. and -1,-2,-3... count as covering the pixel).

image

(I might have my clockwises backward - but this is what I observe with font rendering)

Sometimes it's useful to use odd instead, which is what SVG rendering uses. Sometimes you want only positive or only negative.

@LoganDark
Copy link
Author

LoganDark commented Jun 11, 2022

Come to think of it, I haven't actually checked if c can be outside the 0.0-1.0 range. If it can go above and below by layering additional shapes then I would consider this issue closed. Then I can implement any fill mode I want, including CSG

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants