Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// Some polar noise stuff by Stefan Petrick
- //// written in Processing 4, meant to be used with FastLED
- void setup() {
- fullScreen();
- background(0);
- }
- float scale = 15; // global zoom factor
- float c, d, e, time;
- float r;
- int num_x = 32;
- int num_y = 32;
- void draw() {
- time = millis();
- time = time * 8; // global anaimation speed
- c = time / 7000; // timedependant offsets
- d = time / 8000;
- for (int x = 0; x < num_x; x++) {
- for (int y = 0; y < num_y; y++) {
- //top left: DISTANCE from center ----------------------------
- float center_x = 15-sin(c)*4; // move the center somehow
- float center_y = 15-sin(d)*4;
- float xx = x-center_x; // relative distance from center
- float yy = y-center_y;
- float dist = sqrt((xx*xx)+(yy*yy)); // Pythagoras, hypot()
- float show1 = map(dist, 0, 20, 0, 255);
- fill( show1, 0,0 );
- rect( 1+x*7, 1+y*7, 7, 7);
- // top middle: ANGLE of every pixel relative to center-------
- float angle = atan2(yy,xx); // fuck yeah!
- float show2 = map(angle, -PI, PI, 0, 255);
- fill( show2, 0,0 );
- rect( 251+x*7, 1+y*7, 7, 7);
- // top right: mirrored polar reconstuction-------------------
- float newangle = angle/2;
- float newx= (cos(newangle)*dist) / scale;
- float newy= (sin(newangle)*dist) / scale;
- r = noise( newx, newy, c/10);
- float show3 = map(r, 0.4, 0.8, 0, 255);
- fill( show3, 0,0 );
- rect( 501+x*7, 1+y*7, 7, 7);
- // middle left: rotation (manipulate all angles)-------------
- newangle = angle - (c/5);
- newx= (cos(newangle)*dist)/scale;
- newy= (sin(newangle)*dist)/scale;
- r = noise( newx, newy, c/10);
- float show4 = map(r, 0.4, 0.8, 0, 255);
- fill( show4, 0,0 );
- rect( 1+x*7, 251+y*7, 7, 7);
- // middle middle: rotation + scroll --------------------------
- newx= (cos(newangle)*dist)/scale;
- newy= (sin(newangle)*dist)/scale;
- r = noise( newx+c, newy, c/10);
- float show5 = map(r, 0.4, 0.8, 0, 255);
- fill( show5, 0, 0);
- rect( 251+x*7, 251+y*7, 7, 7);
- // middle right: rotation + different scroll-------------------
- newangle = angle - (c/3);
- newx= (cos(newangle)*dist)/scale;
- newy= (sin(newangle)*dist)/scale;
- r = noise( newx, newy+d , c/10);
- float show6 = map(r, 0.4, 0.8, 0, 255);
- fill( show6, 0, 0);
- rect( 501+x*7, 251+y*7, 7, 7);
- // low left: SPIRAL, manipulated angles depending on distance from center------
- newangle = angle + dist/12 - c/3;
- newx= (cos(newangle)*dist) /scale;
- newy= (sin(newangle)*dist) /scale;
- r = noise( newx-d/10, newy+c/10, c/10);
- float show7 = map(r, 0.4, 0.8, 0, 255);
- fill( show7, 0, 0);
- rect( 1+x*7, 501+y*7, 7, 7);
- // low middle: overlay layer 3 + 4 + 7-------------------------------
- float show8 = show7;
- if (show4 > show8) show8= show4;
- if (show3 > show8) show8= show3;
- fill(show8, 0, 0);
- rect( 251+x*7, 501+y*7, 7, 7);
- // low righ: overlay layer 5 & 6--------------------------------------
- float show9 = show5;
- if (show6 > show9) show9= show6;
- fill(show9, 0, 0);
- rect( 501+x*7, 501+y*7, 7, 7);
- }
- }
- updatePixels();
- }
Add Comment
Please, Sign In to add comment