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 › changing appearance of PGraphics
Page Index Toggle Pages: 1
changing appearance of PGraphics (Read 605 times)
changing appearance of PGraphics
May 29th, 2007, 6:48pm
 
I have a class that draws itself into a PGraphic, and I want to change certain attributes of the class' appearance at runtime. This example just makes a basic music staff. I want to change the background colour when I roll over the staff, and change the staff colour when it's selected.

Code:

public void draw()

{
container.beginDraw();
container.background(BGColour);
int[] strokeVals;
if(selected)
strokeVals = strokeSelected;
else
strokeVals = strokeNormal;
int strkR = strokeVals[0];
int strkG = strokeVals[1];
int strkB = strokeVals[2];
container.stroke(strkR, strkG, strkB);
lines = new int[5][4];
int offset = 8;
for(int i=0;i < 5;i++)
{
lines[i][0] = 0;
lines[i][1] = 33 + (offset * i);
lines[i][2] = length;
lines[i][3] = 33 + (offset * i);
}
for(int c=0;c < 5;c++)
{
container.line(lines[c][0], lines[c][1], lines[c][2], lines[c][3]);
}
container.endDraw();
app.image(container, xpos, ypos);
}


Although the changing values for the variables "BGColour", and "strokeSelected" and "strokeNormal" are being registered, the staff's appearance doesn't change. From the PGraphics example, it seems clear that a PGraphic can be altered dynamically at runtime, but it seems to ignore the changes in my case. Any indication from this code what might be going on?

thanks,

J.
Re: changing appearance of PGraphics
Reply #1 - May 30th, 2007, 8:21am
 
think I may have found it here:

http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Syntax;action=display;num=1171574044

I'll give this a try today.

Page Index Toggle Pages: 1