dear all,
i am quite new in processing. and i don't know if it possible to add extra information into println.
with a lot of help i have manage to generate a random show wheel but i need to add extra information in the println.
i have renamed the images and what i would like is;
if pictures 1 to 5 are shown then add happy to the println,
if pictures 10 to 16 are shown then add angry to the println
if pictures 21 to 24 are shown then add sad to the println.
is it possible?
i attach the code-----------
PrintWriter output;
int counter; // Automatically initialized at 0
final int DISPLAY_TIME = 5000; // 5000 ms = 5 seconds
int lastTime; // When the current image was first displayed
//String logFileName = "FileList.txt";
String imageFolderPath = "C:/Users/FerranGaldon/Desktop/final projects MA/- PROCESSING/_9_text_file_java/data";
File[] files;
PImage[] images;
// Second version, just listing the images
void setup()
{
size(700, 700);
File imageFolder = new File(imageFolderPath);
files = imageFolder.listFiles(new FileFilter()
{
public boolean accept(File file)
{
if (file.isDirectory())
return false; // Only files. A directory can have a dot in its name...
String name = file.getName();
return name.endsWith(".jpg") || name.endsWith(".png") || name.endsWith(".gif");
}
});
images = new PImage[files.length];
for (int i = 0; i < files.length; i++)
{
images[i] = loadImage(files[i].getAbsolutePath());
}
randomizeImages();
showImageInfo();
lastTime = millis();
}
void draw()
{
background(255);
fill(#005599);
if (millis() - lastTime >= DISPLAY_TIME) // Time to display next image
{
counter++;
if (counter == files.length) // Or IMAGE_NB
{
// Displayed all images, re-randomize the images
randomizeImages();
}
lastTime = millis();
showImageInfo();
}
image(images[counter], 0,0);
}
void randomizeImages()
{
for (int i = images.length - 1; i > 0; i--)
{
int j = int(random(i + 1));
// Swap
PImage ti = images[i];
images[i] = images[j];
images[j] = ti;
// Swap
File tf = files[i];
files[i] = files[j];
files[j] = tf;
}
}
void showImageInfo()
{
File tf = files[counter];
println("-----------------------");
println("Name: " + tf.getName());
println("-----------------------");
}
1