header text

a blog of things that I (eventually) make work

Friday, 29 January 2016

Code development - Now with icons!

After surprisingly little work, I've arrived at a version of the smart mirror Processing sketch that includes a limited amount of error checking and also displays icons to represent the weather.

The icons were sourced from an awesome pack called Climacons by Adam Whitcroft (thanks!).


Integrating them into the sketch was surprisingly simple; The Yahoo weather API includes a numeric parameter that indicates the current weather. This saves needing to do string comparisons to determine which icon to use. Instead, I was able to construct a CSV file which has columns for this numeric value, the corresponding weather, and the filename of the icon that most closely matches the weather state. Then it was a simple matter of pulling out the numeric value from the API, looking the value up in a table, and displaying the relevant graphic.

All of this serves to reinforce why Processing is such a great language for fast development of ideas, and makes me realise exactly why a program in Processing is referred to as a "sketch".

No comments:

Post a Comment