/* Viral Cell Drawing Jayne Vidheecharoen 2008 This lets you draw with little viral like cells, that grow over time. */ int numCells = 1000; MovingCell[] cells = new MovingCell [numCells]; int currentCell = 0; void setup() { size (600,400); smooth (); noStroke(); cursor(HAND); frameRate (24); for (int i = 0; i < numCells; i++) { cells [i] = new MovingCell (); } } void draw() { background (255, 229, 244); for (int i = 0; i < currentCell; i++) { // Set the color of the cell, from orange to cyan. if ( i < 200 ) { fill (random(180,223), random(30, 68), random(10, 24), 30); //orange } else if ( i < 300) { fill (random(180,221), random(20, 56), random(70, 96), 30); //magenta } else if ( i < 400) { fill (random(50,69), random(20, 47), random(70, 98), 50); //violet } else if ( i < 500) { fill (random(40,63), random(30, 76), random(120, 150), 50); //blue } else if ( i < 1000) { fill (random(0,10), random(130, 159), random(170, 193), 30); //cyan } cells[i].display(); } } void mouseDragged(){ cells[currentCell].setPosition(mouseX, mouseY, pmouseX, pmouseY); if (currentCell < numCells - 1) { currentCell++; } } class MovingCell { float x1, y1, x2, y2; void setPosition(int x, int y, int px, int py){ x1 = x; y1 = y; x2 = px; y2 = py; } void display () { //this is where to tweak sizes and twitchiness // twitch around at small random increments x1 += random (-2, 2); y1 += random (-2, 2); x2 += random (-0.5, 0.5); y2 += random (-0.5, 0.5); // draw the ellipse ellipse (x1, y1, .25*(x2-x1), .25*(x2-x1)); ellipse (x1, y1, 1.5*(y2-y1), 1.5*(y2-y1)); ellipse (x1, y1, y2-y1, y2-y1); } }