Beispiel #1
0
func main() {
	flag.Parse()

	m = mandelbrot.New(*width, *height, iterations(),
		mandelbrot.Colors(hex(*inside), hex(*outside))).Image()

	if err := ebiten.Run(update, *width, *height, *scale, "Plasma GUI"); err != nil {
		log.Fatal(err)
	}
}
Beispiel #2
0
func main() {
	flag.Parse()

	m := mandelbrot.New(*width, *height, *iterations,
		mandelbrot.Colors(hex(*inside), hex(*outside))).Image()

	if file, err := os.Create(*filename); err == nil {
		defer file.Close()

		if err := png.Encode(file, m); err == nil {
			open(*filename)
		}
	}
}
Beispiel #3
0
func update(screen *ebiten.Image) error {
	count++

	m = mandelbrot.New(*width, *height, iterations(),
		mandelbrot.Colors(hex(*inside), hex(*outside))).Image()

	mandelbrotImage, err := ebiten.NewImageFromImage(m, ebiten.FilterLinear)
	if err == nil {
		op := &ebiten.DrawImageOptions{}

		op.GeoM.Translate(-float64(*width)/2, -float64(*height)/2)
		op.GeoM.Rotate(float64(count%360) * 2 * math.Pi / 360)
		op.GeoM.Translate(float64(*width)/2, float64(*height)/2)

		if err := screen.DrawImage(mandelbrotImage, op); err != nil {
			return err
		}
	}

	return nil
}