//Initalize variables //Font data int fontsize; PFont font; int fontConstant; //The number to be added to position the text correctly //Object array for number box NUMBER_INPUT [] numberInputArray; //RGB data float R; float G; float B; void setup(){ size (800,200); //Object array setup //Where the positions of the array are:- //[0] RED //[1] GREEN //[2] BLUE numberInputArray = new NUMBER_INPUT [3]; numberInputArray[0] = new NUMBER_INPUT(150, 5, 75, 50, "%", 2, color (122,0,0), color (255,0,0), color (100)); numberInputArray[1] = new NUMBER_INPUT(150, 60, 75, 50, "%", 2, color (0,122,0), color (0,255,0), color (100)); numberInputArray[2] = new NUMBER_INPUT(150, 115, 75, 50, "%", 2, color (0,0,122), color (0,0,255), color (100)); //Font setup fontsize = 37; fontConstant = 45; font = loadFont("CourierNewPSMT-37.vlw"); textFont(font,fontsize); //Variable setup boolean buttonsActivited = false; R = 0; G = 0; B = 0; } void draw(){ //Draw the background background(R,G,B); //Display the elements text("RED",5,5+fontConstant); text("GREEN",5,60+fontConstant); text("BLUE",5,115+fontConstant); for (int i=0; i<3; i++){ numberInputArray[i].display(); } //Updates the background only when the keyboard selection is cancelled if ((numberInputArray[0].acceptKeyboard==false)&&(numberInputArray[1].acceptKeyboard==false)&&(numberInputArray[2].acceptKeyboard==false)){ R = 2.55*(numberInputArray[0].return_value()); G = 2.55*(numberInputArray[1].return_value()); B = 2.55*(numberInputArray[2].return_value()); } } void mousePressed(){ //When the mouse is pressed setup the number boxes to be ready for keyboard input for (int i=0; i<3; i++){ numberInputArray[i].activate_keyboardInput(); } }