Skip to content

Instantly share code, notes, and snippets.

@KrabCode
Created April 22, 2024 12:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KrabCode/c1777f15781b5135a5f7e796161bf72a to your computer and use it in GitHub Desktop.
Save KrabCode/c1777f15781b5135a5f7e796161bf72a to your computer and use it in GitHub Desktop.
import com.krab.lazy.*;
LazyGui gui;
PGraphics noiseOverlay;
void setup() {
size(800, 800, P2D);
gui = new LazyGui(this, new LazyGuiSettings()
.setLoadLatestSaveOnStartup(true)
);
colorMode(HSB, 1, 1, 1, 1);
noiseOverlay = createGraphics(width, height, P2D);
}
void draw() {
background(gui.colorPicker("debug bg", color(0, 0.5, 1)).hex);
gui.pushFolder("layers");
int layerCount = gui.sliderInt("count", 8);
gui.gradient("gradient");
float marginX = 100;
float startY = gui.slider("start y", 0);
float endY = gui.slider("end y", height);
float startX = gui.slider("start x", marginX);
float endX = gui.slider("end x", width-marginX);
float stepX = gui.slider("step x", 20, 1, 1000);
float layerHeight = gui.slider("height", 500);
float noiseFreqX = gui.slider("noise freq x", 0.1);
float noiseFreqY = gui.slider("noise freq y", 0.1);
float noiseAmp = gui.slider("noise amp", 20);
float distAmpNorm = gui.slider("dist amp norm", 1);
stroke(gui.colorPicker("stroke", color(0.5)).hex);
if (gui.toggle("no stroke")) {
noStroke();
}
for (int layerIndex = 0; layerIndex < layerCount; layerIndex++) {
float layerNorm = norm(layerIndex, 0, layerCount-1);
int fill = gui.gradientColorAt("gradient", layerNorm).hex;
float baseY = lerp(startY, endY, layerNorm);
pushMatrix();
translate(0, baseY);
fill(fill);
// rect(-marginX, y, width + marginX, layerHeight);
beginShape(TRIANGLE_STRIP);
for (float x = startX; x < endX; x+= stepX) {
float xNorm = norm(x, startX, endX);
float y = (distAmpNorm * layerNorm * noiseAmp) * (-1+2*noise(xNorm * noiseFreqX + layerNorm * noiseFreqY));
vertex(x, y);
vertex(x, layerHeight);
}
endShape();
popMatrix();
}
gui.popFolder();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment