// mouseX to change octaves / details // mouseY to change falloff // key s to save frame (not in web version) // key 0,1,...,7 to change mode // left button to zoom out // right button to zoom in float ndf = 0.65; // noise details fallof int oct = 4; // octaves float step = 0.01; // step int MODE = 0; void setup() { size(400,400); smooth(); } void draw(){ oct = (int) abs((mouseX / 50) + 1); ndf = mouseY / (float)height; float col = mouseX / (float)width; colorMode(RGB, 255); for (int i=0; i < width; i++) { for (int j=0; j < height; j++) { noiseDetail(oct,ndf); float nv1 = noise(i*step,j*step); float nv2 = noise(i*step/3,j*step/3); float nv3 = noise(i*step/5,j*step/5); if (MODE == 0) stroke(nv1*255,nv1*255,nv1*255); if (MODE == 1) stroke(nv1*255,nv2*255,nv3*255); if (MODE == 2) stroke(nv1*255%32*2+200, nv2*255%16*4+150, nv3*255%32*4+100); if (MODE == 3) { colorMode(HSB,1); stroke(nv1,0,nv2%.1*10); } if (MODE == 4) { colorMode(HSB,1); stroke(nv1,1,nv2%.2*5); } if (MODE == 5) { colorMode(HSB,1); stroke(0,0,(float)round(nv1*10)/10); } if (MODE == 6) { colorMode(HSB,1); stroke(0,0,nv1*nv1*nv1*nv1); } if (MODE == 7) { colorMode(HSB,1); stroke((float)round(nv1*10)/10,(float)round(nv2*10)/10,(float)round(nv1*10)/10); } point(i,j); } } } void mousePressed() { if (mouseButton == LEFT) { step += 0.001; } else if (mouseButton == RIGHT) { step -= 0.001; } if (step < 0.00001) step = 0.00001; } void keyPressed() { if (key == 's' || key == 'S') saveFrame("perlin_noise_" + millis() + ".tif"); if (key == '0') MODE = 0; if (key == '1') MODE = 1; if (key == '2') MODE = 2; if (key == '3') MODE = 3; if (key == '4') MODE = 4; if (key == '5') MODE = 5; if (key == '6') MODE = 6; if (key == '7') MODE = 7; }