class LightBulb { //---------------------------- // variables int[] colorChoices = { #E80000, #E10CED, #2133EA, #04AF35, #FCE405, #FC5405 }; int blinkInterval = 20; int birthFrame; int baseX; int baseY; float angle; int bulbWidth; int bulbHeight; int bulbColor; //---------------------------- LightBulb(float _baseX, float _baseY, float _angle) { birthFrame = frameCount; baseX = (int)_baseX; baseY = (int)_baseY; angle = _angle; bulbWidth = 4; bulbHeight = 10; bulbColor = colorChoices[(int)random(colorChoices.length)]; } //---------------------------- void draw() { stroke(0); pushMatrix(); translate(baseX, baseY); rotate(angle); translate(-baseX, -baseY); // draw the bulb if (((birthFrame + frameCount)/blinkInterval)%2 == 0) fill(bulbColor); else fill(bulbColor, 50); ellipse(baseX, baseY - bulbHeight*3/4, bulbWidth, bulbHeight); // draw the base fill(#797979); rect(baseX - bulbWidth/4, baseY - bulbHeight/4, bulbWidth/2, bulbHeight/4); popMatrix(); } }