Пример #1
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.NewAlpha(image.Rect(0, 0, 300, 300))
		raster.DrawPolyline(img, curve[:]...)
		raster.DrawPolyline(img, p.points...)
		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()
}
Пример #2
0
func TestCubicCurveAdaptive(t *testing.T) {
	for i, curve := range testsCubicFloat64 {
		var p Path
		p.LineTo(curve[0], curve[1])
		curve.AdaptiveSegment(&p, 1, 0, 0)
		img := image.NewAlpha(image.Rect(0, 0, 300, 300))
		raster.DrawPolyline(img, curve[:]...)
		raster.DrawPolyline(img, p.points...)
		drawPoints(img, color.NRGBA{0, 0, 0, 0xff}, p.points...)
		savepng(fmt.Sprintf("_testAdaptive%d.png", i), img)
		log.Printf("Num of points: %d\n", len(p.points))
	}
	fmt.Println()
}