# Anyone know how to Slow down my slideshow?

**URL:** <https://discourse.processing.org/t/anyone-know-how-to-slow-down-my-slideshow/6493>\
**Category:** Coding Questions\
**Created:** [December 10, 2018, 11:49pm UTC](https://discourse.processing.org/t/anyone-know-how-to-slow-down-my-slideshow/6493 "2018-12-10T23:49:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Halcyon](https://avatars.discourse-cdn.com/v4/letter/h/f17d59/32.png) [@Halcyon](https://discourse.processing.org/u/Halcyon)\
**Post date:** [December 10, 2018, 11:49pm UTC](https://discourse.processing.org/t/anyone-know-how-to-slow-down-my-slideshow/6493/1 "2018-12-10T23:49:56Z")

</div>

I am working on a slideshow that display my images repeatedly but the problem is that its showing it way too fast. How can I slow it down?

## Here is my code

```auto
PImage[] images = new PImage[4]; 
int imageIndex = 0; 
int i=0;//Timer
int savedTime;
int totalTime = 3000;

void setup() { 
  size(667,700); // 
  background (0);
}

void draw() { 
  background(255);   

  ///REPEATED SLIDE SHOW////// 
  images[i] = loadImage("Visual"+i+".PNG");     
  image(images[i], 0,0);
  i++;
  if(i>3){
    i=0;
  }
}

```

---

<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 11, 2018, 1:27am UTC](https://discourse.processing.org/t/anyone-know-how-to-slow-down-my-slideshow/6493/2 "2018-12-11T01:27:31Z")

</div>

- pls format your code with

> \</\>

- if you load the images at runtime the array makes no sense
- you need a timer:

```auto
PImage img;
int i=0; 
long startT, totalT = 3000;

void setup() {
  size(667, 700);
}

void draw() {
  background(200, 200, 0);
  img = loadImage("data/Visual"+i+".PNG");
  image(img, 10, 10+10*i); // image(img,0,0);
  if ( millis() > startT + totalT ) {
    startT = millis();
    i++;
    if (i>imax) i=0;
  }
}

```

with array use

```auto
int imax = 4;
PImage[] images = new PImage[imax];
int i=0; 
long startT, totalT = 3000;

void setup() {
  size(667, 700);
  for (int k = 0; k < imax; k++) images[k] = loadImage("data/Visual"+k+".PNG");
}

void draw() {
  background(200, 200, 0);
  image(images[i], 0, 0);
  myTimer();
}

void myTimer() {
  if ( millis() > startT + totalT ) {
    startT = millis();
    i++;
    if (i>=imax) i=0;
  }
}

```

---

<div class="post-metadata">

**Author:** ![TPMoyer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tpmoyer/32/2138_2.png) [@TPMoyer](https://discourse.processing.org/u/TPMoyer)\
**Post date:** [December 11, 2018, 6:16pm UTC](https://discourse.processing.org/t/anyone-know-how-to-slow-down-my-slideshow/6493/3 "2018-12-11T18:16:18Z")

</div>

Include the statement  
frameRate(0.1);  
in your setup to give 10 seconds per refresh.

The general solution is to size the argument “fps” in  
[https://processing.org/reference/frameRate\_.html](https://processing.org/reference/frameRate_.html)  
as 1/(the seconds you want for the refresh delay).

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [December 16, 2018, 10:36pm UTC](https://discourse.processing.org/t/anyone-know-how-to-slow-down-my-slideshow/6493/4 "2018-12-16T22:36:20Z")

</div>

An alternative to using a very low frameRate is to have your code execute on every nth frame – for example, every 600 frames at 60fps (10 seconds).

```auto
void draw(){
  if(frameCount%600=0){
    // redraw screen
  }
}

```

The nice thing about this is that your input/output (and the quit ESC key) will still be checked at 60fps, but the screen will redraw every 10 seconds. If you do it with `frameRate(0.1)` then it may take up to 10 seconds after you hit a key for the program to do something (e.g. quit the slideshow) – it is frozen on the draw loop.
