Guest User

Untitled

a guest
Jun 8th, 2020
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. float t = 0;
  2.  
  3. float radius;
  4. int count;
  5. int levels = 7;
  6. PVector center;
  7.  
  8.  
  9. void setup() {
  10. size(1080, 1080);
  11. result = new int[width*height][3];
  12.  
  13. PFont font = createFont("Nunito-Regular.ttf", 30);
  14. textFont(font);
  15.  
  16. center = new PVector(width/2+radius/pow(2, levels), height/2);
  17. }
  18.  
  19. void draw() {
  20. background(#76E9FF);
  21. count = 0;
  22.  
  23. t = map(frameCount, 1, 1440, 0, 1);
  24.  
  25. radius = map(cos(TAU*t)/2+0.5, 0, 1, 1000, 10000);
  26.  
  27. push();
  28. translate(width/2, height/2);
  29. rotate(TAU*t*2);
  30. guide(radius, levels);
  31. pop();
  32.  
  33. push();
  34. translate(width-center.x, height-center.y);
  35. rotate(TAU*t*2);
  36.  
  37. yinYang(radius, levels);
  38.  
  39.  
  40.  
  41. pop();
  42.  
  43. noStroke();
  44. fill(0, 150);
  45. rect(width-290, height-40, 290, 40, 20);
  46. fill(240);
  47. strokeWeight(1);
  48. text("@URBANOXYGEN_", width-285, height-10);
  49. }
  50.  
  51. void yinYang(float radius, int n) {
  52. noStroke();
  53. fill(0);
  54. arc(0, 0, radius, radius, 0, PI);
  55. fill(255);
  56. arc(0, 0, radius, radius, PI, TAU);
  57. if(n==1) {
  58. fill(0);
  59. ellipse(-radius/4, 0, radius/2, radius/2);
  60. fill(255);
  61. ellipse(radius/4, 0, radius/2, radius/2);
  62.  
  63. ellipse(-radius/4, 0, radius/4, radius/4);
  64.  
  65. fill(0);
  66. ellipse(radius/4, 0, radius/4, radius/4);
  67. } else {
  68. push();
  69. translate(radius/4, 0);
  70. rotate(TAU*t*2);
  71. yinYang(radius/2, n-1);
  72. pop();
  73.  
  74. push();
  75. translate(-radius/4, 0);
  76. rotate(TAU*t*2);
  77. yinYang(radius/2, n-1);
  78. pop();
  79. }
  80. }
  81.  
  82. void guide(float radius, int n) {
  83. count++;
  84.  
  85. if (n==1) {
  86. if (count==pow(2, levels-1)) {
  87. center.set(screenX(0, 0), screenY(0, 0));
  88. }
  89. } else {
  90. push();
  91. translate(radius/4, 0);
  92. rotate(TAU*t*2);
  93. guide(radius/2, n-1);
  94. pop();
  95.  
  96. push();
  97. translate(-radius/4, 0);
  98. rotate(TAU*t*2);
  99. guide(radius/2, n-1);
  100. pop();
  101. }
  102. }
Add Comment
Please, Sign In to add comment