using potentiometer values to scroll left and right.
in
Programming Questions
•
5 months ago
I originally want to map images to values from a potentiometer, but now I just want to scroll left and right in a slideshow using a potentiometer;
- PImage img;
- int x,y;
- void setup()
- {
- size(1000,664);
- img = loadImage("imagescroll.jpg"); // image is 1600 x 600
- }
- void draw()
- {
- // background(0);
- // not needed as image is bigger than size
- // and thus overwrites all areas
- x = constrain(x, 0, img.width - width);
- // ensures that "scrolling" stops at right end of image
- // y = constrain(y, 0, img.height - height);
- // Not needed here, as scolling only in x
- image(img, -x, 0);
- // overwrites the whole screen with the "shifted" image
- x = frameCount;
- // advances the image with each new frame
- // do whatever is wanted from here on
- // like after a call of background();
- //stroke(0,0,0);
- //ellipse(mouseX,mouseY,15,15);
- }
I want to use the values 0 to 1023 I get from using a potentiometer, I want to use the values to select how quickly I scroll through the images and in which direction. Values near 512 stop the scroll, values dropping below 512 would scroll left and values increasing above 512 would scroll right.
How would I write this into the code above?
Cheers
1