Esempio n. 1
0
func TestPixelTasks(t *testing.T) {
	pi := pngimage.NewPngimage(16, 9, "image.png")
	d := mandel.NewData(1024, 800, -0.7435669, 0.1314023, 0.0022878)
	it := task.IterateTasks(d, pi)

	if len(it) != 16*9 {
		t.Errorf("len(%v) = %v, want %v", it, len(it), 16*9)
	}

}
func main() {
	pi := pngimage.NewPngimage(640, 480, "image.png")
	m := pi.Img
	b := m.Bounds()
	for y := b.Min.Y; y < b.Max.Y; y++ {
		for x := b.Min.X; x < b.Max.X; x++ {
			m.Set(x, y, getRandomColor())
		}
	}
	pi.Save()
}
func main() {
	var err error
	var c color.Color
	maxX := 3 * 360
	pi := pngimage.NewPngimage(maxX-1, 240, "hue.png")
	b := pi.Img.Bounds()
	for y := b.Min.Y; y < b.Max.Y; y++ {
		for x := b.Min.X; x < b.Max.X; x++ {
			if c, err = hue.Color(float64(x) / float64(maxX)); err != nil {
				panic(err)
			}
			pi.Img.Set(x, y, c)
		}
	}
	pi.Save()
}
Esempio n. 4
0
func main() {
	var c color.Color
	var err error
	pi := pngimage.NewPngimage(360-1, 240, "use-hue.png")
	b := pi.Img.Bounds()
	for y := b.Min.Y; y < b.Max.Y; y++ {
		for x := b.Min.X; x < b.Max.X; x++ {
			h := float64(x) / 60.0
			h = h - math.Floor(h)
			if c, err = hue.Color(h); err != nil {
				panic(err)
			}
			pi.Img.Set(x, y, c)
		}
	}
	pi.Save()
}
func main() {
	var maxIter = 10 * 360
	var d = mandel.NewData(640, 400, -0.7435669, 0.1314023, 0.0022878)

	for colScale := 30; colScale < 120; colScale += 30 {

		n := fmt.Sprintf("mandel-hue-%04d.png", colScale)
		fmt.Println("Render:", n)
		pi := pngimage.NewPngimage(d.MaxX, d.MaxY, n)
		it := task.IterateTasks(d, pi)

		for t := range it {
			iter := mandel.Iterate(t.CRe, t.CIm, maxIter)
			pi.Img.Set(t.X, d.MaxY-t.Y, getColor(iter, colScale))
		}
		pi.Save()
	}
}