golang/freetype

[QUESTION] Can Rasterizer be used to rasterize a horizontal line into spans?

tonykwok opened this issue · 1 comments

I used the following code to rasterize a horizontal Line, but the output is empty! Is this my mistake or there's a bug in Rasterizer?

type painter struct {

}

func (p *painter) Paint(spans []raster.Span, done bool) {
	for _, span := range spans {
		fmt.Printf("span %d, %d, %d\n", span.Y, span.X0, span.X1)
	}
}

func main() {
	raster := raster.NewRasterizer(256, 256)
	raster.UseNonZeroWinding = true
	raster.Start(fixed.Point26_6{fixed.Int26_6(10 * 64), fixed.Int26_6(10 * 64)})
	raster.Add1( fixed.Point26_6{fixed.Int26_6(50 * 64), fixed.Int26_6(10 * 64)})
	var ptr painter
	raster.Rasterize(&ptr);
}

I finally know that even for a horizontal line, it should be defined with 4 points, since the Rasterizer only supports polygon rasterization.