# Coding a composite image of images that randomly shuffle in placement

**URL:** <https://discourse.processing.org/t/coding-a-composite-image-of-images-that-randomly-shuffle-in-placement/30694>\
**Category:** Coding Questions\
**Created:** [June 14, 2021, 6:24am UTC](https://discourse.processing.org/t/coding-a-composite-image-of-images-that-randomly-shuffle-in-placement/30694 "2021-06-14T06:24:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![phanan](https://avatars.discourse-cdn.com/v4/letter/p/a587f6/32.png) [@phanan](https://discourse.processing.org/u/phanan)\
**Post date:** [June 14, 2021, 6:24am UTC](https://discourse.processing.org/t/coding-a-composite-image-of-images-that-randomly-shuffle-in-placement/30694/1 "2021-06-14T06:24:17Z")

</div>

I know how to code basic Python, but am brand new to Processing/p5j.s. Any help would be appreciated on the steps needed to do the following:

I want to code an array of images to fill the background of a webpage, and have the position of each image randomly shuffled each time the page is refreshed. The images would be pulled from a folder of 1600 images (300x300 pixels each). With each refresh, every image is still present on screen but in a different place on the canvas. The images are quite abstract so the idea is that a different pattern is generated each time, creating a composite image that is never the same.

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [June 14, 2021, 10:40am UTC](https://discourse.processing.org/t/coding-a-composite-image-of-images-that-randomly-shuffle-in-placement/30694/2 "2021-06-14T10:40:31Z")

</div>

**in setup**

- load all images in an array arr
- shuffle that array

**in draw**  
make a nested for-loop to achieve a grid

```auto
int k=0; 
for x....
    for y......
        image (arr[k], x*300+300, y*300+300); 
        k++;
    }
}

```

**upon restart**

- shuffle arr

Hey, and welcome to the forum!

Great to have you here!

Warm regards,

Chrisir
