Hello, thank you so much for answering. I'll show you more of the code so you are able to enlighten me a little.
Code:
// fonts
PFont titleFont, clearFont;
// canvas background color
color canvasBg = color(255);
// paint color
color paintColor;
// palette
color[]palette = new color[156];
// creating 3 icons
PImage pencil, brush, eraser;
// panels coordinate arrays
float[] menu, tools, canvas;
// buttons coordinate arrays
float[] pencilBtn, brushBtn, eraserBtn;
//creating button state colors
color buttonUp = color(175, 175, 50, 150);
color buttonOver = color(255, 130, 20, 175);
color buttonSelected = color(250, 250, 30, 175);
// setting initial button background colors
color pencilBg = buttonSelected;
color brushBg = buttonUp;
color eraserBg = buttonUp;
// button booleans
boolean isPencilSelected = true;
boolean isBrushSelected = false;
boolean isEraserSelected = false;
// slider
float[] sliderBar, sliderHandle;
boolean isSliderMovable = false;
color sliderHandleUp = color(255, 127, 0);
color sliderHandleOver = color(255, 200, 0);
color sliderHandleBg = sliderHandleUp;
float sliderValue = 0;
//clear button
float[]clearBtn;
color clearBtnOver = color(50, 50, 150);
color clearBtnUp = color(0, 0);
color clearBtnBg = clearBtnUp;
void setup(){
size(600, 400);
background(canvasBg);
frameRate(30);
// creating fonts
titleFont = createFont("Arial", 11);
clearFont = createFont("Arial", 10);
// creating icons
pencil = loadImage("pencil_cursor.png");
brush = loadImage("brush_cursor.png");
eraser = loadImage("eraser_cursor.png");
// creating panel coordinate arrays
menu = new float[]{
0, 0, width, 25 };
tools = new float[]{
0, menu[3], 50, 165 };
canvas = new float[]{
tools[2], menu[3], width-tools[2], height-menu[3]+1 };
// creating button coordinate arrays
pencilBtn = new float[]{
tools[0]+5, tools[1]+10, tools[2]-11, 45 };
brushBtn = new float[]{
tools[0]+5, pencilBtn[1]+ pencilBtn[3]+5, tools[2]-11, 45 };
eraserBtn = new float[]{
tools[0]+5, brushBtn[1]+ brushBtn[3]+5, tools[2]-11, 45 };
// creating slider coordinate arrays
sliderBar = new float[]{
width-150, menu[1]+menu[3]/2, 75, menu[1]+menu[3]/2 };
sliderHandle = new float[]{
sliderBar[0]+sliderBar[2]/2, sliderBar[1]-3, 6, 6 };
// creating clear button coordinate array
clearBtn = new float[]{
width-45, 6, 31, 13 };
//temporarily setting colorMode to HSB
colorMode(HSB, 6, 26, 26);
//constructing palette values
int paletteCounter = 0;
for (int j=0; j<6; j++){
for (int i=palette.length/6; i>0; i--){
if (i>13){
palette[paletteCounter] = color(random(6), random(26)+5, random(26)+5);
}
if (i<=13){
palette[paletteCounter] = color(j, i*2, i*4);
}
paletteCounter++;
}
}
//setting initial color
paintColor = palette[23];
//resetting colorMode to RGB
colorMode(RGB, 256, 256, 256);
}
Here is the first half of the program including the setup function. I hope this can help better to understand. Thank you for all your help.