Processing Forum
new questions below.
boolean animationIsRunning = true; color black = color(#000000); int size = 1000; // width, height int grid = 10; // number of grids int s = 0; // standard index of rect-color color[] cc = new color [3]; color[] colorsave = new color[500]; int[] coorX = new int[grid]; // coordinates of possible random fields int[] coorY = new int[grid]; // coordinates of possible random fields Lottery myLottery = new Lottery(); void setup () { cc[0] = #FF0000; cc[1] = #00FF00; cc[2] = #0000FF; size (size, size); background (black); frameRate(40); myLottery.drawGrids(15); for (int i = 0; i * (size/grid) < size; i++) { coorX[i] = i * (size/grid); coorY[i] = i * (size/grid); } } void draw () { int rando1 = int (random(coorX.length)); // rando = random number from array coor int rando2 = int (random(coorY.length)); noStroke(); tint(0, 0, 255); fill(cc[s], 10); rect(coorX[rando1], coorY[rando2], size/grid, size/grid); if (keyPressed) { if (key == '0') { background(black); } if (key == 'r') { s = 0; } if (key == 'g') { s = 1; } if (key == 'b') { s = 2; } else { s=0; } } } // end draw void mouseReleased() { animationIsRunning = !animationIsRunning; if (animationIsRunning) { loop(); } else { noLoop(); } } class Lottery { void drawGrids(int transparency) { for (int i = 1; i * (size/grid) < size; i++) { if (i * (size/grid) < size) { int x = i * (size/grid); int y = i * (size/grid); // stroke(#FFFFFF, transparency); line (x, 0, x, size); line (0, y, size, y); } // if-condition } // for-loop } // drawGrids } // end lottery