Creating a Slideshow
in
Programming Questions
•
2 years ago
Hi all!
I'm as new here as in programming :)
I created a small program for my degree project. I'm in an art school.
It's a program that loads pictures like a slideshow, very quickly.
I've got thousands of pictures with different sizes.
How could I say
if the picture width is bigger than than the screen width, width pictures == screen width,
f the pictures height is bigger than than the screen height, height pictures == screen height,
??
I'm sure it so simple but I'm a bit of a Newbee :)
Thank's all
Here is my code.
PS: I'm sure it could be optimized so if you see anything that could be coding better, PLEASE tell me!!
/**
Brainwashing
Correction: romée by basile
*/
PImage img;
String[] files;
int timer;
float a ;
int fragNumber;
void setup() {
size(1300,760);
float a = random(0,1327);// a est une valeur au hasard comprise entre les deux valeurs données (n'apelle pas tes images "0001" mais "1");
int fragNumber = int (a);//fragNumber est l'arrondi de a (10,55 --> 11)
img = loadImage("pic_" + fragNumber +".jpg");
println(fragNumber);
timer=0;
}
void draw() {
background(255);
if(timer==0)
{
smooth();
imageMode(CENTER);
image(img,650,380);//Si tu veux leur donner à toute une taille commune (les adapter à la fen^tre par ex:
// il te suffit de mettre image(img,0,0,largeur,hauteur);
}
else if(timer==1)
{
a = random(0,1327);
int fragNumberPlus=int (a);//fragNumberPlus est l'image qui charge pendant ce temps (une autre épreuve de "a")
img = loadImage("pic_" + fragNumberPlus +".jpg");
println(fragNumberPlus);
delay(130); //this decides how long an image should be displayed
}
timer=(timer+1)%2;
}
1