We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexDiscussionExhibition › sinks and fountains
Page Index Toggle Pages: 1
sinks and fountains (Read 947 times)
sinks and fountains
Jan 11th, 2008, 7:47am
 
http://jeremyawon.info/saf/

each pixel is walking through an array of colors, with constant acceleration after an initial speed given by the noise function on (x,y). areas where colors appear look like fountains to me, areas where they disappear like sinks.

Re: sinks and fountains
Reply #1 - Jan 11th, 2008, 8:24pm
 
Another beautiful one.  Now make the points move around!
Re: sinks and fountains
Reply #2 - Jan 12th, 2008, 5:30am
 
notice though that there are no explicitly coded "points", just local peaks and minimas of the noise function.
Re: sinks and fountains
Reply #3 - Mar 30th, 2008, 7:26am
 
Wow, it's amazing!
Nice choice of colors.
I don't know how colors can change everywhere so fast.
I'll have to study your code.

What are the meaning of your parameters? The names are self-explanatory, but I need to know more to assign them appropriate values.

_phaseResolution
_imageDepth
_phaseAcceleration
_edgeThreshold
_edgeAlpha
_colorsAlpha
Re: sinks and fountains
Reply #4 - Mar 30th, 2008, 8:52am
 
Try this modified code, select option 1 or 2 or 3.
---option=1 //with noise
---option=2 //with double image
---option=3 //with noise and double image
Code:
color _edgeColor,
_colors[];

float _edgeAlpha, _colorsAlpha;

int _generation[],
_iteration;

float _image[],
_imageDepth,
_phaseResolution,
_phaseVelocity[],
_phaseDepth,
_phaseAcceleration,
_edgeThreshold;

boolean _returning[];
boolean toggle=true;
int widthheight;

void setup() {
size(800,800);
widthheight=width*height;
//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));
}
else {
_phaseResolution = 3;
}
if(param_imageDepth!=null) {
println("found param_imageDepth "+param_imageDepth);
_imageDepth = max(0,float(param_imageDepth));
}
else {
_imageDepth = 255;
}
if(param_phaseDepth!=null) {
println("found param_phaseDepth "+param_phaseDepth);
_phaseDepth = max(0,float(param_phaseDepth));
}
else {
_phaseDepth = 10;
}
if(param_phaseAcceleration!=null) {
println("found param_phaseAcceleration "+param_phaseAcceleration);
_phaseAcceleration = max(0,float(param_phaseAcceleration));
}
else {
_phaseAcceleration = 0.01;
}
if(param_edgeThreshold!=null) {
println("found param_edgeThreshold "+param_edgeThreshold);
_edgeThreshold = max(0,float(param_edgeThreshold));
}
else {
_edgeThreshold = 50;//0.01
}
if(param_edgeAlpha!=null) {
println("found param_edgeAlpha "+param_edgeAlpha);
_edgeAlpha = max(0,float(param_edgeAlpha));
}
else {
_edgeAlpha = 30;
}
if(param_colorsAlpha!=null) {
println("found param_colorsAlpha "+param_colorsAlpha);
_colorsAlpha = max(0,float(param_colorsAlpha));
}
else {
_colorsAlpha = 50;
}

_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<width;x++) {
for(int y=0;y<height;y++) {
int i = x+(y*width);
_generation[i] = 0;
_image[i] = 0;
_phaseVelocity[i] = noise((x/(float)width)*_phaseResolution, (y/(float)height)*_phaseResolution, r)*_phaseDepth;
_returning[i] = false;
}
}
}

void draw() {
loadPixels();

if((_iteration*_phaseAcceleration)>_phaseDepth) {
reset();
}

for(int i=0;i<width*height;i+=1) {
_image[i] += _phaseVelocity[i];
_phaseVelocity[i] = (_phaseVelocity[i]+_phaseAcceleration);

if(_phaseVelocity[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]];
}
}

//@@@@@.added.@@@@@---------------->>>
int option=3;// <<<@@@@@@@ TRY OPTION 1 OR 2 OR 3 @@@@@@@>>>
if (option==1) {//with noise
for(int i=0;i<widthheight;i+=3) {
pixels[i]=pixels[(int)random(widthheight)];
}
}
else if (option==2) {//with double image
for(int i=0;i<widthheight;i+=2) {
pixels[i] = pixels[widthheight-i-1];
}
}
else if (option==3) {//with noise and double image
toggle=!toggle;
if (toggle) {
for(int i=0;i<widthheight;i+=3) {
pixels[i]=pixels[(int)random(widthheight)];
}
}
else {
for(int i=0;i<widthheight;i+=2) {
pixels[i] = pixels[widthheight-i-1];
}
}
}
//@@@@@.added.@@@@@----------------<<<

updatePixels();

_iteration++;
}
Page Index Toggle Pages: 1