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
- Mandlebrot Set in C/C++ Using Graphics
- Reflection In 2D Graphics
- bar() function in C graphics
- Draw circle in C graphics
- How to include graphics.h in CodeBlocks?
- Draw ellipse in C graphics
- Applications of Computer Graphics
- Draw a line in C++ graphics
- Draw Rectangle in C graphics
- bar3d() function in C graphics
- Vector vs Raster Graphics
- Segments in Computer Graphics
- Computer Graphics | Antialiasing
- Introduction to Computer Graphics
- What is AGP(Accelerated Graphics Port)?
- Translation of objects in computer graphics
- Flood fill algorithm using C graphics
- Creating a Rainbow using Graphics Programming in C
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.