func TestRasterizerNonZeroWinding(t *testing.T) { img := image.NewRGBA(image.Rect(0, 0, 200, 200)) var p Path p.LineTo(10, 190) draw2dbase.TraceCubic(&p, []float64{10, 190, 10, 10, 190, 10, 190, 190}, 0.5) poly := Polygon(p.points) color := color.RGBA{0, 0, 0, 0xff} tr := [6]float64{1, 0, 0, 1, 0, 0} r := NewRasterizer8BitsSample(200, 200) //PolylineBresenham(img, image.Black, poly...) r.RenderNonZeroWinding(img, &color, &poly, tr) draw2dimg.SaveToPngFile("../output/raster/TestRasterizerNonZeroWinding.png", img) }
func test(t *testing.T, draw sample) { // Initialize the graphic context on an RGBA image dest := image.NewRGBA(image.Rect(0, 0, 297, 210.0)) gc := draw2dimg.NewGraphicContext(dest) // Draw Android logo output, err := draw(gc, "png") if err != nil { t.Errorf("Drawing %q failed: %v", output, err) return } // Save to png err = draw2dimg.SaveToPngFile(output, dest) if err != nil { t.Errorf("Saving %q failed: %v", output, err) } }
func TestFreetypeNonZeroWinding(t *testing.T) { var p Path p.LineTo(10, 190) draw2dbase.TraceCubic(&p, []float64{10, 190, 10, 10, 190, 10, 190, 190}, 0.5) poly := Polygon(p.points) color := color.RGBA{0, 0, 0, 0xff} img := image.NewRGBA(image.Rect(0, 0, 200, 200)) rasterizer := raster.NewRasterizer(200, 200) rasterizer.UseNonZeroWinding = true rasterizer.Start(raster.Point{ X: raster.Fix32(10 * 256), Y: raster.Fix32(190 * 256)}) for j := 0; j < len(poly); j = j + 2 { rasterizer.Add1(raster.Point{ X: raster.Fix32(poly[j] * 256), Y: raster.Fix32(poly[j+1] * 256)}) } painter := raster.NewRGBAPainter(img) painter.SetColor(color) rasterizer.Rasterize(painter) draw2dimg.SaveToPngFile("../output/raster/TestFreetypeNonZeroWinding.png", img) }