Rotating Multiple Images A Random Amount
in
Programming Questions
•
5 months ago
Hi everyone, this is my first post so please be kind!
What I am doing is placing images at random in the sketch, this works fine but I would also like to rotate them a random amount of degrees.
I have managed to make an individual image rotate but cannot seem to get my random images to do it.
What happens is most of the images disappear of the screen, I thinks its to do with me translating it incorrectly but I just can't figure it out!
If someone would be so kind as to amend my code and add a few comments so I can see how its done I would really appreciate it!
Kind Regards,
Oli
PImage shoe1 ;
float scatterX = random(30, 670);
float scatterY = random(30, 345);
int spin = int(random(360));
int counter = 0;
int angle = int(random(360));
void setup()
{
size(700, 375);
imageMode(CENTER);
shoe1=loadImage("shoe1.png"); // load image
}
void draw()
{
while (counter < 10) {
shoe1.resize(0, 60); //shrink image size
//uncomment below and most the images dissapear
/* translate(scatterX,scatterY);
rotate(radians(angle)); //rotate image random amount of degrees
*/
image(shoe1, scatterX, scatterY); // put image at random location
counter +=1; // add to count
scatterX = random(30, 670); //get new X position
scatterY = random(30, 345); // get new Y position
print(counter); // check counter works
}
}
1