import processing.opengl.*; /** * Anemone Sketch - Thomas W. Gonzalez

* * Keys:

* * LEFT MOUSE = Generate new Anemone
* "space" = Clear current Frame
* "r" = add red to current growth
* "g" = add green to current growth
* "b" = add blue to current growth
* "i" = increase spine length (next spawn cycle)
* "d" = decrease spine length (next spawn cycle)


* * Note: either hold keys down or press repeatedlly for cumulative effects */ // Copyright (c) 2008 Thomas W. Gonzalez // // Warning - this source code is a mess and poorly factored // no attempt has been made to clearly comment or structure this for others. // This source code is released so others can potentially learn from it, like I have done with so many other // peoples source. // This code is released under an MIT license which is described below // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. boolean clearTrail=true; float gravity=0; float lastAdded=0; float maxRadius=80; int redOffset=0; int greenOffset=0; int blueOffset=0; char mode='a'; ArrayList systems; int dur=1000; float accFactor=.2; int maxLifetime=250; color c; void setup() { size(800,800); frameRate(30); colorMode(RGB,255,255,255,100); background(255); systems=new ArrayList(); noStroke(); smooth(); c=color(int(random(0,255)),int(random(0,255)),int(random(0,255))); ParticleSystem ps= new ParticleSystem(100,new Vector3D(random(0,width),random(0,height),0),c,0,accFactor); systems.add(ps); } void draw() { //Run current systems for (int i=systems.size()-1;i>-1;i--) { ParticleSystem ps = (ParticleSystem) systems.get(i); if (ps.dead()==true) { systems.remove(ps); } else { ps.run(); } } } void mousePressed() { if (mouseButton==RIGHT) return; c=color(int(random(0,255)),int(random(0,255)),int(random(0,255))); ParticleSystem ps= new ParticleSystem(100,new Vector3D(mouseX,mouseY,0),c,0,accFactor); systems.add(ps); } void keyPressed() { if (key=='c' || key=='C') { fill(255,255); rect(0,0,width,height); } if (key=='r' || key=='R') { redOffset=redOffset+10; if (redOffset > 255) redOffset=255; } else { redOffset=0; } if (key=='g' || key=='G') { greenOffset=greenOffset+10; if (greenOffset>255) greenOffset=255; } else { greenOffset=0; } if (key=='b' || key=='B') { if (key=='b') { blueOffset=blueOffset+10; if (blueOffset>255) blueOffset=255; } else if (key=='B') { blueOffset=blueOffset-10; if (blueOffset<-255) blueOffset=-255; } } else { blueOffset=0; } if (key=='i' || key=='I') { maxLifetime+=5; } if (key=='d' || key=='D') { maxLifetime-=5; } if (maxLifetime < 50) maxLifetime=50; if (maxLifetime > 1000) maxLifetime=1000; if (key==' ') { background(255); } }