GithubHelp home page GithubHelp logo

ladnik / pascal Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 1.0 200 KB

Graphical representation of the Sierpiński triangle based on Pascal's triangle and modulo operations on the binomial coefficients

Java 53.01% Processing 46.99%

pascal's Introduction

Pascal

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.

Mathematical background

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]

Implementation

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.

Execution

Executing .pde file in VSCode

  • Install the Extension 'Processing for Visual Studio Code' by Tobiah Zarlez
  • In the .pde file, press cmd-shift-p and run Processing: 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

Executing the exported executables

  • 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.

Examples

  1. Borders and numbers displayed, color scheme 2, mod 6

program screenshot 1

  1. Borders and numbers not displayed, color scheme 1, mod 3

program screenshot 2

Sources and further notes

The keyboard and mouse icons are taken from Xelu's icon pack. [Source]

pascal's People

Contributors

ladnik avatar jschoedl avatar

Stargazers

Jasper Stritzke avatar  avatar

Watchers

 avatar

Forkers

jschoedl

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.