Advertisement
xeromino

tweak

Jun 9th, 2014
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.12 KB | None | 0 0
  1. int numCol = 10, numRow = 5;
  2. float colSize, rowSize;
  3.  
  4. void setup() {
  5.   size(500, 500);
  6.   background(255);
  7.   frameRate(3);
  8.   colSize = width/numCol;
  9.   rowSize = height/numRow;
  10. }
  11.  
  12. void draw() {
  13.  
  14.   //float randColor1 = random(100, 200); -> not needed since you can simple add random() later in your fill() function?
  15.   //float randColor2 = random(100, 200);  
  16.   //float randColor3 = random(100, 200);
  17.  
  18.   for (int i=0; i<numCol; i++) {
  19.     //fill(random(100, 200), randColor1, randColor3, 100); //why would you want to do this here?
  20.     for (int j=0; j<numRow; j++) {
  21.       fill(random(100, 200), random(50, 150), random(100, 200), 100); //why use you randColors here instead of simply using random()?
  22.       //rect((width/numCol) * i, (height/numRow) *j, (width/numCol) * i, (height/numRow) * j);
  23.       rect(colSize*i, rowSize*j, colSize, rowSize); // the 3rd and 4th argument only need to be the size of one rectangle! your code created huge rectangles (that were hidden by the screen being too small), I think that also explains the offset in some way ... I'm not sure why though ... my rewrite starts at 0,0
  24.     }
  25.   }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement