dimanche 22 avril 2018

show random image on Processing

I'm really noob on processing and programing and I can't figure it out how to show my images at random.

I'm loading the images in setup with the PImage name img0, img1, img2 and then

image("img" + random(3), 0, 0); 

But it does't work, coz processing wait for a PImage argument, and the string plus a number isn't.

And I know for shure there must be some better way than:

int randomNumber = random(3);

if(randomNumber == 0 ){ 
   image(img0,0,0);
} 
if(randomNumber == 1 ){ 
    image(img1,0,0);
} 
if(randomNumber == 2 ){
    image(img2,0,0);
} 

But I haven't found it.

Any thoughts? thanks!




Aucun commentaire:

Enregistrer un commentaire