Mapping color/tint values to ControlP5 slider

edited April 2016 in Library Questions

Hi folks, Novice user here, just with a simple question. I am working on a program that can take a picture of a car using PImage, and then manipulate the color of it using a controlP5 slider. I have been able to play with the tint, but can't seem to get the slider to change it. Say the original image is a blue car; I want to be able to make it red, green,etc.

Thanks!

Here is my code:

PImage img; PImage dest; ControlP5 cp5; int sliderValue = 127; int textValue = 0;

void setup() { background(255, 255, 255); noStroke(); colorMode(HSB, 100); for (int i = 0; i < 100; i++) { for (int j = 0; j < 100; j++) { stroke(i, j, 100); point(i, j); } }

size(960, 540); img = loadImage("car1.png"); strokeWeight(10); cp5 = new ControlP5(this); cp5.addSlider("slide", 0, 255, sliderValue, 100, 50, 100, 20); cp5.addTextfield("text", 100, 100, 100, 20); }

void draw() { textSize(25); { fill(0); text("Real-Time Tuning", 370, 60); } fill(1000); image(img, 0, 0); fill(sliderValue); stroke(textValue); }

public void slider(int val) { sliderValue = val; }

public void text(String val) { textValue = Integer.parseInt(val); }

Sign In or Register to comment.