/* Paranoids * By Jacob Joaquin * * jacobjoaquin@gmail.com * Thumbuki http://www.thumbuki.com/ * * Copyright (C) 2008 Jacob Joaquin * License: GNU LESSER GENERAL PUBLIC LICENSE * http://www.gnu.org/licenses/lgpl.txt * * * Tested with Processing 0135 Beta. */ color[] palette = new color[5]; void setup() { size(800, 600); smooth(); noLoop(); palette[0] = #ff0000; palette[1] = #ff8888; palette[2] = #ff8800; palette[3] = #ff0088; palette[4] = #880000; } void draw() { background(0); generateParanoid(width / 2, height / 2, 3, 30, 0.1, 0, PI, 40); } void mousePressed() { redraw(); } void generateParanoid(float x, float y, float min, float max, float odds, float lastAngle, float spread, int nLimbs) { float angle = ((random(1) - 0.5) * spread) + lastAngle; float length = (random(1) * (max - min) + min); float x1 = (cos(angle) * length) + x; float y1 = (sin(angle) * length) + y; color c1 = palette[(int) random(5)]; color c2 = palette[(int) random(5)]; stroke(c1, 180); fill(c2, 180); float eh = random(min); float ev = random(max); ellipse((x1 + x) * 0.5, (y1 + y) * 0.5, eh, ev); ellipse((x1 + x) * 0.5, (y1 + y) * 0.5, length * 0.5, length * 0.5); ellipse(width - (x1 + x) * 0.5, (y1 + y) * 0.5, eh, ev); ellipse(width - (x1 + x) * 0.5, (y1 + y) * 0.5, length * 0.5, length * 0.5); if (nLimbs >= 1) { generateParanoid(x1, y1, min, max, odds, angle, spread, nLimbs - 1); if (random(1) < odds) { generateParanoid(x1, y1, min, max, odds, angle, spread, nLimbs - 1); } } }