/** NoiseGrid.pde (part of NoiseGrid) Dave Bollinger http://www.davebollinger.com */ /** * a noise grid draws a regular grid of cells with a given renderer */ public class NoiseGrid { PApplet applet; int cols, rows; float noiseXScale, noiseYScale; float noiseXOffset, noiseYOffset; float t, deltat; NoiseGrid(PApplet applet, int rows, int cols) { this.applet = applet; setSize(cols, rows); config(); } public void setSize(int cols, int rows) { this.cols = cols; this.rows = rows; } /** * configure entirely randomly */ public void config() { noiseXScale = random(0.0001, 0.2); noiseYScale = random(0.0001, 0.2); noiseXOffset = random(100f); noiseYOffset = random(100f); t = 0f; deltat = random(0.005,0.03); } /** * configure randomly using the specified seed */ public void config(int seed) { randomSeed(seed); float burnone = random(1f); noiseSeed(seed); config(); } /** * configure manually */ public void config(float xscale, float yscale, float xoffset, float yoffset, float t, float deltat) { noiseXScale = xscale; noiseYScale = yscale; noiseXOffset = xoffset; noiseYOffset = yoffset; this.t = t; this.deltat = deltat; } /** * renders the grid to screen using the specified renderer */ void render(CellRenderer renderer) { if (renderer==null) return; if (!renderer.ready()) return; float screenXScale = (float)(applet.width) / (float)(cols); float screenYScale = (float)(applet.height) / (float)(rows); float screenXOffset = screenXScale / 2f; float screenYOffset = screenYScale / 2f; float screeny = screenYOffset; float noisey = noiseYOffset; for (int row=0; row