Monday, 27 October 2014

Pixel Clock in Processing

Over the weekend I created a Digital Pixel clock in Processing, this sketch compiles various things I learnt in last week's workshop such as loading images and using strings. Strings are useful for grouping, comparing and extracting data which would be very important for me to learn when creating data visualisations in Processing. In the Pixel Clock I created values such as year, month and hour and stored them in a string using the following method.

String[] apple={"A","P","P","L","E",};

  String ye= str(year());
  String mo= str(month());
  String d= str(day());
  String h= str(hour());
  String m= str(minute());
  String s= str(second());
  String time = ye +"/"+ mo + "/" + d + " " + h + ":" + m + ":" + s;

Values such as year are defined by the letters "ye" which enables the year value to be called later in the sketch. As you can see I decided to display and format the time/date values professionally by putting slashes and colons in the correct place.

I've also implemented a mouse click event which when triggered it changes the image which is loaded, in this case an image of a banana will appear when the left mouse button is held down. 

In terms of my interactive display project strings would be very useful if I want to create a visualisation which uses multiple values which can be references several times. It's also a way of display live data for example a public display may change it's background to dark during the night and  light during day hours. 

No comments:

Post a Comment