Fade images in and out running on an RSS feed
in
Programming Questions
•
4 months ago
Hi! I'm quite new to Processing and all it's wonders so apologies in advance for my lack of understanding! I'm making a little applet that is running off the tubeupdates.com London Underground RSS feed. It displays images I've made that show which line has a problem. Very simple. I'd like the images to fade in and out if possible. I have been playing with tint(), and have tried to follow this sketch:
http://www.openprocessing.org/sketch/57102
However I can't get it to work on so many images. Is there a simpler way? Here is my code:
PImage imgBakerloo;
PImage imgCentral;
PImage imgCircle;
PImage imgDistrict;
PImage imgHamCity;
PImage imgJubilee;
PImage imgMetropolitan;
PImage imgNorthern;
PImage imgOverground;
PImage imgPiccadilly;
PImage imgVictoria;
PImage imgWaterloo;
PImage imgGoodService;
int transparency1;
int transparency2;
int transparency3;
void setup() {
size(1600, 1062);
transparency1 = 255;
transparency2 = 0;
transparency3 = 0;
imgGoodService = loadImage("tubemap.jpg");
imgBakerloo = loadImage("Bakerloo.jpg");
imgCentral = loadImage("Central.jpg");
imgCircle = loadImage("Circle.jpg");
imgDistrict = loadImage("District.jpg");
imgHamCity = loadImage("HamCity.JPG");
imgJubilee = loadImage("Jubilee.jpg");
imgMetropolitan = loadImage("Metropolitan.jpg");
imgNorthern = loadImage("Northern.jpg");
imgOverground = loadImage("Overground.jpg");
imgPiccadilly = loadImage("Piccadilly.jpg");
imgVictoria = loadImage("Victoria.jpg");
imgWaterloo = loadImage("WaterlooCity.jpg");
}
void draw() {
background(0);
String next = getNext();
if(next != null) {
println(next);
if (next.contains("Good Service")) {
// tint(255,255,255,transparency1);
image(imgGoodService,0,0);
// if(transparency1 > 0){
// transparency1--;
// }
// tint(255,255,255,255-transparency1);
}
else if (next.contains("Central")) image(imgCentral,0,0);
else if (next.contains("Bakerloo")) image(imgBakerloo,0,0);
else if (next.contains("Circle")) image(imgCircle,0,0);
else if (next.contains("District")) image(imgDistrict,0,0);
else if (next.contains("H'smith & City")) image(imgHamCity,0,0);
else if (next.contains("Jubilee")) image(imgJubilee,0,0);
else if (next.contains("Metropolitan")) image(imgMetropolitan,0,0);
else if (next.contains("Northern")) image(imgNorthern,0,0);
else if (next.contains("Overground")) image(imgOverground,0,0);
else if (next.contains("Piccadilly")) image(imgPiccadilly,0,0);
else if (next.contains("Victoria")) image(imgVictoria,0,0);
else if (next.contains("Waterloo")) image(imgWaterloo,0,0);
}
delay(5000);
}
http://www.openprocessing.org/sketch/57102
However I can't get it to work on so many images. Is there a simpler way? Here is my code:
PImage imgBakerloo;
PImage imgCentral;
PImage imgCircle;
PImage imgDistrict;
PImage imgHamCity;
PImage imgJubilee;
PImage imgMetropolitan;
PImage imgNorthern;
PImage imgOverground;
PImage imgPiccadilly;
PImage imgVictoria;
PImage imgWaterloo;
PImage imgGoodService;
int transparency1;
int transparency2;
int transparency3;
void setup() {
size(1600, 1062);
transparency1 = 255;
transparency2 = 0;
transparency3 = 0;
imgGoodService = loadImage("tubemap.jpg");
imgBakerloo = loadImage("Bakerloo.jpg");
imgCentral = loadImage("Central.jpg");
imgCircle = loadImage("Circle.jpg");
imgDistrict = loadImage("District.jpg");
imgHamCity = loadImage("HamCity.JPG");
imgJubilee = loadImage("Jubilee.jpg");
imgMetropolitan = loadImage("Metropolitan.jpg");
imgNorthern = loadImage("Northern.jpg");
imgOverground = loadImage("Overground.jpg");
imgPiccadilly = loadImage("Piccadilly.jpg");
imgVictoria = loadImage("Victoria.jpg");
imgWaterloo = loadImage("WaterlooCity.jpg");
}
void draw() {
background(0);
String next = getNext();
if(next != null) {
println(next);
if (next.contains("Good Service")) {
// tint(255,255,255,transparency1);
image(imgGoodService,0,0);
// if(transparency1 > 0){
// transparency1--;
// }
// tint(255,255,255,255-transparency1);
}
else if (next.contains("Central")) image(imgCentral,0,0);
else if (next.contains("Bakerloo")) image(imgBakerloo,0,0);
else if (next.contains("Circle")) image(imgCircle,0,0);
else if (next.contains("District")) image(imgDistrict,0,0);
else if (next.contains("H'smith & City")) image(imgHamCity,0,0);
else if (next.contains("Jubilee")) image(imgJubilee,0,0);
else if (next.contains("Metropolitan")) image(imgMetropolitan,0,0);
else if (next.contains("Northern")) image(imgNorthern,0,0);
else if (next.contains("Overground")) image(imgOverground,0,0);
else if (next.contains("Piccadilly")) image(imgPiccadilly,0,0);
else if (next.contains("Victoria")) image(imgVictoria,0,0);
else if (next.contains("Waterloo")) image(imgWaterloo,0,0);
}
delay(5000);
}
1