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.
IndexSuggestions & BugsSoftware,  Documentation,  Website Suggestions › controlling the global-core variables
Page Index Toggle Pages: 1
controlling the global-core variables (Read 663 times)
controlling the global-core variables
May 23rd, 2006, 7:49am
 
I wish to have a function, which remembers the current settings, and then another function, to load the remembered settings back up. this way i can change settings as i'd like, ie. textAlign(CENTER), and not worry about the textobjects drawn after this (if i run the reset-to-remembered function)


so something like
Code:

textAlign(LEFT);
fill(0);
rememberSettings();
text("sometext",15,15);

textAlign(CENTER);
for(int i = 0; i < 10; i++){
fill(random(255));
text("lala",random(width),random(height));
}
recallSettings();
text("brother of sometext",35,15); // this will appear aligned LEFT, and with fill(0);


-seltar
Re: controlling the global-core variables
Reply #1 - May 23rd, 2006, 11:15am
 
snip this:

Code:

class gSettings
{
PApplet papplet;
int textAlign;
int fill;

gSettings (PApplet _p) {
papplet = _p;
}

void pushSettings()
{
textAlign = papplet.g.textAlign;
fill = papplet.g.fill;
}

void popSettings()
{
textAlign(textAlign);
fill(fill);
}
}


untested, but i think you get the idea ...
F
Re: controlling the global-core variables
Reply #2 - May 24th, 2006, 11:43am
 
That's brilliant Smiley I must try this some time.
Re: controlling the global-core variables
Reply #3 - May 24th, 2006, 5:47pm
 
i made it with the most usefull variables..

Code:

public class gSettings
{
public boolean smooth;

public int rectMode, ellipseMode;

public int textAlign;
public float textSize;

public boolean tint;
public int tintColor;
public boolean fill;
public int fillColor;
public boolean stroke;
public int strokeColor;
public float strokeWeight;

public gSettings () {
pushSettings();
}

public void pushSettings()
{
smooth = g.smooth;

rectMode = g.rectMode;
ellipseMode = g.ellipseMode;

textAlign = g.textAlign;
textSize = g.textSize;

tint = g.tint;
fill = g.fill;
stroke = g.stroke;
tintColor = g.tintColor;
fillColor = g.fillColor;
strokeColor = g.strokeColor;
strokeWeight = g.strokeWeight;
}

public void popSettings()
{
if(smooth) smooth();
else noSmooth();

rectMode(rectMode);
ellipseMode(ellipseMode);

textAlign(textAlign);
textSize(textSize);

if(tint) tint(tintColor);
else noTint();

if(fill) fill(fillColor);
else noFill();

if(stroke) stroke(strokeColor);
else noStroke();

strokeWeight(strokeWeight);
}
}
Page Index Toggle Pages: 1