Exemplo n.º 1
0
func main() {
	buddha.Grid = geometry.Rect(-2.5, -2.5, 2.5, 2.5)
	set := buddha.New(1024, 1024)
	filePath := "buddha.png"
	err := imgutil.WriteFile(filePath, set)
	if err != nil {
		log.Fatalln(err)
	}
	fmt.Println("Created:", filePath)
}
Exemplo n.º 2
0
func main() {
	mset.Grid = geometry.Rect(-2.5, -2.5, 2.5, 2.5)
	set := mset.New(1024, 1024)
	set.White = true
	filePath := "simple.png"
	err := imgutil.WriteFile(filePath, set)
	if err != nil {
		log.Fatalln(err)
	}
	fmt.Println("Created:", filePath)
}
Exemplo n.º 3
0
//
// gen stores c and uses it as the first input to f.
func gen(c complex128) func() complex128 {
	x := c
	next := func() complex128 {
		// f(x) = x**2 + c
		x = x*x + c
		return x
	}
	return next
}

// Grid is the bounds of the coordinate system on which the Mandelbrot set
// will be displayed. The x and y values of grid doesn't represent pixels but
// rather positions on the coordinate system.
var Grid = geometry.Rect(-2, -1.2, 1, 1.2)

// definition of a few common colors.
var (
	red    = color.RGBA{255, 0, 0, 255}
	green  = color.RGBA{0, 128, 0, 255}
	blue   = color.RGBA{0, 0, 255, 255}
	yellow = color.RGBA{255, 255, 0, 255}
)

// Colors represent the slice of colors that are used to represent how many
// iterations it took to escape the circle.
//
// Thus pixels that escape on the first iteration are colored red, while pixels
// that escape on the second iteration are colored green.
var Colors = []color.Color{