Exemplo n.º 1
0
func TestCubicCurveAdaptiveRec(t *testing.T) {
	for i, curve := range testsCubicFloat64 {
		var p Path
		p.LineTo(curve[0], curve[1])
		curve.AdaptiveSegmentRec(&p, 1, 0, 0)
		img := image.NewNRGBA(image.Rect(0, 0, 300, 300))
		raster.PolylineBresenham(img, color.NRGBA{0xff, 0, 0, 0xff}, curve[:]...)
		raster.PolylineBresenham(img, image.Black, p.points...)
		//drawPoints(img, image.NRGBAColor{0, 0, 0, 0xff}, curve[:]...)
		drawPoints(img, color.NRGBA{0, 0, 0, 0xff}, p.points...)
		savepng(fmt.Sprintf("_testAdaptiveRec%d.png", i), img)
		log.Printf("Num of points: %d\n", len(p.points))
	}
	fmt.Println()
}
Exemplo n.º 2
0
func TestQuadCurve(t *testing.T) {
	for i, curve := range testsQuadFloat64 {
		var p Path
		p.LineTo(curve[0], curve[1])
		curve.Segment(&p, flattening_threshold)
		img := image.NewNRGBA(image.Rect(0, 0, 300, 300))
		raster.PolylineBresenham(img, color.NRGBA{0xff, 0, 0, 0xff}, curve[:]...)
		raster.PolylineBresenham(img, image.Black, p.points...)
		//drawPoints(img, image.NRGBAColor{0, 0, 0, 0xff}, curve[:]...)
		drawPoints(img, color.NRGBA{0, 0, 0, 0xff}, p.points...)
		savepng(fmt.Sprintf("_testQuad%d.png", i), img)
		log.Printf("Num of points: %d\n", len(p.points))
	}
	fmt.Println()
}
Exemplo n.º 3
0
func TestQuadCurve(t *testing.T) {
	for i := 0; i < len(testsQuadFloat64); i += 6 {
		var p SegmentedPath
		p.MoveTo(testsQuadFloat64[i], testsQuadFloat64[i+1])
		TraceQuad(&p, testsQuadFloat64[i:], flatteningThreshold)
		img := image.NewNRGBA(image.Rect(0, 0, 300, 300))
		raster.PolylineBresenham(img, color.NRGBA{0xff, 0, 0, 0xff}, testsQuadFloat64[i:i+6]...)
		raster.PolylineBresenham(img, image.Black, p.Points...)
		//drawPoints(img, image.NRGBAColor{0, 0, 0, 0xff}, curve[:]...)
		drawPoints(img, color.NRGBA{0, 0, 0, 0xff}, p.Points...)
		SaveToPngFile(fmt.Sprintf("../output/curve/_testQuad%d.png", i), img)
		log.Printf("Num of points: %d\n", len(p.Points))
	}
	fmt.Println()
}