/** Noise Grid Applet Dave Bollinger http://www.davebollinger.com click to advance pattern, or wait for auto-advance */ import processing.opengl.*; NoiseGrid grid; CellRenderer renderer; ArrayList transforms; ArrayList shapes; color bgColor, fgColor; int seed = 0; int inactivityTimer; int INACTIVITY_TIMEOUT = 90; void setup() { size(500,500,OPENGL); frameRate(30); smooth(); rectMode(CENTER); ellipseMode(CENTER); grid = new NoiseGrid(this, 0, 0); // we'll set size later renderer = new CellRenderer(this); transforms = new ArrayList(); //transforms.add(new BaseTransform(this)); transforms.add(new TranslateTransform(this)); transforms.add(new RotateTransform(this)); transforms.add(new ScaleTransform(this)); transforms.add(new RotateScaleTransform(this)); transforms.add(new TranslateRotateTransform(this)); transforms.add(new TranslateScaleTransform(this)); transforms.add(new TranslateRotateScaleTransform(this)); shapes = new ArrayList(); //shapes.add(new BaseShape(this)); shapes.add(new TriangleShape(this)); shapes.add(new WideTriangleShape(this)); shapes.add(new TallTriangleShape(this)); shapes.add(new RectangleShape(this)); shapes.add(new WideRectangleShape(this)); shapes.add(new TallRectangleShape(this)); shapes.add(new PentagonShape(this)); shapes.add(new WidePentagonShape(this)); shapes.add(new TallPentagonShape(this)); shapes.add(new HexagonShape(this)); shapes.add(new WideHexagonShape(this)); shapes.add(new TallHexagonShape(this)); shapes.add(new EllipseShape(this)); shapes.add(new WideEllipseShape(this)); shapes.add(new TallEllipseShape(this)); shapes.add(new Star3Shape(this)); shapes.add(new Star4Shape(this)); shapes.add(new Star5Shape(this)); shapes.add(new Star6Shape(this)); shapes.add(new EllShape(this)); shapes.add(new TeeShape(this)); shapes.add(new ZeeShape(this)); config(); } void config() { // take 7 transforms... // times 22 shapes... // times 900 grid sizes.. // times millions of noise parameter values.. // times 2 color modes.. // times 4 fill/stroke modes.. // times about a dozen stroke weights (assuming your card will render 4X oversampled strokes).. // times many noise-frame-advances per pattern.. // equals a lot of possible images! :D // (of course some are admittedly more/less interesting than others) // configure noise parameters //grid.config(seed++); // use a specific seed sequence? grid.config(hour()+minute()+second()+millis()); // no, time, so different each time run // configure grid size grid.setSize((int)(random(15,45)), (int)(random(15,45))); // configure renderer, transform and shape int tidx = (int)(random(transforms.size())); int sidx = (int)(random(shapes.size())); renderer.config( (BaseTransform)transforms.get(tidx), (BaseShape)shapes.get(sidx) ); // configure colors, fill, stroke boolean blackonwhite = random(1f) > 0.5f; bgColor = (blackonwhite) ? color(255) : color(0); fgColor = (blackonwhite) ? color(0) : color(255); int fillstroke = (int)(random(4f)); switch(fillstroke) { case 0 : fill(fgColor); noStroke(); break; case 1 : noFill(); stroke(fgColor); break; case 2 : fill(fgColor); stroke(bgColor); break; case 3 : fill(bgColor); stroke(fgColor); break; } strokeWeight(random(0.25,3f)); // reset inactivity timer inactivityTimer = 0; } void draw() { background(bgColor); grid.render(renderer); grid.advance(); if (++inactivityTimer > INACTIVITY_TIMEOUT) config(); } void mousePressed() { config(); }