import controlP5.*;
ControlP5 cp5;
int myColorBackground = color(0,0,0);
public float numberboxValue = 100;
void setup() {
size(700,400);
noStroke();
cp5 = new ControlP5(this);
cp5.addNumberbox("numberbox")
.setPosition(100,160)
.setSize(100,20)
.setScrollSensitivity(1)//??
.setDirection(Controller.HORIZONTAL) // change the control direction to left/right
.setValue(50)
;
cp5.addNumberbox("numberboxValue")
.setPosition(100,220)
.setSize(100,20)
.setRange(0,200)
.setMultiplier(1) // set the sensitifity of the numberbox敏感性
.setDirection(Controller.HORIZONTAL) // change the control direction to left/right
.setValue(100)
;
}
void draw() {
background(myColorBackground);
fill(numberboxValue,0,0);
rect(0,0,h,100);
}
int h;
void numberbox(int theColor) { //即numberbox的TheValue
myColorBackground = color(theColor);
h = theColor;
println("a numberbox event. setting background to "+theColor);
}```
[processing学习]ControlP5-06-numberbox
最新推荐文章于 2025-12-29 06:05:29 发布
本文介绍了一个基于Processing的程序实例,通过ControlP5库创建了两个数值选择器(numberbox)来动态调整画布背景颜色及填充颜色。其中一个numberbox用于设置背景颜色,另一个用于设置矩形的填充颜色。
6万+

被折叠的 条评论
为什么被折叠?



