Color with shape
in
Programming Questions
•
10 months ago
Hello people,
I have a quick question, this is my situation:
I have 16 boxes in 4x4 configuration. I want to get reading from a Serial Port (COM) and update the color of each box. Let say, my PIC16F73 will send 16 BYTE (8bit each one) and then store in a buffer then once the buffer is completed by loading those 16 BYTES then they will show up on the screen depending of each byte which will correspond to each color from 0 to 255. I want to change only the color from white to black let say the transition in the middle will become gray. Example: the input is 125 that number will become grey at that moment and so on... The range will be black to white or viceversa.
First, How can I change the color of each shape?
This is my code so far:
void setup () {
size (1000, 600);
}
void draw () {
background (1);
beginShape();
vertex(0, 0);
vertex(250, 0);
vertex(250, 150);
vertex(0, 150);
endShape(CLOSE);
beginShape();
vertex(250, 0);
vertex(500, 0);
vertex(500, 150);
vertex(250, 150);
endShape(CLOSE);
beginShape();
vertex(500, 0);
vertex(750, 0);
vertex(750, 150);
vertex(500, 150);
endShape(CLOSE);
beginShape();
vertex(750, 0);
vertex(1000, 0);
vertex(1000, 150);
vertex(750, 150);
endShape(CLOSE);
beginShape();
vertex(0, 150);
vertex(250, 150);
vertex(250, 300);
vertex(0, 300);
endShape(CLOSE);
beginShape();
vertex(250, 150);
vertex(500, 150);
vertex(500, 300);
vertex(250, 300);
endShape(CLOSE);
beginShape();
vertex(500, 150);
vertex(750, 150);
vertex(750, 300);
vertex(500, 300);
endShape(CLOSE);
beginShape();
vertex(750, 150);
vertex(1000, 150);
vertex(1000, 300);
vertex(750, 300);
endShape(CLOSE);
beginShape();
vertex(0, 300);
vertex(250, 300);
vertex(250, 450);
vertex(0, 450);
endShape(CLOSE);
beginShape();
vertex(250, 300);
vertex(500, 300);
vertex(500, 450);
vertex(250, 450);
endShape(CLOSE);
beginShape();
vertex(500, 300);
vertex(750, 300);
vertex(750, 450);
vertex(500, 450);
endShape(CLOSE);
beginShape();
vertex(750, 300);
vertex(1000, 300);
vertex(1000, 450);
vertex(750, 450);
endShape(CLOSE);
beginShape();
vertex(0, 450);
vertex(250, 450);
vertex(250, 600);
vertex(0, 600);
endShape(CLOSE);
beginShape();
vertex(250, 450);
vertex(500, 450);
vertex(500, 600);
vertex(250, 600);
endShape(CLOSE);
beginShape();
vertex(500, 450);
vertex(750, 450);
vertex(750, 600);
vertex(500, 600);
endShape(CLOSE);
beginShape();
vertex(750, 450);
vertex(1000, 450);
vertex(1000, 600);
vertex(750, 600);
endShape(CLOSE);
}
1