Guest User

Untitled

a guest
Feb 28th, 2023
289
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.80 KB | None | 1 0
  1. /// Some polar noise stuff by Stefan Petrick
  2. //// written in Processing 4, meant to be used with FastLED
  3.  
  4. void setup() {
  5. fullScreen();
  6. background(0);
  7. }
  8.  
  9. float scale = 15; // global zoom factor
  10. float c, d, e, time;
  11. float r;
  12.  
  13. int num_x = 32;
  14. int num_y = 32;
  15.  
  16. void draw() {
  17.  
  18. time = millis();
  19. time = time * 8; // global anaimation speed
  20.  
  21. c = time / 7000; // timedependant offsets
  22. d = time / 8000;
  23.  
  24. for (int x = 0; x < num_x; x++) {
  25. for (int y = 0; y < num_y; y++) {
  26.  
  27. //top left: DISTANCE from center ----------------------------
  28.  
  29. float center_x = 15-sin(c)*4; // move the center somehow
  30. float center_y = 15-sin(d)*4;
  31.  
  32. float xx = x-center_x; // relative distance from center
  33. float yy = y-center_y;
  34.  
  35. float dist = sqrt((xx*xx)+(yy*yy)); // Pythagoras, hypot()
  36. float show1 = map(dist, 0, 20, 0, 255);
  37.  
  38. fill( show1, 0,0 );
  39. rect( 1+x*7, 1+y*7, 7, 7);
  40.  
  41.  
  42. // top middle: ANGLE of every pixel relative to center-------
  43.  
  44. float angle = atan2(yy,xx); // fuck yeah!
  45. float show2 = map(angle, -PI, PI, 0, 255);
  46.  
  47. fill( show2, 0,0 );
  48. rect( 251+x*7, 1+y*7, 7, 7);
  49.  
  50.  
  51. // top right: mirrored polar reconstuction-------------------
  52.  
  53. float newangle = angle/2;
  54.  
  55. float newx= (cos(newangle)*dist) / scale;
  56. float newy= (sin(newangle)*dist) / scale;
  57.  
  58. r = noise( newx, newy, c/10);
  59. float show3 = map(r, 0.4, 0.8, 0, 255);
  60.  
  61. fill( show3, 0,0 );
  62. rect( 501+x*7, 1+y*7, 7, 7);
  63.  
  64.  
  65. // middle left: rotation (manipulate all angles)-------------
  66.  
  67. newangle = angle - (c/5);
  68.  
  69. newx= (cos(newangle)*dist)/scale;
  70. newy= (sin(newangle)*dist)/scale;
  71.  
  72. r = noise( newx, newy, c/10);
  73. float show4 = map(r, 0.4, 0.8, 0, 255);
  74.  
  75. fill( show4, 0,0 );
  76. rect( 1+x*7, 251+y*7, 7, 7);
  77.  
  78.  
  79. // middle middle: rotation + scroll --------------------------
  80.  
  81. newx= (cos(newangle)*dist)/scale;
  82. newy= (sin(newangle)*dist)/scale;
  83.  
  84. r = noise( newx+c, newy, c/10);
  85. float show5 = map(r, 0.4, 0.8, 0, 255);
  86.  
  87. fill( show5, 0, 0);
  88. rect( 251+x*7, 251+y*7, 7, 7);
  89.  
  90. // middle right: rotation + different scroll-------------------
  91.  
  92. newangle = angle - (c/3);
  93. newx= (cos(newangle)*dist)/scale;
  94. newy= (sin(newangle)*dist)/scale;
  95.  
  96. r = noise( newx, newy+d , c/10);
  97. float show6 = map(r, 0.4, 0.8, 0, 255);
  98.  
  99. fill( show6, 0, 0);
  100. rect( 501+x*7, 251+y*7, 7, 7);
  101.  
  102.  
  103. // low left: SPIRAL, manipulated angles depending on distance from center------
  104.  
  105. newangle = angle + dist/12 - c/3;
  106. newx= (cos(newangle)*dist) /scale;
  107. newy= (sin(newangle)*dist) /scale;
  108.  
  109. r = noise( newx-d/10, newy+c/10, c/10);
  110. float show7 = map(r, 0.4, 0.8, 0, 255);
  111.  
  112. fill( show7, 0, 0);
  113. rect( 1+x*7, 501+y*7, 7, 7);
  114.  
  115.  
  116. // low middle: overlay layer 3 + 4 + 7-------------------------------
  117.  
  118. float show8 = show7;
  119. if (show4 > show8) show8= show4;
  120. if (show3 > show8) show8= show3;
  121.  
  122. fill(show8, 0, 0);
  123. rect( 251+x*7, 501+y*7, 7, 7);
  124.  
  125.  
  126. // low righ: overlay layer 5 & 6--------------------------------------
  127.  
  128. float show9 = show5;
  129. if (show6 > show9) show9= show6;
  130.  
  131. fill(show9, 0, 0);
  132. rect( 501+x*7, 501+y*7, 7, 7);
  133.  
  134. }
  135. }
  136. updatePixels();
  137. }
Add Comment
Please, Sign In to add comment