# Is text align local?

**URL:** <https://discourse.processing.org/t/is-text-align-local/19158>\
**Category:** Beginners\
**Created:** [March 29, 2020, 9:39pm UTC](https://discourse.processing.org/t/is-text-align-local/19158 "2020-03-29T21:39:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cybernet](https://avatars.discourse-cdn.com/v4/letter/c/54ee81/32.png) [@Cybernet](https://discourse.processing.org/u/Cybernet)\
**Post date:** [March 29, 2020, 9:39pm UTC](https://discourse.processing.org/t/is-text-align-local/19158/1 "2020-03-29T21:39:57Z")

</div>

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

```auto
void Function()
{
    textAlign(LEFT);
}

```

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [March 30, 2020, 4:06am UTC](https://discourse.processing.org/t/is-text-align-local/19158/2 "2020-03-30T04:06:03Z")

</div>

```auto
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);
}

```

---

<div class="post-metadata">

**Author:** ![Cybernet](https://avatars.discourse-cdn.com/v4/letter/c/54ee81/32.png) [@Cybernet](https://discourse.processing.org/u/Cybernet)\
**Post date:** [March 30, 2020, 11:51pm UTC](https://discourse.processing.org/t/is-text-align-local/19158/3 "2020-03-30T23:51:24Z")

</div>

Does that mean it is a yes?

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [March 31, 2020, 12:14am UTC](https://discourse.processing.org/t/is-text-align-local/19158/4 "2020-03-31T00:14:26Z")

</div>

When I’m doubt of something, that"s not explicitly confirmed in the [documents](https://processing.org/reference/textAlign_.html) , I simply do a test.  
I could have answered with yes or no, but my message was; do a test and see for yourself.

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [March 31, 2020, 1:13am UTC](https://discourse.processing.org/t/is-text-align-local/19158/5 "2020-03-31T01:13:07Z")

</div>

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

```auto
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);
}

```

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [March 31, 2020, 1:13am UTC](https://discourse.processing.org/t/is-text-align-local/19158/6 "2020-03-31T01:13:19Z")

</div>

> [@noel](#):
>
> do a test and see for yourself

I can confirm that a test will clearly show the behavior of [textAlign()](https://processing.org/reference/textAlign_.html).  
Tested them all.

`:)`

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [April 1, 2020, 10:20am UTC](https://discourse.processing.org/t/is-text-align-local/19158/7 "2020-04-01T10:20:22Z")

</div>

> [@Cybernet](#):
>
> Does that mean it is a yes?

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

```auto
push();
  textAlign(LEFT);
  text ("ABC", 50, 70);
pop();

```
