Beginner Question: Random image placement.
in
Programming Questions
•
1 month ago
Hi guys, I'm fairly new to coding and would greatly appreciate a bit of help with a small task.
What I am trying to do is place a single image into my sketch multiple times in random places but also of slightly varying sizes and gradually reducing the number of images and the sizes the lower the images are down the page.
This is an example of what I am trying to do. http://www.booksplendour.com.au/gallery/classics/Mucha/Mucha_Image19_sb.jpg The stars in the background all vary slightly in size and the further down the page they are the smaller and less frequently they appear until there are none at all.
This is where I am at the moment, the star image used is not the image I will be using but just an example. Am I on the right track? Thanks in advance.
What I am trying to do is place a single image into my sketch multiple times in random places but also of slightly varying sizes and gradually reducing the number of images and the sizes the lower the images are down the page.
This is an example of what I am trying to do. http://www.booksplendour.com.au/gallery/classics/Mucha/Mucha_Image19_sb.jpg The stars in the background all vary slightly in size and the further down the page they are the smaller and less frequently they appear until there are none at all.
This is where I am at the moment, the star image used is not the image I will be using but just an example. Am I on the right track? Thanks in advance.
- PImage webImg;
void setup(){
background(255);
size(780,1000);
String url = "http://ww1.prweb.com/prfiles/2011/10/12/8875514/star_white.jpg";
webImg = loadImage(url, "jpg");
for(int i=0; i<500; i= i + 1){
float r1 = random(-100, 780);
float r2 = random(-100, 500);
image(webImg,r1,r2);
}
}
1