# Why did you make this?

For my math class, (131: Mathematical Thinking), we had the assignment to create a math related project, and I decided to see if I could
create a golden spiral using PHP (a web-based programming language). I always enjoyed transferring things I learned in math or computer science
into programming, so I figured this would be a fun way to do my project.

This is my first time (heavily) working with images in PHP, so it was a bit harder than I thought it would be, but it turned out perfect.
After doing some manual trial-and-error programming to get the basic drawing done, I moved on to writing up a function that would be able to calculate
points for each square no matter how large the original golden rectangle had been (it's dynamic). After that I had to learn how to position the squares
into a spiraling pattern where they get smaller and smaller as they create more and more golden rectangles (the formula is 1/phi^x, where x gets larger
as the rectangles get smaller). I accomplished this by dividing the squares into certain criteria by where the quarter-circle arc's inside them would start
to be drawn (it turned out to be in intervals of 90 degrees). The final result can be seen below, as well as the source code that creates the image itself.

# What is the golden spiral?

A golden spiral is a logarithmic spiral created using golden rectangles (a golden rectangle is a rectangle whose sides are in the ratio 1:phi). This spiral is very numerous in nature (shell of a chambered nautilus, spiraling bracts of a pine cone, etc). The golden ratio phi is defined such that partitioning the original rectangle into a square and new rectangle results in the new rectangle having sides with a ratio 1:phi.

# What does the golden spiral look like?

# More information on how this image was generated:

This image was generated using the GD Library in PHP. The principal lies in using golden rectangles (rectangles whose sides are in the ratio of 1:phi) to position arc's in a spiraling pattern. By removing a square from the original golden rectangle, you are left with another golden rectangle. A square is removed from this rectangle and another golden rectangle is formed and so on. If we place quarter-circles tangent to the interior of each square, we form an approximate golden spiral.

# Customizing the image:

You may change the width of the golden rectangle by adding the 'w' argument.

example: **img.php?w=400** (the default is 200).

You may change the color of the image by adding 'r', 'g', and 'b' arguments.

example: **img.php?r=255&g=50&b=0** (default is black).

All of these arguments may be used together at one time.

example: **img.php?w=400&r=255&g=50&b=0**.