Esempio n. 1
0
// ChaosGame steps SKIP+n times, plotting the last n points.
func (o IFS) ChaosGame(targ *canvas.Canvas, n int, c canvas.Color) {
	x, y := 0.5, 0.5
	for i := 0; i < SKIP; i++ {
		x, y = o.Choose().Apply(x, y)
	}
	for i := 0; i < n; i++ {
		x, y = o.Choose().Apply(x, y)
		targ.FSet(x, y, c)
	}
}
Esempio n. 2
0
// WholeGame
func (o IFS) WholeGame(src *canvas.Canvas, n int) *canvas.Canvas {
	t1 := src.Dup()
	t2 := canvas.NewCanvas(src.Width, src.Height)
	for i := 0; i < n; i++ {
		canvas.Say("WholeStep", i)
		o.WholeStep(t1, t2)
		t1, t2 = t2, t1
		t2.Fill(0, 0, t2.Width, t2.Height, canvas.Black)
	}
	return t1
}
Esempio n. 3
0
// MapImageTo maps one picture through an IFS onto another.
func (o Affine) MapImageTo(src *canvas.Canvas, dest *canvas.Canvas, k int, done chan int) {
	for i := 0; i < src.Width; i++ {
		x := float64(i) / src.FWidth
		for j := 0; j < src.Height; j++ {
			r, g, b := src.Get(i, j)
			if r > 0 || g > 0 || b > 0 {
				y := float64(j) / src.FHeight
				x2, y2 := o.Apply(x, y)
				dest.FSet(x2, y2, canvas.RGB(r, g, b))
			}
		}
	}
	done <- k
}