goFractal

package module
v0.0.0-...-88a0c6b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2023 License: MIT Imports: 10 Imported by: 0

README

goFractal

Description

The goFractal library is a Go package for generating fractals. This library provides support for both PNG and GIF formats. You can specify the focus points and zoom level for more detailed fractals.

Installation

To install the package, run:

go get -u github.com/leorighi/goFractal

Usage

Import the Package

First, import the package in your Go file:

import "github.com/leorighi/goFractal"
Initialize Mandelbrot struct

Initialize a new Mandelbrot struct with your preferred dimensions:

m := &goFractal.Mandelbrot{
    Width:  800,
    Height: 800,
}
Generate PNG Image

To generate a PNG image:

err := m.GeneratePNG("mandelbrot.png", 0.0, 0.0)
if err != nil {
    return err
}

Mandelbrot Set in PNG

Generate GIF Animation

To generate a GIF animation:

err := m.GenerateGIF("output.gif", 30, -1.4017, 0.0, 0.20)
if err != nil {
    // Handle error
}

Mandelbrot Set Animated in GIF

Methods

GeneratePNG

Generates a PNG image file of the Mandelbrot fractal.

  • filename: The name of the output PNG file.
  • focusX: X-coordinate of the focus point.
  • focusY: Y-coordinate of the focus point.

Returns an error if the operation fails.

func (m *Mandelbrot) GeneratePNG(filename string, focusX float64, focusY float64) error
GenerateGIF

Generates a GIF image file with animated zoom of the Mandelbrot fractal.

  • filename: The name of the output GIF file.
  • frames: Number of frames in the animation.
  • focusX: X-coordinate of the focus point.
  • focusY: Y-coordinate of the focus point.
  • zoomSpeed: Zoom speed for animation.

Returns an error if the operation fails.

func (m *Mandelbrot) GenerateGIF(filename string, frames int, focusX float64, focusY float64, zoomSpeed float64) error

Contributing

Feel free to contribute to this project.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MandelbrotGenerator

func MandelbrotGenerator(z complex128) color.Color

Types

type Mandelbrot

type Mandelbrot struct {
	Width  int
	Height int
}

func (*Mandelbrot) GenerateGIF

func (m *Mandelbrot) GenerateGIF(filename string, frames int, focusX float64, focusY float64, zoomSpeed float64) error

func (*Mandelbrot) GeneratePNG

func (m *Mandelbrot) GeneratePNG(filename string, focusX float64, focusY float64) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL