Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Selecting images from an array with a slider (ControlP5 + Processing3)
import controlP5.*;
ControlP5 cp5;
PImage[] images = new PImage[12];
int imageIndex = 0;
void setup(){
size(800,800);
for(int i = 0; i < 12; i++){
images[i] = loadImage(i+".gif");
}
// instanciate the control p5 object
cp5 = new ControlP5(this);
// define the slider with the imageIndex variable bound
cp5.addSlider("imageIndex")
// set the range of the slider between 0 and the images array length -1
.setRange(0,images.length-1)
.setValue(0)
.setPosition(100,400);
}
void draw(){
// display the image by doing sth like:
image(images[imageIndex],0,0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.