/** * sinks and fountains, * jeremyawon.info * jeremy awon, (c) all rights reserved. **/ color _edgeColor, _colors[]; float _edgeAlpha, _colorsAlpha; int _generation[], _iteration; float _image[], _imageDepth, _phaseResolution, _phaseVelocity[], _phaseDepth, _phaseAcceleration, _edgeThreshold; boolean _returning[]; void setup() { size(600,600); //colorMode(HSB, 255); println("sinks and fountains - created by jeremy awon, jeremyawon.info, contact@jeremyawon.info, jeremy.awon@gmail.com"); initalize(); reset(); } void mousePressed() { reset(); } void initalize() { _phaseResolution = 3; _imageDepth = 255; // initially image depth was gray scale pixel color _phaseDepth = 10; _phaseAcceleration = 0.001; _edgeThreshold = 50; _edgeAlpha = 30; _colorsAlpha = 50; String param_phaseResolution = param("phaseResolution"); String param_imageDepth = param("imageDepth"); String param_phaseDepth = param("phaseDepth"); String param_phaseAcceleration = param("phaseAcceleration"); String param_edgeThreshold = param("edgeThreshold"); String param_edgeAlpha = param("edgeAlpha"); String param_colorsAlpha = param("colorsAlpha"); if(param_phaseResolution!=null) { println("found param_phaseResolution "+param_phaseResolution); _phaseResolution = max(0,float(param_phaseResolution)); } if(param_imageDepth!=null) { println("found param_imageDepth "+param_imageDepth); _imageDepth = max(0,float(param_imageDepth)); } if(param_phaseDepth!=null) { println("found param_phaseDepth "+param_phaseDepth); _phaseDepth = max(0,float(param_phaseDepth)); } if(param_phaseAcceleration!=null) { println("found param_phaseAcceleration "+param_phaseAcceleration); _phaseAcceleration = max(0,float(param_phaseAcceleration)); } if(param_edgeThreshold!=null) { println("found param_edgeThreshold "+param_edgeThreshold); _edgeThreshold = max(0,float(param_edgeThreshold)); } if(param_edgeAlpha!=null) { println("found param_edgeAlpha "+param_edgeAlpha); _edgeAlpha = max(0,float(param_edgeAlpha)); } if(param_colorsAlpha!=null) { println("found param_colorsAlpha "+param_colorsAlpha); _colorsAlpha = max(0,float(param_colorsAlpha)); } _colors = new color[100]; _image = new float[width*height]; _generation = new int[width*height]; _phaseVelocity = new float[width*height]; _returning = new boolean[width*height]; _edgeColor = color(0,0,0,_edgeAlpha); } void reset() { _iteration = 0; //colorMode(HSB, 255); for(int i=01;i<_colors.length;i++) { _colors[i] = color(random(100,255),random(100,255),random(100,255),_colorsAlpha); //_colors[i] = color(random(0,255),100,200,_colorsAlpha); } float r = random(0,100); for(int x=0;x_phaseDepth) { reset(); } for(int i=0;i_phaseDepth) { _phaseVelocity[i] = _phaseVelocity[i]%_phaseDepth; _returning[i] = true; } if(_image[i]>_imageDepth) { _generation[i] += 1; _generation[i] %= _colors.length; _image[i] = _image[i]%_imageDepth; } if((_image[i]<_edgeThreshold)&&(!_returning[i])) { pixels[i] = _edgeColor; } else { pixels[i] = _colors[_generation[i]]; } } updatePixels(); _iteration++; }