/* built with Studio Sketchpad:
* https://sketchpad.cc
*
* observe the evolution of this sketch:
* https://studio.sketchpad.cc/sp/pad/view/ro.SEox$spWTn2/rev.17
*
* authors:
* Natalia Valencia
* license (unless otherwise specified):
* creative commons attribution-share alike 3.0 license.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
/* @pjs preload="/static/uploaded_resources/p.14209/leticia.jpg"; */
cite Cite;
cite2 Cite2;
void setup()
{
size(800,300);
background(255);
Cite = new cite("loadImage("/static/uploaded_resources/p.14209/leticia.jpg");", "368335");
Cite2 = new cite2("leticia.jpg", "368148");
}
void draw()
{
Cite.dibujar();
}
void mousePressed ()
{
background (random (255), random (255), random (255));
}
class cite
{
PFont fuente;
String urlYahoo;
PImage leticia;
float posx;
float velx;
cite(String imgCiudad, String codCiudad)
{
posx = width;
velx = -5;
leticia = loadImage(imgCiudad);
fuente = loadFont("Helvetica-Light-48.vlw");
urlYahoo = "http://weather.yahooapis.com/forecastrss?w="+codCiudad+"&u=c";
}
void dibujar()
{
//Leticia
XML xmlYahoo = loadXML(urlYahoo);
XML[] hijosC = xmlYahoo.getChildren("channel/item/yweather:condition");
XML[] hijosL = xmlYahoo.getChildren("channel/yweather:location");
String temperatura = hijosC[0].getString("temp");
String date = hijosC[0].getString("date");
String descripcion = hijosC[0].getString("text");
String ciudad = hijosL[0].getString("city");
background(0);
image(leticia,posx,0,width,height);
textAlign(LEFT);
textFont(fuente,40);
fill(255,200);
text(ciudad,posx,200);
text(temperatura,posx, 50);
text(date,posx,100);
text(descripcion,posx,150);
posx = posx -10;
}
}
class cite2
{
PFont fuente2;
String urlYahoo2;
PImage leticia;
float posx2;
float velx2;
cite2(String imgCiudad2, String codCiudad2)
{
posx2 = width;
velx2 = -5;
leticia = loadImage(imgCiudad2);
fuente2 = loadFont("Helvetica-Light-48.vlw");
urlYahoo2 = "http://weather.yahooapis.com/forecastrss?w="+codCiudad2+"&u=c";
}
void dibujar()
{
//Leticia
XML xmlYahoo2 = loadXML(urlYahoo2);
XML[] hijosC2 = xmlYahoo2.getChildren("channel/item/yweather:condition");
XML[] hijosL2 = xmlYahoo2.getChildren("channel/yweather:location");
String temperatura2 = hijosC2[0].getString("temp");
String date2 = hijosC2[0].getString("date");
String descripcion2 = hijosC2[0].getString("text");
String ciudad2 = hijosL2[0].getString("city");
background(255);
image(leticia,posx2,0,width,height);
textAlign(LEFT);
textFont(fuente2,20);
fill(255);
text(temperatura2,posx2,50);
text(date2,posx2,100);
text(descripcion2,posx2,150);
text(ciudad2,posx2,200);
posx2 = posx2 -30;
}
}