Coder Social home page Coder Social logo

foobar167 / fractals Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 1.0 7.33 MB

Experiments with fractals are placed here

License: MIT License

CSS 1.40% HTML 22.72% JavaScript 75.88%
fractals chaos-game drawing-fractals sierpinski-gasket lindenmayer-systems mandelbrot barnsley-fern

fractals's Introduction

Fractals drawing

I've used the book of Ben Trube "Fractals: A Programmer's Approach". However, all software was rewritten from C++ to Javascript to make it available online, without sophisticated compilation and additional libraries.

Tested mostly on Firefox browser, but it should work on any browser with Javascript support. No additional libraries required.

1.1 Chaos game is a "fractal player" on Javascript.

Run HTML file and control fractal drawing with your keyboard. Pause, resume, forward and backward random fractal drawing with {Space}, →, ←, ↑, ↓ keys. Turn on/off color mode with {1} and {2} keys. Black-and-white drawing is faster.

Chaos game

The same as previous chaos game, but rotation is added to the drawing procedure.

Chaos game with rotation

Random Sierpinski Gasket is a Sierpinski Gasket with random triangles. It is different every time you press {F5} key and reload page.

Random Sierpinski Gasket

Sierpinski Gasket, Hexagon and Carpet with 3, 6 and 8 vertices respectively. You can change their size dynamically by resizing your browser's window. After resizing the image is smoothly redrawn.

Sierpinski Gasket

2.2 Ferns

There are three types of fractal ferns presented: Barnsley Fern (the most beautiful), Simple Fern and Spirals. You can change their size dynamically by resizing your browser's window. After resizing the image is smoothly redrawn.

Barnsley Fern:

Barnsley Fern

Simple Fern:

Simple Fern

Spirals:

Spirals

Draw the fractal recursively with depth of 12.

Recursion Figure

Implementation of the "Turtle Library". Imagine that you're turtle crawling on a plane. There are only 2 actions: move forward or turn left-right on some angle. It is possible to create huge number of unique and beautiful fractals using only two actions. And encode these actions in some "words" (see further implementations of Lindenmayer systems).

You can resize some of these drawings by changing browser's window.

Dragon, Tree and Zig-zag:

Dragon, Tree and Zig-zag

Cycles, Helix and Spiral:

Cycles, Helix and Spiral

Sierpinski Gasket, Koch Snowflake and Cycle:

Sierpinski Gasket, Koch Snowflake and Cycle

Lindenmayer Systems or L-systems were first outlined by Aristid Lindenmayer as a method for modeling the growth of algae and fungi. Through the work of fractal pioneers like Michael Barnsley and others, L-Systems have been created for fractals like the Harter-Heighway dragon, the Hilbert curve, and several methods for the Sierpinski Gasket.

L-System is a grammar for drawing fractals. L-Systems grow by parsing a string character by character to build a new string. Each character is either added directly to the new string, or replaced by a sequence of characters outlined by our replacement rules. Initial string is called the Axiom and is often used to define the initial shape of the fractal.

H-figure, Bent H-figure, Spiky Square and Square Islands:

H-figure, Bent H-figure, Spiky Square and Square Islands

Penrose Tilings, Arrowhead Gasket, Koch Square figure and L-system with recursion:

Penrose Tilings, Arrowhead Gasket, Koch Square figure and L-system with recursion

The Mandelbrot set is the set of complex numbers c for which the function f(z) = z^2 + c does not diverge when iterated from z = 0, i.e., for which the sequence f(0), f(f(0)), f(f(f(0))), etc., remains bounded in absolute value.

The set is connected to a Julia set, and related Julia sets produce similarly complex fractal shapes.

Mandelbrot 01

Mandelbrot 02

Mandelbrot 03

Mandelbrot 04

Mandelbrot 05

Julia set is a set of complex numbers which do not converge to any limit when a given mapping is repeatedly applied to them. In some cases the result is a connected fractal set. It was named after Gaston M. Julia (1893–1978), Algerian-born French mathematician.

Julia set 01

Julia set 02

Julia set 03

Julia set 04

Julia set 05

Julia set 06

fractals's People

Contributors

foobar167 avatar paulenka167 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

leimazizizi

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.