Guest User

Untitled

a guest
Jul 27th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. var rows = [];
  2. var gridSquareSize = 20;
  3.  
  4. function setup() {
  5. createCanvas(windowWidth, windowHeight);
  6. rectMode(CENTER);
  7. stroke(255);
  8. var amountOfRows = Math.max(windowHeight / gridSquareSize);
  9. var amountOfColumns = Math.max(windowWidth / gridSquareSize);
  10. for (let rowIndex = 0; rowIndex < amountOfRows; rowIndex++) {
  11. for (let colIndex = 0; colIndex < amountOfColumns; colIndex++) {
  12. var hasStroke = random() > 0.8;
  13. if (rowIndex <= colIndex) {
  14. fill(0);
  15. }
  16. else {
  17. fill(255)
  18. }
  19. var x = gridSquareSize * colIndex + gridSquareSize / 2;
  20. var y = gridSquareSize * rowIndex + gridSquareSize / 2;
  21. strokeWeight(hasStroke ? 1 : 0);
  22. rect(x, y, gridSquareSize, gridSquareSize, (colIndex * rowIndex / 100));
  23. }
  24. }
  25. }
Add Comment
Please, Sign In to add comment