Itunes like progress/capcity bar
Back in December I was working on a project that needed to show progress bars. They progress bars had to show the progress of multiple items, and it was explained to me that they should resemble the percentage bars in iTunes that show how full your ipod / iphone is, like so;
Not a problem I thought to myself, all I needed was a few images and the ever useful PHP GD library . If you’ve never used the PHP GD library before, a brief overview: It’s a graphics library that allows you to create dynamic graphics. (Told you it was brief).
Of course the great thing about PHP is that it is open source, so anything you need todo has already practaclly been done. After googling I found this percentage bar code created by netlobo.com, as well as this progress/percentage bar WebAppers (theirs was in javascript but it gave me a starting point). Both of these were close to what I wanted to do, I just needed to tweak and combine them.
I should note, that since I did use code from both those websites (which are covered under the Creative Commons license and GNU General Public License) this code covers the same licensing.
The Process
My thought process for creating this was pretty straight forward from the get-go.
- Get percents of the items that will be on the bar
- Create a “bucket” image
- for each percent, fill part of the bucket with a color
- Output the whole bar.
And that’s pretty much the route I followed. It was pretty simple actually.
Sorry to say, this code has been removed for legal reasons
but, please check out the sources I used when developing my code (they are mentioned above)
