Graphical representation of the Sierpiński triangle based on Pascal's triangle and modulo operations on the binomial coefficients. Implemented in Processing, a visualization and animation language and framework based on Java.
If you have any questions regarding this project or ideas on improving it, feel free to contact me.
The Sierpiński triangle is a fractal attractive fixed set with the overall shape of an equilateral triangle, subdivided recursively into smaller equilateral triangles. Originally constructed as a curve, this is one of the basic examples of self-similar sets—that is, it is a mathematically generated pattern that is reproducible at any magnification or reduction. It is named after the Polish mathematician Wacław Sierpiński, but appeared as a decorative pattern many centuries before the work of Sierpiński. [Wikipedia]
The Sierpiński triangle can be generated through many different methods, this application uses the coloring of remainders when dividing binomial coefficients placed in a triangle shape (Pascal's triangle).
Pascal's triangle is generated by starting with "1" for row 0, for each subsequent row a "1" is added to each side. Starting at row 2, the values between those outmost "1" are calculated by adding the two numbers directly above in the previous row. It then looks something like:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
...
Each value of the triagle is placed inside a box which then is colored according to the remainder of the modulo operation with the specified divisor. The controls are displayed within the application.
Further details are explained in the code's comments.
- Install the Extension 'Processing for Visual Studio Code' by Tobiah Zarlez
- In the .pde file, press
cmd-shift-p
and runProcessing: Create Task File
- After creating the task file in your workspace, run
Processing: Run Processing Project
via the same window - A new window running the application should open
- For Windows, get the latest release here, unpack it and run pascal.exe.
- For Linux, get the latest release here, unpack it and run pascal (or open it in a terminal and run
chmod +x pascal
and./pascal
). If you haven't installed Java yet, install the correct JRE and JDK for your system through your package manager.
- Borders and numbers displayed, color scheme 2, mod 6
- Borders and numbers not displayed, color scheme 1, mod 3
The keyboard and mouse icons are taken from Xelu's icon pack. [Source]