ab-glyph icon indicating copy to clipboard operation
ab-glyph copied to clipboard

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

Open LoganDark opened this issue 2 years ago • 3 comments

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

LoganDark avatar Jan 11 '22 21:01 LoganDark

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?

alexheretic avatar Jan 12 '22 18:01 alexheretic

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 avatar Jan 12 '22 18:01 LoganDark

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

LoganDark avatar Jun 11 '22 23:06 LoganDark