Giter Site home page Giter Site logo

bojanv03 / sfml_fractals Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 1.0 13.36 MB

I was interested in learning some SFML and doing fractals seemed like an interesting idea

C++ 97.37% C 0.60% Makefile 2.02%
sfml fractals fractal-algorithms recursion tree-fractal mandelbrot-fractal koch-snowflake sierpinski-triangle sierpinski-carpet mandelbrot-renderer

sfml_fractals's Introduction

SFML_Fractals

I was bored and decided to play around with fractals in order to teach myself SFML. I was mainly interested in the algorithmic part of it so there is no fancy UI here. It sure was fun doing this project and I hope someone finds it entertaining/useful.

๐Ÿ’ป Setup

This version is mainly tested on Ubuntu.

Prerequisites

  1. Install g++

sudo apt-get update

sudo apt-get install g++

  1. Install SFML library

There are three ways to install SFML library:

  • Using package manager

$ sudo apt-get install libsfml-dev

  • Download the SDK

Download the SDK from the download page, unpack it and copy the files to your preferred location: either a separate path in your personal folder (like /home/me/sfml), or a standard path (like /usr/local).

  • Building SFML yourself

If you want to go this way, there's a dedicated tutorial on building SFML yourself.

๐Ÿ”ง Setup and run

  1. Download (clone) this repository
  2. In main.cpp, define the desired fractal preset you want to see
  3. Type 'make' in your terminal (without quotes)
  4. Type './exec.out' in your terminal (again, without quotes)
  5. Enjoy the fractals

Here's some screenshots:

Mandelbrot fractal:

Check out the renderer in action:

https://www.youtube.com/edit?o=U&video_id=95CqTifr_NE

Mandelbrot Fractal Render

Sierpinski Triangle:

You can render the Sierpinski Triangle with as many iterations as you want(or as many as your processor can handle) and set an arbitrary bounding box to position and set the scale of the triangle. It also has a color member variable which you can use to change the color of it but I preffer this gradient so i'll keep it this way. Sierpinski Triangle Animation

Sierpinski Carpet:

You can render the Sierpinski Carpet with as many iterations as you want(or as many as your processor can handle) and set an arbitrary bounding box to position and set the scale of the carpet. It also has a color member variable which you can use to change the color of it but I preffer this gradient so i'll keep it this way.

Additionally you can set the carpet matrix(instead of the usual 3x3) to arbitrary width/height and pass it an array of indexes you don't want to render recursively.

standard 3x3 carpet excluding the (1, 1) square where (0, 0) is the top left square: Sierpinski Carpet Animation

custom 5x5 carpet excluding the (1, 1), (1, 2), (1, 3), (2, 1), (2, 3), (3, 1), (3, 2), (3, 3) squares. Sierpinski Carpet 5x5

custom 5x5 carpet excluding the top left and bottom right edge squares, looks kinda like a snowflake, doesn't it? Sierpinski Carpet Snowflake

custom 3x3 carpet excluding the top left and bottom right squares: Sierpinski Carpet Tank

Tree Fractal:

You can render the standard Tree Fractal with as many iterations as you want(or as many as your processor can handle), set the initial seed location, adjust the width/height of a branch, change the scaling factor and color and have seperate angles for the left and right branch.

The following gif shows several iteration of a tree with starting color (70,190,63), scaling factor 0.88, left branch angle of 30 degrees, right branch angle of 13 degrees, Height/Width of 96/12 Tree Fractal Animation

Koch Snowflake:

You can render the Koch Snowflake with as many iterations as you want(or as many as your processor can handle) and set an arbitrary bounding box to position and set the scale of the flake. Adjusting the color and wether or not it grows outwards or inwards is also possible

Koch Snowflake Animation

sfml_fractals's People

Contributors

bojanv03 avatar fr1sk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

eemmanuel7

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.