Sierpinski triangle is a fractal and attractive fixed set with the overall shape of an equilateral triangle. It subdivides recursively into smaller triangles.
- In the given segment of codes, a triangle is made and then draws out three other adjacent small triangles till the terminating condition which checks out whether the height of the triangle is less than 5 pixels returns true.
- We only need to verify whether a given triangle is smaller than 5 pixels since beyond that the triangles would start converging at fixed points.
- A counter colorVal is defined for in response to the aesthetic need of the triangle and in all, it cycles through all the available colours by iterating every triangle set.
- Using this methodology we can also further implement a fractal zoom and hypothetically provide an infinite zoom later.
Below is the implementation of the above approach:
- Sierpinski triangle
- Program to print a Hollow Triangle inside a Triangle
- Reflection In 2D Graphics
- bar() function in C graphics
- Mandlebrot Set in C/C++ Using Graphics
- How to include graphics.h in CodeBlocks?
- Draw Rectangle in C graphics
- Draw ellipse in C graphics
- Draw circle in C graphics
- bar3d() function in C graphics
- Segments in Computer Graphics
- Draw a line in C++ graphics
- How to create a Heart using C Graphics
- What is AGP(Accelerated Graphics Port)?
- Applications of Computer Graphics
- Introduction to Computer Graphics
- Computer Graphics | Antialiasing
- Vector vs Raster Graphics
- Computer Graphics | The RGB color model
- Translation of objects in computer graphics
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.