Random Select Images and Fade in / fade out according to variable / Blend

Hi All,
can’t see the wood for the trees here!! I"m trying to randomly move through an image directory, and fade in and out according to a variable imgA_Duration. Eventually I want to blend multiple layers of images from a number of directories. I’m struggling to get any further than this right now though

My first issue is my PImages array.

Secondarily I aiming for a Fadein and Out to occur when a new image loads, and have the rate of this dependant upon the image’s display duration variable (totalT1)

import java.util.Date;

String pathA = " " ;
String[] filenamesA;
PImage[] imagesA = new PImage[99]; /// how to set value of array to = number of files in directory pathA? i.e filenamesA.length

int i=0; 
float startT1;
float totalT1 = 2000;   ///////////// imageA display duration

int imgNumA = 0;
float transparencyA = 0;
boolean fadeInA = true;
boolean fadeOutA = false;

void setup() { /////////////////////////////////////////////////////////////// setup starts

  size(1024, 576, P3D);
    
  pathA = sketchPath()+"/data/imagesA/";
  filenamesA = listfilenamesA(pathA);
  imagesA = new PImage[this.filenamesA.length]; 
  println("Listing all Image A files: ");
  printArray(filenamesA);
  println(this.filenamesA.length+" dir A images");
  
  for (int i = 0; i < this.filenamesA.length; i++) { 
  imagesA[i] = loadImage( "imagesA/"+i+".png");
  imagesA[i].resize(width, height);
  }
     
}  //////////////////////////////////////////////////////////////////////////// setup ends

void draw() { ////////////////////////////////////////////////////////////////// draw loop

   tint(255, transparencyA);
   PImage outA = imagesA[imgNumA];
   image(outA, 0, 0);

   if ( millis() > startT1 + totalT1 ) {
   startT1 = millis();
   imgNumA = (int)random(this.filenamesA.length);
   if (imgNumA>=this.filenamesA.length)
   imgNumA=0; 
}

   if (transparencyA < 256 && fadeInA) {
   transparencyA += 1;
   println("fade_InA:", transparencyA);
   if (transparencyA >= 255) {
   fadeInA = false;
   fadeOutA = true;
    }
  }
  
    if (transparencyA > 0 && fadeOutA) {
    transparencyA -= 1;
    println("fadeOutA :", transparencyA);
    if (transparencyA <= 0) {
    fadeInA = true;
    fadeOutA = false;
    }    
  }
         
} ///////////////////////////////////////////////////////////////////////////////////////// draw loop end

  String[] listfilenamesA(String dir) {
  File file = new File(dir);
  if (file.isDirectory()) {
    String names[] = file.list();
    return names;
  } else {
    // If it's not a directory
    return null;
  }
}

Been trying all afternoon!! Best wishes and thx, jnt

Hi @JonnieNightTime,

Maybe you can have a look here if there some useful hints for you to use …

Cheers
— mnse