Recursive - Fractal Generator

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
Nuthen224
Citizen
Posts: 50
Joined: Sun Jul 28, 2013 9:40 pm

Recursive - Fractal Generator

Post by Nuthen224 »

This generates fractals based on the Koch snowflake. The process to create this is to start with a triangle, and then for each line segment add a triangle onto it of the size of 1/3 of the line. This forms new lines, and the same process is done multiple times to form a fractal.

Here's an example of the Koch snowflake made in this program:
Image

There are several variables to change in this program to generate many different fractals:
  • (mousewheel) Angle: The angle of the shape that extends off of each line
    (q/a) angle1: a multiplier for the left angle when you have extra line toggled on
    (w/s) angle2: a multiplier for the right angle when you have extra line toggled on
    (e/d) (r/f) remove %: a fraction how much of each line is removed, essentially the size of each shape added on. One set of controls is to change the numerator, the other is to change the denominator (exact fractions are important here)
    (y/h) radius: size of the original shape
    (g) clean lines: removes extra lines with each iteration
    (t) extra line: with this off, a triangle is added to each line. With this on, a quadrilateral is added to each line. Angle1 and angle2 are only relevant when this is on
Other controls:
  • (backspace) reset
    (f1) fullscreen
    (f2) reset values to default
    (f3) hide help text
    (f4) hide preview
    (space) iterate - go to the next step
    (3-9) press a number to set the number of sides
There are a lot of different settings, and even one variable can greatly influence the overall result of the fractal. There's a preview to show what will happen to each line after every step. You can also change each setting between each step (at which point it's no longer a fractal, but you can still make cool shapes).

Note: It's limited to 5 iterations because I found that after that it tends to lose any noticeable detail, and going past 5 generally results in long freezes or crashes. Also, it requires use of a canvas to improve performance.

Here are some other examples of fractals you can make:
Image

Image

Image


This was made over the course of the last 48 hours. I have been using LÖVE for a few years, and I found this something fun to play around with. I hope you might find it cool.
Attachments
recursive.love
(393.29 KiB) Downloaded 157 times
Last edited by Nuthen224 on Thu Feb 05, 2015 3:00 am, edited 1 time in total.
User avatar
undef
Party member
Posts: 438
Joined: Mon Jun 10, 2013 3:09 pm
Location: Berlin
Contact:

Re: Recursive - Fractal Generator

Post by undef »

Very, very nice.
Hadn't played around with Koch snowflakes yet, thanks!
twitter | steam | indieDB

Check out quadrant on Steam!
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests