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 › beginner help with fading colours
Page Index Toggle Pages: 1
beginner help with fading colours (Read 254 times)
beginner help with fading colours
Nov 16th, 2008, 9:16pm
 
Hi!
I am a beginner in processing and would like some help..

i have manged to make the following:

float x = 255;
int y = 1;

void setup() {
background (0);
}

void draw() {
 background(0);
stroke(x,x-132,x-54);
line(85, 20, 85, 75);
x = x-y;
if (x == 0 || x == 255) {
     y = y * (-1);
   }

}

This was my attempt at creating a line fading into various colors... Although i do have a problem.. It can only make a short range of colors. and repeats the same colors again and again. I was thinking that maybe it would work with arrays but i'm not really sure of how arrays work and need a little help on that department.
If anyone can come up with an easy, begginer friendly solution i would really apreciate it.


Re: beginner help with fading colours
Reply #1 - Nov 16th, 2008, 11:18pm
 
I would really apreciate any help! Please help
Re: beginner help with fading colours
Reply #2 - Nov 17th, 2008, 2:36am
 
Hi, M1kes.  Read over the documentation for colorMode():

http://processing.org/reference/colorMode_.html

By default, Processing uses the RGB color mode, which is great for computers, but not so intuitive for people.  Try using HSB instead -- hue, saturation, brightness.  With HSB, you can change the hue of your color by changing only one value.  (With RGB, you have to change all three, which is why your sketch is stuck on pink/red.)

You can also adjust the saturation and brightness separately, but usually when people talk about changing the "color," they mostly mean "hue".

Check that out, and also some of the examples under:

File > Examples > Basics > Color

You're on the right track!
Page Index Toggle Pages: 1