Example to fill shapes with color in Processing 2.0+, using fill() method:
|
fill shapes with color in Processing |
int buttonA_x = 300;
int buttonA_y = 50;
int buttonA_width = 50;
int buttonA_height = 50;
int buttonA_colorR = 0xff;
int buttonA_colorG = 0x00;
int buttonA_colorB = 0x00;
int buttonB_x = 300;
int buttonB_y = 150;
int buttonB_width = 50;
int buttonB_height = 50;
int buttonB_r = 10;
int buttonB_color = 200;
int defaultColor = 150;
void setup() { // setup() runs once
size(400, 300);
background(255);
}
void draw() {
line(0, 0, width, height);
fill(defaultColor);
ellipse(width/2, height/2, 100, 100);
fill(buttonA_colorR, buttonA_colorG, buttonA_colorB);
rect(buttonA_x, buttonA_y, buttonA_width, buttonA_height);
fill(buttonB_color);
rect(buttonB_x, buttonB_y, buttonB_width, buttonB_height, buttonB_r);
}
No comments:
Post a Comment