The mathematician Michael Barnsley created a theorem called the Collage Theorem that provides the mathematics for playing the 'Chaos Game' (the common source for the Sierpinski Triangle) that will compute ANY image!
Perhaps you've seen the ferns (a soon to be uploaded Scratch project) and other images produced by the Collage Theorem (called Iterated Functions Systems by Barnsley).
Geometrically, the Collage Theorem is the mathematics for creating an affine geometric transformation which is a combination of translations, rotations, and scalings (taught in secondary mathematics). Every image has a unique set of values for the coefficients a, b, c, d, e, and f of the transformation equations. Plug those values into an algorithm like the one in this project and compute the image!
Here is a very short video of the Scratch project.
The Chaos Game is usually presented as a random application of the midpoint theorem, a typical Algebra I topic. In the future I will upload the midpoint formula project as used in playing the Chaos Game. It computes the same image computed in this project.
Click on this link to go to the Scratch web site and download the project.
I have also written a PDF document that contains biographical information about Dr. Barnsley and works through the mathematics used in the project. Send an email to
to request a free copy.