Is text align local?

So if I put textAlign(LEFT) inside a function, will it only be that function, or the entire code?

void Function()
{
    textAlign(LEFT);
}
1 Like
void setup () {
  background (0);
  textSize(18);
  size (400, 400);
  text ("ABC", 50, 50);
  function();
  text("ABC", 50, 90);
}

void function() {
  textAlign(CENTER);
  text ("ABC", 50, 70);
}
1 Like

Does that mean it is a yes?

When I’m doubt of something, that"s not explicitly confirmed in the documents , I simply do a test.
I could have answered with yes or no, but my message was; do a test and see for yourself.

Now you have another textAlign() in the function. Is this global or local?

PGraphics pg;

void setup () {
  size (400, 100);
  background (0);
  textSize(18);
  frameRate(1);
  pg = createGraphics(400, 100);
}

void draw (){
  if(frameCount % 2 == 0){
    background(0);
    textAlign(RIGHT);
    text ("ABC", 150, 70);
  } else {  
  function();
  }
}  

void function() {
  pg.beginDraw();
  pg.background(0);
  pg.textAlign(LEFT);
  pg.text("ABC", 150, 70);
  pg.endDraw();
  image(pg, 0, 0);
}

I can confirm that a test will clearly show the behavior of textAlign().
Tested them all.

:)

1 Like

@Cybernet Since you didn’t answer, you can force it to be local in function this way.

push();
  textAlign(LEFT);
  text ("ABC", 50, 70);
pop();
2 Likes