
I can get one colored bar to expand as I hold down the key. I have another an issue of getting another colored bar to continue where the other one left off? Essentially it continues right after the previous rectangle depending on where it stops. Here's a picture of what I want to achieve (assuming each colored rectangle is a different length).
Here is my code:
int rectWidth=0;
int rectHeight=250;
int x = -rectWidth;
void setup(){
size(800,800);
background(0);
noStroke();
smooth();
}
void draw(){
rect(0, 0, rectWidth, rectHeight);
if(keyPressed){
rectWidth++;
if((key == 'a')) {
fill(#8fcd9c); }
if((key == 'b')) {
fill(#96c6ea); }
if((key == 'c')) {
fill(#ef3942); }
if((key == 'd')) {
fill(#fdf04d); }
if((key == 'e')) {
fill(#c6e9f6); }
if((key == 'f')) {
fill(#ef5a7a); }
if((key == 'g')) {
fill(#f8971d); }
}