Skip to content

MathiDEV/fractals

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fractals

"Fractals" is like string replace in 2D.

Initialisation

A fractal is composed of "#" and ".". We have a replacement pattern for each symbol. Here we chose to replace each "#" by :

##
#.

And each "." by :

..
..

Iterations

We begin with a simple "#" :

#

(that's our iteration 0)

For each iteration, we replace the characters by the corresponding pattern, so our first iteration will be :

##
#.

(Because we replaced the single "#" by it's pattern)

Our second iteration will be :

              ##  ##                 ####
##            #.  #.                 #.#.
#.     ->                 ->         ##..
              ##  ..                 #...
              #.  ..

With more iterations we can obtain something like this :

################
#.#.#.#.#.#.#.#.
##..##..##..##..
#...#...#...#...
####....####....
#.#.....#.#.....
##......##......
#.......#.......
########........
#.#.#.#.........
##..##..........
#...#...........
####............
#.#.............
##..............
#...............

How to use ?

  • Compile via makefile
make
  • Run program
./fractals <n iter> <pattern for "#"> <pattern for ".">

You must use "@" as linebreak in the patterns.

You can use rectangle patterns.

But all lines must have the same length and the two patterns must have the same dimensions.

Releases

No releases published

Packages

No packages published