xxxxxxxxxx
void setup() {
size(500, 500);
noiseDetail(5, 0.4);
}
seed = 0;
zoom = 100;
xoff = 0;
yoff = 0;
camSpeed = 10;
void draw() {
background(noise(xoff / zoom, yoff / zoom));
for (int x; x < width; x += 5) {
for (int y; y < height; y += 5) {
cell(x, y)
}
}
noiseDetail(10, 1.2/PI);
fill(255);
textAlign(CENTER, BOTTOM);
textSize(32);
text('Seed: ' + String(seed), width / 2, height - 15);
textSize(15);
text('WASD to move, arrow keys to change seed, and r to reset position', width / 2, height - 2);
if (keyPressed) {
if (key == 'w') {
yoff -= camSpeed;
}
if (key == 's') {
yoff += camSpeed;
}
if (key == 'a') {
xoff -= camSpeed;
}
if (key == 'd') {
xoff += camSpeed;
}
if (key == 'r') {
xoff = 0;
yoff = 0;
}
}
}
void keyPressed() {
if (keyCode == UP) {
seed += 1;
}
if (keyCode == DOWN) {
seed -= 1;
}
}
void cell(int _xPos, int _yPos) {
xPos = _xPos + xoff;
yPos = _yPos + yoff;
noStroke();
noiseSeed(seed);
float noiseVal = noise(xPos / zoom, yPos / zoom)
fill(noiseVal * mouseX - 50, (noiseVal * 255) - 50, noiseVal * mouseY - 50);
rect(_xPos, _yPos, 10, 10);
fill(noiseVal * mouseX, (noiseVal * 255), noiseVal * mouseY);
rect(_xPos, _yPos, 11 * noiseVal, 11 * noiseVal);
}