I've had the idea since around 8th grade, but have never had the means to fulfill the project because I didn't know anything about coding. I still haven't taken any CS classes, but I figured there would be no better time to learn some basics than at a hackathon!

What it does

It takes the hexadecimal form of pi, splits it up into units of six, and uses these hex values to generate a corresponding color. This color is displayed as a square, and the code iterates through to create a 35 by 35 grid of colors taken from pi.

How we built it

We took the hexadecimal form of pi, then cut it into substrings of 2 units in chunks of 3 substrings. The first substring corresponds to the red value of the hue, the second to green, and the third to blue. With nested for loops, we created a grid of squares, and filled each one with the corresponding color of that six digit "chunk" of pi. This creates a grid of colored squares on a black background.

Challenges we ran into

It was very difficult figuring out how to take the hexadecimal string and converting it to something that the program could actually recognize as a color. We tried to leave it in hexadecimal, but this proved to be a large challenge, so instead we used RGB, which produces the same color as hexadecimal, just uses slightly different notation. Also, trying to figure out how to go through the for loop so that the right part of pi was selected and the right color showed up in the square was another obstacle. For a while, the code showed colored squares, but the colors in each square were wrong. Eventually, though, everything was worked out, and the squares now show the correct colors.

Accomplishments that we're proud of

That it works! I'm proud that with having no CS background, I was able to spearhead this project and figure out how to solve all of the problems we ran in to.

What we learned

I learned what a string is, how to create substrings, how to convert strings to integers, and how to create graphics in Processing.

What's next for Visualization of Pi

I really want to print out the final product and hang it on my wall. Also, I suppose this method could be applied to other irrational numbers like e or phi.

Built With

Share this project: