// Modified from Daniel Shiffman's example /** * Code kinda works online, but better within Processing. */ PImage img; PFont f; String typing = ""; String savedZip = ""; String weather = ""; String location =""; int temp = 0; String[] otherside; // The array to hold all of the text int counter = 0; int counterCounter = 0; int counterIncrement = 50; // speed of text display boolean hasZip = false; // We will use spaces and punctuation as delimiters String delimiters = " ,.?!;:[]-"; void setup() { smooth(); size(700,512); f = loadFont("Harrington-25.vlw"); // println(temp); //show switch/case in print line //frameRate(2); // Make a new instance of a PImage by loading an image file img = loadImage("wood_window_web.jpg"); //the window } void draw() { background(0); //The image() function displays the image at a location-in this case the point (0,0). image(img,0,0); //placement of image textFont(f); // textMode(SCREEN); fill(25); // almost true black // Display all the stuff we want to display text("What does it feel like out?",185,40); text("Enter U.S. zip code & press return to get a reading.",65,485); fill(255,0,0); // red text(typing,53,330); //zip code input text(savedZip,53,330); //zip code text(weather,53,175); text("°F",580,175); // degrees farenheit text(temp,550,175); text(location,620,200); //city location // some zip codes to try: 90210 - L.A., 10003 - Downtown NYC, 99501 - Anchorage, AK, // 96801 - Honolulu, HI, 85001 - Phoenix, AZ, 53201 - Milwaukee, WI // 98101 - Seattle, WA, 60601 - Chicago, IL if (hasZip == true){ String theword = otherside[counter]; fill(255); text(theword,280,250); if (counterCounter >= counterIncrement){ counter = (counter + 1) % otherside.length; // move onto the next word counterCounter = 20; } counterCounter ++; } // Draw a little thermometer based on the temperature // stroke(125); // fill(255,0,0); // rect(100,270,temp*2,20); } void keyPressed(){ //If the return key is pressed, save the String and clear it if (key == '\n'){ savedZip = typing; getWeather(savedZip); typing = ""; } else { typing = typing + key; savedZip = ""; } } void getWeather(String saved) { //Get all the HTML/XML source code into an array of strings (each line is one element in the array) String url = "http://itp.nyu.edu/icm/proxy/proxy.php?url=http://xml.weather.yahoo.com/forecastrss?p=" + saved; // using our php proxy to allow it to work in a browser String[] lines = loadStrings(url); for(int i=0;i