Mouse & keyboard inputs
Arrays & design strategy
// --- Color options and current pen & background color
var colors = [
    color(255,255,255),  // white
    color(255, 0, 0),    // red
    color(0, 255, 0),    // green
    color(0, 0, 255),    // blue
    color(255, 255, 0),  // yellow
    color(255, 0, 255),  // pink
    color(0, 255, 255),  // aqua
    color(0, 0, 0)       // black
];
var bgColorIndex = 0;    // colors[0] = white
var penColorIndex = 1;   // colors[1] = red
    References
// --- Pen size choices and current pen size
var penSizes = [ 2, 4, 8, 16 ];
var sizeIndex  = 1;
    References
draw = function() { 
    if (mouseIsPressed) {
       stroke(_____);        // pen color
       strokeWeight(_____);  // pen size
       // draw line from PREVIOUS mouse location to CURRENT mouse location
       line(pmouseX, pmouseY, mouseX, mouseY);
    }
};
    // --- Provide next array index and wrap around
var next = function (index, array) {
    index += 1;
    if (index >= array.length) {
        index = 0;
    }
    return index;
};
    keyPressed = function () {
    if (keyCode === "C".charCodeAt()) {          // change pen Color
        penColorIndex = next(penColorIndex, colors);
    } else if (keyCode === "S".charCodeAt()) {   // change pen Size
        sizeIndex = next(sizeIndex, penSizes);
    }
};
    keyPressed = function () {
    if (keyCode === "C".charCodeAt()) {          // change pen Color
        penColorIndex = next(penColorIndex, colors);
    } else if (keyCode === "S".charCodeAt()) {   // change pen Size
        sizeIndex = next(sizeIndex, penSizes);
    } else if (keyCode === "B".charCodeAt()) {   // change Background color
        bgColorIndex = next(bgColorIndex, colors);
    } else if (keyCode === "E".charCodeAt()) {   // erase to background color
        background(colors[bgColorIndex]);
    }  
};
    var menu = function () {
    var TEXT_COLOR = color(0, 43, 255);
    // menu background
    noStroke();
    fill(222, 247, 246);           // light blue
    rectMode(RADIUS);
    rect(width/2, 30, width/2, 30);
    // Pen color display
    fill(TEXT_COLOR);
    text("[C]olor", 10, 32);
    fill(______);                  // current pen color
    ellipseMode(RADIUS);
    ellipse(70, 30, 18, 18);
    // Pen Size display
    fill(TEXT_COLOR);
    text("[S]ize", 100, 32);
    fill(0, 0, 0);           // black
    rect(160, 28, 18, _____, 10);  // current pen size
}
draw = function() { 
    if (mouseIsPressed) { ... };
    menu();  // draw menu last, on top of everything else
};
    var menu = function () {
    ... Pen color and pen size menu ...
    // Background menu display
    fill(TEXT_COLOR);
    text("[B]ackground", 200, 26);
    text("[E]rase BG", 200, 44);
    fill(colors[bgColorIndex]);  // background
    rect(300, 30, 18, 18);
    
    // Pen up/down status
    fill(TEXT_COLOR);
    if (mouseIsPressed) {
        text("DOWN", width-50, 32);   
    } else {
        text("UP", width-50, 32);
    }
};
    Text
Exercise Name: EZ Paint