ライブラリー(sketch_ControlP5_colorPicker)スケッチ
ライブラリー(sketch_ControlP5_colorPicker)スケッチは以下となります。
//sketch_ControlP5_colorPicker
import controlP5.*;
ControlP5 cp5;
ColorPicker cp;
void setup()
{
size(400,400,P3D);
noStroke();
cp5 = new ControlP5(this);
cp = cp5.addColorPicker("picker")
.setPosition(0,0)
.setColorValue(color(255, 128, 0, 128));
}
void draw()
{
pushMatrix();
lights();
background(255);
fill(cp.getColorValue());
translate(width / 2, height / 2);
rotateY(map(mouseX, 0, width, -PI/1, PI/1));
rotateX(map(mouseY, 0, height, PI/1, -PI/1));
box(50,50,100);
popMatrix();
if (keyPressed == true)
{cp5.hide();}
else{cp5.show();}
}
void picker(int col)
{
println("picker\talpha:"+alpha(col)+"\tred:"+red(col)+"\tgreen:"+green(col)+"\tblue:"+blue(col)+"\t col="+hex(col));
}