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 › color change to transparent transition
Page Index Toggle Pages: 1
color change to transparent transition (Read 788 times)
color change to transparent transition
Jan 5th, 2007, 6:18pm
 
Hi,
I've just started using Processing and am having trouble with the color class/modes. I am trying to have a line color go from white to green, and then disappear via alpha decrease. Any help on how to achieve this would be greatly appreciated.
Re: color change to transparent transition
Reply #1 - Jan 5th, 2007, 6:38pm
 
split the line into smaller pieces (multiple lines) and then set stroke() for each of these in a color between the first and the last.

have a look at the second colorBetween() there for an example on how to mix two colors:
http://snippet.seltar.org/index.php?pid=3&sid=29

F
Re: color change to transparent transition
Reply #2 - Jan 5th, 2007, 10:55pm
 
thanks!!
but now I'm getting a "GL_ERROR at before bind: 0505  GL_OUT_OF_MEMORY" after the application runs for sometime.

know what I should look into to fix this?
Re: color change to transparent transition
Reply #3 - Jan 5th, 2007, 11:59pm
 
not sure what's happening there. can you post your code or give a link?

F
Re: color change to transparent transition
Reply #4 - Jan 8th, 2007, 4:46pm
 
ok, I've narrowed it down to the text causing the error.
Inside draw():

PFont fontA = loadFont("Interstate-Regular-48.vlw");
textFont(fontA,48);
text("GRASS 48",50,50);
Re: color change to transparent transition
Reply #5 - Jan 8th, 2007, 5:17pm
 
easy. don't reload the font on every iteration of draw. this is not only filling your memory slowly, it is also very slow.

do something like:

Code:

PFont pf;

// use setup for things like loading images, fonts, ...
void setup() {
pf = loadFont( "....vlw" );
textFont( pf );
}

void draw() {
text( "abc", 10, 10 );
}


F
Re: color change to transparent transition
Reply #6 - Jan 8th, 2007, 6:04pm
 
yes of course...great, thanks!!
Re: color change to transparent transition
Reply #7 - Jan 9th, 2007, 1:35am
 
if you're doing openGL, then you can do something like:

Code:

size(200,200,OPENGL);
noFill();
beginShape();

//white, full opacity
stroke(255,255);
vertex(0,0);

//red, zero opacity
stroke(255,0,0,0);
vertex(200,200);
endShape();

Page Index Toggle Pages: 1