Display several images (icons) randomly
in
Programming Questions
•
9 months ago
Hi,
I'm new to processing and I've got some questions.
In my little project I want to display some icons with random coordinates.
Then I want an animation; every image is supposed to 'shake' a bit. For that I added "random(5)" to the x-position and to the y-position of the image.
This is my code so far:
My problem is that all images got the same position. But i want them to have an own position each. As I said, I'm more or less a beginner to this program, maybe you can put me in the right way?!
At the end I want it to be interactive. Every image has its own random position (or is floating randomly all over the background size) and if my mouse cursor is located near by one or more images the image(s) shall follow the cursor).
Best thing would be if I can create something like is shown on http://www.wefeelfine.org/. Just with images instead of those colorful objects.
Thank you!
I'm new to processing and I've got some questions.
In my little project I want to display some icons with random coordinates.
Then I want an animation; every image is supposed to 'shake' a bit. For that I added "random(5)" to the x-position and to the y-position of the image.
This is my code so far:
PImage[] bild;
PImage img;
float a = random(50,950);
float b = random(50,550);
int n=34;
void setup() {
size(1000, 600);
img = loadImage("background.jpg");
bild=new PImage[n];
for(int i=0;i<bild.length;i++){
bild[i]=loadImage(str(i) + ".png");
smooth();
//frameRate(25);
}
}
void draw(){
image(img,0,0);
for(int i=0;i<bild.length;i++){
image(bild[i],a+random(5),b+random(5));
}
}
My problem is that all images got the same position. But i want them to have an own position each. As I said, I'm more or less a beginner to this program, maybe you can put me in the right way?!
At the end I want it to be interactive. Every image has its own random position (or is floating randomly all over the background size) and if my mouse cursor is located near by one or more images the image(s) shall follow the cursor).
Best thing would be if I can create something like is shown on http://www.wefeelfine.org/. Just with images instead of those colorful objects.
Thank you!
1