Created
September 13, 2018 02:22
-
-
Save anotherjesse/40facb43e90e5db5ed61651bd9a0db6a to your computer and use it in GitHub Desktop.
a bad approach to using 3d noise to generate looping 2d animated gif
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // this works, but the right side is much more dynamic as it rotates through the space. | |
| // the idea here was taking golan's https://twitter.com/anotherjesse/status/1040007965799997440 or https://editor.p5js.org/full/BJLbRp8dm | |
| // and using the 3d dimension of noise for adding another dimension to noise (I think this works) | |
| // but then modifying the radius of the noise to add a 3rd dimension | |
| let myScale = 0.01, | |
| radius = 100.0, | |
| nSteps = 360, | |
| width = 600, | |
| height = 600, | |
| pixel_size = 1, | |
| myLoopingNoiseArray = []; | |
| // var offscreenImg; | |
| var currStep = 0; | |
| function setup() { | |
| createCanvas(width, height); | |
| pixelDensity(1); | |
| angleMode(RADIANS); | |
| } | |
| function noisy(x, y, theta) { | |
| // (radius*5) is important. if px, py is an offset of 0, it have too much symetry | |
| var px = (radius*5) + (x + radius) * cos(theta); | |
| var py = (radius*5) + (x + radius) * sin(theta); | |
| return noise(myScale * px, myScale * py, myScale * y); | |
| } | |
| function draw() { | |
| currStep = frameCount % nSteps; | |
| // var t = map(mouseX, 0, width, 0, TWO_PI); | |
| var t = map(currStep, 0, nSteps, 0, TWO_PI); | |
| // console.log(t); | |
| var p_min = 255; | |
| var p_max = 0; | |
| noStroke(); | |
| for (var x = 0; x < width/pixel_size; x++) { | |
| for (var y = 0; y < height/pixel_size; y++) { | |
| var n = noisy(x, y, t); | |
| if (n > 0.5) { | |
| var col = 255; | |
| } else { | |
| var col = 0; | |
| } | |
| // var col = map(noisy(x, y), 0.5, 1, 0, 255); | |
| fill(col); | |
| rect(x * pixel_size, y * pixel_size, pixel_size, pixel_size); | |
| } | |
| } | |
| if (frameCount >= nSteps) { | |
| noLoop(); | |
| } | |
| saveCanvas("blob-" + nf(currStep, 3) + ".png"); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment