Guest User

Untitled

a guest
Nov 21st, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. int r = 50;
  2.  
  3. void setup() {
  4. size(600, 600);
  5. }
  6.  
  7. void draw() {
  8. background(-1);
  9. fill(0);
  10.  
  11. for (int i = -1; i <= height/r; i++) {
  12. pushMatrix();
  13. translate(0, i*r);
  14. triangleWave();
  15. popMatrix();
  16. }
  17. }
  18.  
  19. void triangleWave() {
  20. for (int j = 0; j < width; j+=10) {
  21. float x = j;
  22. float angle = 10*PI*j/width;
  23. float y = r*sin(angle + radians(frameCount));
  24.  
  25. triangle(x, y);
  26. }
  27. }
  28.  
  29.  
  30. void triangle(float x, float y) {
  31.  
  32. pushMatrix();
  33. translate(x, y);
  34.  
  35. beginShape();
  36. int side_num = 3;
  37. for (int i = 0; i < side_num; i++) {
  38. float newR = map(abs(y), r, 0, 5, r/3);
  39. float pointX = newR * sin(i*TWO_PI/side_num + PI);
  40. float pointY = newR * cos(i*TWO_PI/side_num + PI);
  41. vertex(pointX, pointY);
  42. }
  43.  
  44. endShape(CLOSE);
  45. popMatrix();
  46. }
Add Comment
Please, Sign In to add comment