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 & HelpPrograms › about the color like  the rainbow
Page Index Toggle Pages: 1
about the color like  the rainbow (Read 584 times)
about the color like  the rainbow
Dec 10th, 2008, 9:58pm
 
HI,who can help me? i make the progaramme-change the color like the rainbow.red to violet.but, the programme was black to red ,andthat,it was't circle.

thank u..


// Two variables for color.
float c1 = 0;      
float c2 = 255;  

// Start by incrementing c1.
float c1dir = 0.1;  
// Start by decrementing c2.
float c2dir = -0.1;


void draw() {
 noStroke();
 colorMode(HSB,200);
 
 // Draw rectangle on left
 fill(c2,c1,c1);
 rect(0,0,100,100);

 // Adjust colo r values
 c1 = c1 + c1dir;
 c2 = c2 + c2dir;
 loop();
}
Re: about the color like  the rainbow
Reply #1 - Dec 10th, 2008, 10:54pm
 
Quote:
float c1 = 0;
void draw() {
  noStroke();
  colorMode(HSB);
  c1+=1;
  c1%=255;
  fill(c1,255,255);
  rect(0,0,100,100);




hope it can help
Re: about the color like  the rainbow
Reply #2 - Dec 11th, 2008, 10:24pm
 
hey! that's clever using %= like that! i was printing out c1 to see how it changed and i think it should be c %= 256 though.  either that or the %= should be after the fill(). that way 255 gets a turn before being reset to 0. nitpicking i know but i'm a perfectionist. Smiley
Re: about the color like  the rainbow
Reply #3 - Dec 12th, 2008, 4:10pm
 
mb09 wrote on Dec 10th, 2008, 10:54pm:
hope it can help



thanks~it's clever.~
Page Index Toggle Pages: 1