golang / freetype

The Freetype font rasterizer in the Go programming language.
Other
778 stars 183 forks source link

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

Closed tonykwok closed 6 years ago

tonykwok commented 6 years ago

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);
}
tonykwok commented 6 years ago

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