Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //// The never ending quest for better LED animations
- ////
- //// Today: Some complex noise shifting and overlaying by Stefan Petrick 2022
- //// written in Processing 4, meant to be used with FastLED
- void setup() {
- size(600, 600);
- background(0);
- }
- float scale = 200; // the zoom factor for the layers
- float scale2 = 100;
- float c, d, time;
- float shift1, shift2;
- float r, g, b;
- void draw() {
- time = millis(); // lets have the animation speed independent from the framerate
- time = time / 2; // global speed setting, could also be time*3 or anything
- c = time / 3000; // speeds of the linear scrollings relative to global speed
- d = time / 4000;
- for (int i = 0; i < 400; i++) {
- for (int j = 0; j < 400; j++) {
- shift1 = (g-127)/100;
- shift2 = (r-127)/500;
- r = noise( (i)/scale , (j/scale) + c ); // just a linear scrolling along y
- // please note that we use 2 dimensional noise only
- r = map(r, 0.3, 0.8, 0, 255); // increase contrast by constraining and magnifying a value range
- // it works like histogram manipulation which sets a black
- // and a white value, everything smaller or bigger "bleeds out"
- g = noise( (i/scale/2) + shift2 , (j/scale/2) + d ); // x wobble and y linear scrolling, different zoom level than layer r
- g = map(g, 0.2, 0.7, 0, 255);
- b = noise( (i/scale2) + shift1, (j/scale2) + shift2 ); // x and y wobble
- b = map(b, 0.3, 0.7, 0, 255);
- color c = color( (b*r) / 255, b-g, (b-r) * g/255 ); // some modulation & delta stuff to make it more interesting
- set(i+100, j+100, c ); // done!
- if ((i%20==0) && (j==399)) { // show a horizontal line of values as rectangles
- fill((b*r)/255, b-g, (b-r)*g/255);
- rect (i+100, 520, 18, 18, 5);
- }
- if ((i==0) && (j%20==0)) { // same vertical
- fill((b*r)/255, b-g, (b-r)*g/255);
- rect (60, j+100, 18, 18, 5);
- }
- }
- }
- updatePixels();
- }
Advertisement
Comments
-
- I am not sure, is Arduino IDE able to upload this to Arduino uno, ESP-32, Raspberry pi?
Add Comment
Please, Sign In to add comment