Pi Art Using Pi-thon

by QuantumXenon in Circuits > Software

4003 Views, 25 Favorites, 0 Comments

Pi Art Using Pi-thon

Pi Art.png
Untitled-1.png

For Pi Day, I have written a Pi-thon program that will create Pi-xel art using the digits of pi. This is done using the integrated "Turtle Graphics" module.

I have included the final program at the end for anyone who would like to try it out for themselves.

If anyone runs into any issues with the program, please let me know in the comments and I will try to help you if necessary. I have tried to make it as easy to use as possible.

(P.S. Sorry in advance for all the pi puns)

Convert Digits Into Colours

Part1.png

In the first section of the program, digits of pi will be converted to RGB colour values.

Here, digits of pi are automatically calculated using the 'BBP' algorithm, then each number is assigned RGB values for a chosen colour. The code then reads through the calculated digits of pi and the colour data for each digit is then stored in a list for use in the next step.

Present Colours in a Grid

Part 2.png

In the second section of the program, colour data will be converted into a piece of art.

Here, the colour data that was previously stored is now used by the Turtle Graphics module to create coloured squares in a grid shape.

Producing the Pi-ece of Art

Pi-xel Art.png
Pi Art
Untitled-2.png

Attached is the complete program. (Note: It is in a .txt file, so it will need to be copied into python to work because the python file does not download correctly).

At the top, there are four variables that you can change to make your own art:

  • 'GridWidth' and 'GridHeight' adjust the size and shape of the grid, which the program should automatically centre for you. It will also automatically generate as many digits of pi as necessary for the specified grid size.
  • 'Sides' changes the number of sides the 'pi-xels' have, which the program will automatically calculate the necessary angles.
  • 'PixelSize' changes the length of the sides of the 'pi-xels'. This is measured in pixels.

You can also change the RGB colour value that is related to each of the numbers.

I have also included a time-lapse of a 100x100 'pi-xel' grid that took one hour to complete, as well as a few examples to show what the program is capable of.

I have used comments throughout the program to explain what is happening in each section.

Please remember to 'Vote' for me if you like what I have done!

:)

Downloads