Coder Social home page Coder Social logo

jeswin-8802 / the-fern-fractal Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 185 KB

A Fern Fractal Generator

Home Page: https://jeswin-8802.github.io/The-Fern-Fractal

License: GNU General Public License v3.0

CSS 4.86% HTML 13.35% JavaScript 81.79%
fractals

the-fern-fractal's Introduction

The-Fern-Fractal

Also called the Barnsley Fern, it is a fractal pattern generated by iterating over four sets of transformations chosen based on a specific probability factor.

How It Works

The formula for a single transformation looks like this:
7a6ccaaa702062c1c63c488c076d4e1d08f94302

There are 4 such transformations and each of the transformations are specifically tasked with creating a portion of the fern.

function a b c d e f p PART
ƒ1 0. 0. 0. 0.16 0. 0. 0.01 Stem
ƒ2 0.85 0.04 −0.04 0.85 0. 1.60 0.85 Successively smaller leaflets
ƒ3 0.20 −0.26 0.23 0.22 0. 1.60 0.07 Largest left-hand leaflet
ƒ4 −0.15 0.28 0.26 0.24 0. 0.44 0.07 Largest right-hand leaflet

Here p is the probability factor and it determines the probability of choosing that function from the list of 4 functions.


5bc8debe5073efbf8347bed92ab7c1b4fbd1bf67
5bc8debe5073efbf8347bed92ab7c1b4fbd1bf67
687f3f274b69c4e3597a470065d3669e137e7e36
40699077f271fd7f45d3e26c536b1d4b1a9c50dd



Each iteration chooses 1 of 4 functions based on it's probability factor (in the first iteration, (0, 0) is used as the initial input). The co-ordinates obtained are traced in the output and is used as input for the next iteration. More the number of iterations, the more defined the fern looks as the number of points plotted increases.

By slightly changing the function parameters, we can create different variations of fern.

image

References

the-fern-fractal's People

Contributors

jeswin-8801 avatar

Watchers

Jeswin Santosh 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.