Slider redS,greenS,blueS; int red = 120; int green = 120; int blue = 120; void setup() { size(500,500); background(red-120,green-120,blue-120); redS = new Slider(red,205); greenS = new Slider(green,235); blueS = new Slider(blue,265); } void draw() { box(); lines(); sliders(); } void box() { rectMode(CORNER); noStroke(); fill(190); rect(100,175,295,125); } void lines() { stroke(0); strokeWeight(3); line(120,205,335,205); line(120,235,335,235); line(120,265,335,265); } void sliders() { redS.draw(); greenS.draw(); blueS.draw(); } void mousePressed() { while(redS.mouseOn()){ redS.colour = mouseX; } } class Slider{ float colour,y; int w = 10; Slider(int colour, int y){ this.colour = colour; this.y = y; } void draw() { fill(0,255,255); rectMode(CENTER); strokeWeight(1); rect(colour,y,w,w); } boolean mouseOn(){ if(mouseX > colour && mouseX < colour+w && mouseY > y-w/2 && mouseY < y+w) { return true; } else { return false; } } }