# PImage - Array reverse

**URL:** https://discourse.processing.org/t/pimage-array-reverse/16668
**Category:** Coding Questions
**Created:** [December 28, 2019, 12:46am UTC](https://discourse.processing.org/t/pimage-array-reverse/16668 "2019-12-28T00:46:15Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![iheartart](https://avatars.discourse-cdn.com/v4/letter/i/a183cd/32.png) [@iheartart](https://discourse.processing.org/u/iheartart)
#### Post date: [December 28, 2019, 12:46am UTC](https://discourse.processing.org/t/pimage-array-reverse/16668/1 "2019-12-28T00:46:15Z")

</div>

Hi Guys, I have a little troubleshooting with a PImage…  
The code works but i really wonder how to change the direction of the pictures.  
Starting mouseY on top with numb 22 going down to 0.  
( I just managed to start the array with 0 going down to 22 ).  
Since i tried the whole day to find the solution, i hope you could help me:

```auto
PImage[] images;
int numImg = 22;

void setup() {

  background(255);
  size(944, 944);
  images = new PImage [numImg]; 

  for (int a=0; a<numImg; a++) {
    images[a] = loadImage("smile-" + a +".png" );
  }
}

void draw() {
  background(255);
  int imgNr = int(map(mouseY, 0, width, 0, numImg));
  translate(width/2, height/2);
  imageMode(CENTER);
  image(images[imgNr], 0, 0);
}

```

//All the best Iheartart

---

<div class="post-metadata">

### Author: ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)
#### Post date: [December 28, 2019, 1:00am UTC](https://discourse.processing.org/t/pimage-array-reverse/16668/2 "2019-12-28T01:00:32Z")

</div>

please format your code posting by pasting it into the

```auto
</> code button

```

of the editor header menu ( context name: Preformatted text )  
it looks like  
```  
type or paste code here  
```

also can use the ``` manually above and below your code.

thank you.

* * *

if you ask about the load Image sequence?

```auto
for (int a=0; a<numImg; a++) {

```

did you try ?

```auto
for (int a=numImg-1; a>=0; a--) {

```

---

<div class="post-metadata">

### Author: ![iheartart](https://avatars.discourse-cdn.com/v4/letter/i/a183cd/32.png) [@iheartart](https://discourse.processing.org/u/iheartart)
#### Post date: [December 28, 2019, 1:10am UTC](https://discourse.processing.org/t/pimage-array-reverse/16668/3 "2019-12-28T01:10:25Z")

</div>

Sorry, didn´t knew it.  
The animation works with your variable aswell but it didn´t change the direction of the sequenz.

---

<div class="post-metadata">

### Author: ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)
#### Post date: [December 28, 2019, 1:14am UTC](https://discourse.processing.org/t/pimage-array-reverse/16668/4 "2019-12-28T01:14:17Z")

</div>

> [@iheartart](#):
>
> Sorry, didn´t knew it

no problem, please edit your first post now. ( not make an new post for it )

* * *

please more detail about your question,

```auto
for (int a=0; a<numImg; a++) {
images[a] = loadImage(“smile-” + a +".png" );
}

```

possibly

```auto
for (int a=0; a<numImg; a++) {
images[numImg-1-a] = loadImage(“smile-” + a +".png" );
}

```

---

<div class="post-metadata">

### Author: ![iheartart](https://avatars.discourse-cdn.com/v4/letter/i/a183cd/32.png) [@iheartart](https://discourse.processing.org/u/iheartart)
#### Post date: [December 28, 2019, 1:25am UTC](https://discourse.processing.org/t/pimage-array-reverse/16668/5 "2019-12-28T01:25:40Z")

</div>

It worked! Thanks for your advice !  
I see, its the double subtraction whitch changes the direction, right ?
