Giter VIP home page Giter VIP logo

mandelbrot-julia's Introduction

Mandelbrot / Julia Set Fractal Generator

mandelbrot julia

A tool for generating Mandelbrot and Julia set fractal images.


Installation

  npm install @hiteshlala/mandelbrot-julia

Usage

The simplest case:

  const { createConfigs, Julia, Mandelbrot } = require( '@hiteshlala/mandelbrot-julia' );

  async function draw() {
    try {
      console.log( '\nGenerate Julia' )
      const jconf = createConfigs( './julia.jpg' );
      const julia = new Julia( jconf );
      await julia.create();

      console.log( '\nGenerate Mandelbrot')
      const mconf = createConfigs( './mandel.jpg' );
      const mandel = new Mandelbrot( mconf );
      await mandel.create();

      console.log( '\nDone' )

    }
    catch( e ) {
      console.log( e.message || e );
    }
  }

  draw();

This generates julia.jpg and mandel.jpg in the current working folder using default values.

Customize

Adjusting the view window:

  const mconf = createConfigs( './mandel.jpg' );

  mconf.minX = -2.1;
  mconf.maxX = 0.5;
  mconf.minY = -1;
  mconf.maxY = 1;

  const mandel = new Mandelbrot( mconf );
  await mandel.create();

Adjusting the image resolution:

  const mconf = createConfigs( './mandel.jpg' );

  mconf.width = 300;
  mconf.height = 200;

  const mandel = new Mandelbrot( mconf );
  await mandel.create();

Adjusting the number of iterations:

  const mconf = createConfigs( './mandel.jpg' );

  mconf.iterations = 300;

  const mandel = new Mandelbrot( mconf );
  await mandel.create();

Change the Z constant for Julia:

  const mconf = createConfigs( './mandel.jpg' );

  mconf.c = { r: 0.1, i: -0.5 };

  const mandel = new Mandelbrot( mconf );
  await mandel.create();

Create a different color pallete:

  const { generateColors, createConfigs, Mandelbrot } = require( '@hiteshlala/mandelbrot-julia' );

  // uses tinygradient package to create a continuous gradient of colors
  const colors = generateColors(
    // array of colors to traverse in gradient
    [ 
      { r: 64, g: 224, b: 208 },
      { r: 255, g: 140, b: 0 },
      { r: 255, g: 0, b: 128},
      { r: 0, g: 0, b: 0 }
    ], 
    // number of steps to have in gradient
    50   
  );

  const mconf = createConfigs( './mandel.jpg' );

  mconf.colors = colors;

  const mandel = new Mandelbrot( mconf );
  await mandel.create();

The Mandelbrot image at the top of the page was created using a default config adjusted to:

  mconf.minX = -2.1;
  mconf.maxX = 0.5;
  mconf.minY = -1;
  mconf.maxY = 1;
  mconf.width = 300;
  mconf.height = 200;

mandelbrot-julia's People

Contributors

hiteshlala avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.