Initial Commit

This commit is contained in:
plane000
2018-04-20 10:15:15 +01:00
parent 49150ccfe4
commit 62101e8e61
2870 changed files with 520122 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
/**
* Loading XML Data
* by Daniel Shiffman.
*
* This example demonstrates how to use loadXML()
* to retrieve data from an XML document via a URL
*/
// We're going to store the temperature
int temperature = 0;
// We're going to store text about the weather
String weather = "";
// Yahoo weather uses something called A WOEID (Where On Earth IDentifier)
// https://en.wikipedia.org/wiki/WOEID
// This is the WOEID for zip code 10003
String zip = "10003";
String woeid = "12761335";
PFont font;
void setup() {
size(600, 360);
font = createFont("Merriweather-Light.ttf", 28);
textFont(font);
// The URL for the XML document
String url = "http://query.yahooapis.com/v1/public/yql?format=xml&q=select+*+from+weather.forecast+where+woeid=" + woeid + "+and+u='F'";
// Load the XML document
XML xml = loadXML(url);
// Grab the element we want
XML forecast = xml.getChild("results/channel/item/yweather:forecast");
// Get the attributes we want
temperature = forecast.getInt("high");
weather = forecast.getString("text");
}
void draw() {
background(255);
fill(0);
// Display all the stuff we want to display
text("Zip: " + zip, width*0.15, height*0.33);
text("Todays high: " + temperature + "°F", width*0.15, height*0.5);
text("Forecast: " + weather, width*0.15, height*0.66);
}