Guest User

Untitled

a guest
Jul 22nd, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. final int SIZE = 120;
  2.  
  3. float angle = 0;
  4. float maxAngle = 0.2;
  5. float dAngle = 0.001;
  6.  
  7. void setup() {
  8. size(600, 600);
  9. rectMode(CENTER);
  10. stroke(0);
  11. strokeWeight(2);
  12. noFill();
  13. }
  14.  
  15. void draw() {
  16. background(255);
  17. int dir = 1;
  18. for (int y = SIZE / 2; y < height; y += SIZE) {
  19. for (float x = SIZE / 2; x < width; x += SIZE) {
  20. drawSquare(x, y, SIZE, angle, dir);
  21. dir = -dir;
  22. }
  23. }
  24. angle += dAngle;
  25. if (angle > maxAngle || angle < 0) {
  26. dAngle = -dAngle;
  27. }
  28. }
  29.  
  30. void drawSquare(float xc, float yc, float size, float angle, int dir) {
  31. pushMatrix();
  32. translate(xc, yc);
  33. float coef = 1 / (sin(angle) + cos(angle));
  34. for (int i = 0; i < 20; i++) {
  35. rect(0, 0, size, size);
  36. size *= coef;
  37. rotate(dir * angle);
  38. }
  39. popMatrix();
  40. }
Add Comment
Please, Sign In to add comment