Skip to content

Instantly share code, notes, and snippets.

@jeffThompson
Created June 13, 2016 01:33
Show Gist options
  • Save jeffThompson/77086e0121076ac73b9f90504340047d to your computer and use it in GitHub Desktop.
Save jeffThompson/77086e0121076ac73b9f90504340047d to your computer and use it in GitHub Desktop.
// the "resolution" of the noise
float inc = 0.008;
// "rate of change" for the noise
float zInc = 0.1;
// min/max values for noise
float hueMin = 0; // hue
float hueMax = 50;
float satMin = 100; // saturation
float satMax = 255;
float brightMin = 200; // brightness
float brightMax = 220;
// keep track of x/y noise position
float hxOff, hyOff, sxOff, syOff, bxOff, byOff;
float zOff = 0;
float h, s, b;
// 'd' key turns on debug
boolean debug = false;
void setup() {
size(1920,1080);
colorMode(HSB, 255);
noiseDetail(4, 0.01);
}
void draw() {
loadPixels();
hxOff = sxOff = bxOff = 0;
for (int x=0; x<width; x++) {
hxOff += inc;
sxOff += inc;
bxOff += inc;
hyOff = syOff = byOff = 0;
for (int y=0; y<height; y++) {
hyOff += inc;
syOff += inc;
byOff += inc;
h = noise(hxOff, hyOff, zOff) * 255;
h = map(h, 0,255, hueMin, hueMax);
s = noise(sxOff, syOff, zOff) * 255;
s = map(s, 0,255, satMin, satMax);
b = noise(bxOff, byOff, zOff) * 255;
b = map(b, 0,255, brightMin, brightMax);
pixels[x + y*width] = color(h, s, b);
}
}
updatePixels();
zOff += zInc;
// if debug mode enabled
if (debug) {
stroke(255);
line(width/2,height/2, 80,height-80);
fill(255);
noStroke();
ellipse(width/2,height/2, 8,8);
h = hue(pixels[pixels.length/2]);
s = saturation(pixels[pixels.length/2]);
b = brightness(pixels[pixels.length/2]);
text(int(h) + ", " + int(s) + ", " + int(b), 30, height-50);
}
println(frameCount);
save("frames/" + nf(frameCount, 4) + ".jpg");
if (frameCount > (1 * 60 * 24)) exit();
}
// 'd' key turns on debug mode
// shows value for center pixel :)
void keyPressed() {
if (key == 'd') debug = !debug;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment