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.
Page Index Toggle Pages: 1
Grow Snowflake (Read 752 times)
Grow Snowflake
Feb 8th, 2007, 2:09am
 
I will explain what I am planning to achieve.

Basically, I am studying ice formation as a system.
The snow starts as a single point and branches into 6arms. The lengths of the arms relate directly to the temperature.
So if the temperature is 0' as in the center point of the concentric circle the arms will be of a length X.

The 6 ends of the 1st snow flake will act as the point for growth of the next 6 snowflakes, each growing 5 arms ( the 6th being the previous snowflake arm). If the growth "point" of the 2nd snowflake lies in a freezing temperature environment, the arms will be of a length Y (shorter)
And this is how it will progress....

What I am planning to do in processing is to put an underlying image(of a temperature gradient, in grayscale - for simplicity) , then locate an arbitary point on the image, which would return a pixel value(0-255). If the pixel value lies in a particular temperature range, it has to draw 6 arms of a particular lenght tht we assign to tht pixel value.
From there it will grow another 6 snowflakes at the tips of the arms of the 1st snowflake. These points will again return a pixel value, and similarly it should draw subsequent 5 arms( the 6th being the previous arm)............

In the processing file im attaching, I have only managed to get an arbitary pixel value  ex:  temp: -2631721
( though its a negative value and dosent range from 0-255 - which we need to fix )

The source code is as below : but all that it returns is some vague value.


********I would highly appreciate if someone could help me out,its been a month and I have not managed anything********



SOURCE CODE :

SnowFlake test = new SnowFlake ((new Vector3D (450,450)),60,60);


void setup()

{
 size(500,500);
 PImage b;
 b = loadImage("temper.jpg");
 image(b, 0, 0);
 translate(width/2,height/2);
 stroke(255);

}




void draw() {
 noLoop();
 frameRate(30);
 stroke(255);

 translate(width/2,height/2);
 test.get_temperature();

 //line(0,0,0,-20);



}
class SnowFlake{
 
float s_angle;
float  s_temp;
Vector3D s_position;


//contstructor
SnowFlake (Vector3D in_position,float in_angle,float in_temp)
{
 s_angle = in_angle;
 s_temp = in_temp;
 s_position = in_position;
 
 
 //behaviors...
}
 void get_temperature ()
 
 {
   s_temp = get(int(s_position.x),int(s_position.y));
   println ("temp: " + int(s_temp));
   fill(s_temp);
   //rect (20,20,20,20);
 
 
 
 }
 
}




Re: Grow Snowflake
Reply #1 - Feb 8th, 2007, 4:11pm
 
Check out http://processing.org/reference/get_.html and http://processing.org/reference/red_.html to get and convert the arbitary pixel value to rgb.

try something like:

Quote:

b = loadImage("temper.jpg");
p = b.get[x_position*y_position];
grey = (red(p)+green(p)+blue(p))/3);



Faster way to get grey value: http://processing.org/discourse/yabb/YaBB.cgi?board=Syntax;action=display;num=1113603238
Page Index Toggle Pages: 1