// A Cell object public class Cell { // A cell object knows about its location in the grid as well as its size with the variables x, y, w, h. float x, y; // x,y location float w, h; // width and height int border; // stroke used for each cell 255=white to 0=black // Colors specifications for the cell int colorR, colorG, colorB; int colorA; // Opacity // Colors for mouse selection int rON, gON, bON, aON; // Cell Constructor Cell(float tempX, float tempY, float tempW, float tempH, int tempStroke, int tempR, int tempG, int tempB, int tempAlpha ) { // Spatial attributes x = tempX; y = tempY; w = tempW; h = tempH; // Color attributes border = tempStroke; colorR = tempR; colorG = tempG; colorB = tempB; colorA = tempAlpha; rON = 255; gON = 255; bON = 255; aON = 95; } boolean display(float gridMinX, float gridMinY, float gridMaxX, float gridMaxY) { boolean retVal = false; stroke(border); if(checkover(gridMinX, gridMinY, gridMaxX, gridMaxY)) { //fill(rON, gON, bON, colorA); fill(colorR, colorG, colorB, aON); retVal = true; } else { fill(colorR, colorG, colorB, colorA); } rect(x,y,w,h); return retVal; } void updateColor(int R, int G, int B, int A) { colorR = R; colorG = G; colorB = B; colorA = A; } // Returns true if mouse is currently over the cell boolean checkover(float gridMinX, float gridMinY, float gridMaxX, float gridMaxY) { // Mouse is over (current row OR column) AND (within grid limits) if(((mouseX > x && mouseX < x+w) || (mouseY > y && mouseY < y+h) ) && ((mouseX > gridMinX && mouseX < gridMaxX) && (mouseY > gridMinY && mouseY < gridMaxY) ) ) { return true; } return false; } // Returns true if mouse is currently over the cell boolean isSelected(float gridMinX, float gridMinY, float gridMaxX, float gridMaxY) { // Mouse is over (current row AND column) if((mouseX > x && mouseX < x+w) && (mouseY > y && mouseY < y+h) ) { return true; } return false; } }