Python, Sierpinski Triangle, and more ...

Greetings to readers. This is my first article on Habré. In it, I would like to share my experiments with the algorithm for constructing fractals by placing points in certain coordinates.





I do not exclude that you may already understand the topic of fractals, and even worked with the algorithm, which I will talk about, and that there is a lot of information about this, although I did not find any experiments with it. So don't hit ...





Let's start with a story about the Sierpinski Triangle. This is a fractal, that is, as the erroneous wording says - a self-similar figure (whose parts are similar to the figure itself). You've probably seen the Sierpinski Triangle.





Sierpinski triangle
Sierpinski triangle

There is a way to create it, which we will repeat in the Python programming language. The algorithm itself looks like this:





  .
 ,        .
 :
	     ,    .
      
      







The turquoise square is the builder.
The turquoise square is the builder.

This picture is from a program that I wrote in Python in a couple of minutes. I used the pyxel library because I like it, it looks nice, but as it turns out later, it has insufficient resolution, which in our case will make it difficult to distinguish small elements of the fractal.









...









Fail
Fail

. , , ( ). - , .





...









The builder tends to the center, hesitating a little
,

, . , , , 3 . , . ( , , - ).





...









Squares?
?

, , 1.n, - 1.75 . - .





, 5 , , - 1.5 ?





Can you call it "Levin's Flower", in my honor, if no one has discovered this figure yet?
" ", , ?

, , pygame, , 240 , , , , , - .









Pygame library test
pygame

. - .





1.75, .









The pentagon flower works too
-





, , - , -.





...









.






, , , - - - . , "" - . .





- C++ C# ( Assembler?), , - , , - , , , , . , , ...









, . , /, .





.








All Articles