Skip to content

Instantly share code, notes, and snippets.

@radiodario
Created September 12, 2014 18:23
Show Gist options
  • Save radiodario/0b038299cd641b0b0ab0 to your computer and use it in GitHub Desktop.
Save radiodario/0b038299cd641b0b0ab0 to your computer and use it in GitHub Desktop.
enter the noise
double[] map;
int charwidth = 20;
int cellW, cellH;
float xSpeed = 0.005;
float ySpeed = 0.005;
float step = 0.10;
float xOffset = 0;
float yOffset = 0;
float xPos = 0;
float yPos = 0;
void setup() {
size(1024,768, P3D);
colorMode(HSB, 255, 255, 255);
cellW = width/charwidth;
cellH = cellW;
map = new double[cellW*cellH];
}
void update() {
step = 0.5 * sin((TWO_PI * frameCount)/(60*frameRate));
xPos = xOffset;
yPos = yOffset;
for (int i = 0; i < map.length; i++) {
map[i] = noise(xPos, yPos);
// if we jump a row, add one step to yPos
// but bring back xPos to what it was.
if ((i % cellW) == 0) {
yPos += step;
xPos -= step * cellW;
}
xPos += step;
}
xOffset += xSpeed;
yOffset += ySpeed;
}
void draw() {
// background(255);
fill(20, 50);
noStroke();
rect(0, 0, width, height);
update();
translate(charwidth/2, charwidth/2);
for (int i = 0; i < map.length; i++) {
pushMatrix();
translate((i % cellW) * charwidth, floor(i / cellH) * charwidth);
strokeWeight(charwidth/2);
rotate((int) (2*PI/map[i]));
beginShape();
float factor = 1;//(float) map[i];
stroke((int) (map[i]*255), 255, 255, 150);
if (map[i] >= 0.5) {
vertex(-charwidth * factor, -charwidth * factor, charwidth * (float) map[i]);
vertex(charwidth * factor, charwidth * factor, charwidth * (float) map[i]);
} else {
vertex(-charwidth * factor, charwidth * factor, charwidth * (float) map[i]);
vertex(charwidth * factor, -charwidth * factor, charwidth * (float) map[i]);
}
endShape();
popMatrix();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment