--------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------
import processing.video.*;
PImage img;
//Starting Slider positions
float lX = 1530;
float rX = 1530;
float gX = 1530;
float bX = 1530;
Capture cam;
//Load webcam and Background img
void setup() {
size(1800, 720, P2D);
img = loadImage ("Background.jpg");
String [] cameras = Capture.list();
if (cameras.length == 0) {
println("There are no cameras available for capture.");
exit();
} else {
println("Available cameras:");
for (int i = 0; i < cameras.length; i++) {
println(cameras[i]);
}
//Start cam
cam = new Capture (this, cameras [0]);
cam.start();
}
}
void draw() {
//Mapping the sliders
float lCC = map(lX, 1330, 1730, 2, 0);
float rCC = map(rX, 1330, 1730, 2, 0);
float gCC = map(gX, 1330, 1730, 2, 0);
float bCC = map(bX, 1330, 1730, 2, 0);
if (cam.available() == true) {
cam.read();
loadPixels();
cam.loadPixels();
int x = int(random(cam.width));
int y = int(random(cam.height));
for (int i = 0; i < width*height; i++) {
cam.pixels[i] = color (red(cam.pixels[i])*rCC*lCC, green (cam.pixels[i])*gCC*lCC, blue (cam.pixels[i])*bCC*lCC);
}
updatePixels ();
}
image (img, 170, 0);
image(cam, 0, 0);
//Slider 1
stroke(0);
line(1330, 330, 1730, 330);
fill(150);
rectMode(CENTER);
rect(lX, 330, 20, 12);
if (mouseX > 1330 && mouseX < 1730 && mouseY > 325 && mouseY < 335) {
if (mousePressed==true) {
lX=mouseX;
}
if (lX <=1330) {
lX=1330;
}
if (lX >= 1730) {
lX=1730;
}
}
//Slider 2
stroke(0);
line(1330, 450, 1730, 450);
fill(150);
rectMode(CENTER);
rect(rX, 450, 20, 12);
if (mouseX > 1330 && mouseX < 1730 && mouseY > 445 && mouseY < 455) {
if (mousePressed==true) {
rX=mouseX;
}
if (rX <=1330) {
rX=1330;
}
if (rX >= 1730) {
rX=1730;
}
}
// Slider 3
stroke(0);
line(1330, 550, 1730, 550);
fill(150);
rectMode(CENTER);
rect(bX, 550, 20, 12);
if (mouseX > 1330 && mouseX < 1730 && mouseY > 545 && mouseY < 555) {
if (mousePressed==true) {
bX=mouseX;
}
if (bX <=1330) {
bX=1330;
}
if (bX >= 1730) {
bX=1730;
}
}
// Slider 4
stroke(0);
line(1330, 650, 1730, 650);
fill(150);
rectMode(CENTER);
rect(gX, 650, 20, 12);
if (mouseX > 1330 && mouseX < 1730 && mouseY > 645 && mouseY < 655) {
if (mousePressed==true) {
gX=mouseX;
}
if (gX <=1330) {
gX=1330;
}
if (gX >= 1730) {
gX=1730;
}
}
}