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.
IndexProgramming Questions & HelpSyntax Questions › Random colour each time a new ellipse loads
Page Index Toggle Pages: 1
Random colour each time a new ellipse loads (Read 2734 times)
Random colour each time a new ellipse loads
Oct 23rd, 2007, 8:25pm
 
Hi there,

I have images being loaded in realtime, i.e. a simple ellipse. However each time an ellipse loads, I wanted it to have a random colour...I know how to generate a random colour each time the program loads, but not each time the ellipse loads. Any ideas how I can do this?

To make it clearer I want to change this code...
fill(color(100, 100, 100, 50));
...to such that it each time the ellipse loads, I want a random colour to load on each ellipse.

Thanks
Re: Random colour each time a new ellipse loads
Reply #1 - Oct 23rd, 2007, 8:49pm
 
no need to call color inside fill:

fill(color(100, 100, 100, 50));

should / could be:

fill(100, 100, 100, 50);

and to randomize it:

fill( random(255), random(255), random(255), random(255));

F
Re: Random colour each time a new ellipse loads
Reply #2 - Oct 23rd, 2007, 8:58pm
 
many thanks for the tip,

however, the random bit changes constant through out the duration of the program. I mean it looks cool, but a little too pyschdelic for my liking. I want one color for each ellipse.
Re: Random colour each time a new ellipse loads
Reply #3 - Oct 24th, 2007, 3:48pm
 
hi,

can you post some simple code demonstrating your problem?
Basically you need to set the color once when your ellipse is loaded, and not every frame. Maybe put all the colors into a list and loop through the list every frame.
Page Index Toggle Pages: 1