Hello,
I've got a very basic question about ColorPicker in ControlP5.
I am inspired by Ira Greenberg's RadialGradient sketch, and want to draw circles with controlled transition of color from outer RGB values to inner. Somehow I couldn't manage sliders to update color values...
Can somebody explain, what should be changed here in order to see circles color based on sliders?
Thanks in advance for help
-
import controlP5.*;
ControlP5 cp5;
ColorPicker cp;
ColorPicker cp2;
int rad = 200;
//____________________________ outer RGB fill variables
float r1;
float g1;
float b1 ;
// ____________________________inner RGB fill variables
float r2;
float g2;
float b2;
// ____________________________decrement RGB
float r3 = (r2-r1)/rad;
float g3 = (g2-g1)/rad;
float b3 = (b2-b1)/rad;
void setup()
{
size (600, 600);
smooth();
background(150);
noStroke();
ellipseMode(RADIUS);
//____________________________ RGB sliders
cp5 = new ControlP5(this);
cp = cp5.addColorPicker("RGB_outer")
.setPosition (60, 10)
.setColorValue(color(r1, g1, b1, 255))
;
cp2 = cp5.addColorPicker("RGB_inner")
.setPosition (60, 90)
.setColorValue(color( r2, g2, b2, 255))
;
}
void draw()
{
drawGradient(300, 300);
}
// ____________________________ function to draw circles + fill
void drawGradient(float x, float y)
{
for (int r = rad; r!=0; r--)
{
fill (r1, g1, b1);
ellipse (x, y, r, r);
r1 +=r3;
g1 +=g3;
b1 +=b3;
}
}
1