Prime Spiral II

My first attempt at making a prime spiral worked, but it worked with 90° angles. Trying to make it look smoother, I now used an angle and a distance, drawing circles at calculated position.
If the number is prime, it gets white. If it is not, the circle will be gray.

Prime spiral


# Python 2.7.7 Code
# Pygame 1.9.1 (for Python 2.7.7)
# Jonathan Frech 18th of July, 2015

Continue reading

Sierpinski Triangle

Having recently heard something about chaos theory, I was interested in the sierpinski triangle. Specifically in the random generation. To proof, if it can really be generated using a dice, I wrote this program.

How it works

  • You start with any point inside the triangle (I chose the center)
  • A triangle has three points, let us call them A, B and C
  • You choose randomly between one of those three points, go half the distance and set a pixel right there
  • Repeating this process over and over again (always starting at your last point), you eventually get the sierpinski triangle

Controls

  • Space toggles if the triangle is generated
  • m toggles if the current position is shown (indicated by a blue circle)

Starting with an empty triangle Slowly but surely... Finished sierpinski triangle


# Python 2.7.7 Code
# Pygame 1.9.1 (for Python 2.7.7)
# Jonathan Frech 15th of July, 2015

Continue reading

Primes

Being fascinated with how prime spirals look, I tried another layout for primes. Starting at the upper left and writing out numbers like a normal text, starting at 0 and coloring every prime number red, every other number white, this is the result.
Scale: 50 Scale: 10 Scale: 5
It is interesting, that – like in prime spirals – the red squares form visible patterns. Randomly assigned squares would not as often form such patterns.


# Python 2.7.7 Code
# Pygame 1.9.1 (for Python 2.7.7)
# Jonathan Frech 27th of June, 2015
#         edited 28th of June, 2015

Continue reading