The Hex Clock takes the current time (example: 2:15:09), turns those numbers into a hexadecimal value (#021509), and uses that value to change the background color of the page.
The background and time only updated after a refresh though. It took a lot of Googling before I figured out how to make the function repeat on its own, indefinitely.
Then, I decided that I wanted to try creating an RGB clock too. I’ve never seen someone else build one, so I have nothing to compare to that will say that my code is “right” or “wrong.” But, visually, it works like I imagined it would.
The biggest challenge here was figuring out where I would get my RGB values from. I knew that I wanted R to be hours, G to be minutes, and B to be seconds. After some playing around with the variables, I decided that since 24 * 10 was close enough to 255, I could multiply the current h value by 10 to get the R value. For G and B, I multiplied the m and s values by 4.25 (60 * 4.25 = 255). And, voila. Lots more color changing in the background.
The only gripe I have with what I produced is that, aside from the hours, you can’t really tell how the RGB values relate just by looking at the final product. Still, I’m pretty pleased with myself.
Now, if only I could think of more ways to test my skills…