# Changing coordinate system without mirroring objects

**URL:** https://discourse.processing.org/t/changing-coordinate-system-without-mirroring-objects/21846
**Category:** Processing.py
**Created:** [June 13, 2020, 8:11pm UTC](https://discourse.processing.org/t/changing-coordinate-system-without-mirroring-objects/21846 "2020-06-13T20:11:32Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![renec112](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/renec112/32/9168_2.png) [@renec112](https://discourse.processing.org/u/renec112)
#### Post date: [June 13, 2020, 8:11pm UTC](https://discourse.processing.org/t/changing-coordinate-system-without-mirroring-objects/21846/1 "2020-06-13T20:11:32Z")

</div>

I would love to change my coordinate to be in the middle instead. It’s easily done with translate(width/2, height/2). Like so:

```auto
def setup():
    size(1920, 1080)

def draw():
    background(255)
    translate(width/2,height/2)

```

I get:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/c/cafe0de92f83ed94d7e19fa535a45b6124731ab5.png)

But as you can see the y axis goes negative when going upwards… I would love to fix that.  
I tried that by using scale(1,-1), but off course that flips fonts in the canvas…

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/2/2277d37ca9a3798d6654ca137a680c22f70ff96a.png)

Any ideas?

---

<div class="post-metadata">

### Author: ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)
#### Post date: [June 14, 2020, 8:58pm UTC](https://discourse.processing.org/t/changing-coordinate-system-without-mirroring-objects/21846/2 "2020-06-14T20:58:42Z")

</div>

Hi,

Is it a problem is you just invert the y values each time you need to draw something on the screen?  
I think it’s just a habit to take.

---

<div class="post-metadata">

### Author: ![tabreturn](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tabreturn/32/3697_2.png) [@tabreturn](https://discourse.processing.org/u/tabreturn)
#### Post date: [June 14, 2020, 10:45pm UTC](https://discourse.processing.org/t/changing-coordinate-system-without-mirroring-objects/21846/3 "2020-06-14T22:45:22Z")

</div>

I suppose you could create a function for flipping the text, something like –

```auto
def displayCoord(x, y):
    pushMatrix()
    scale(1, -1)
    if x:
        text(x, x, 0)
    elif y:
        text(y, 0, y*-1)
    popMatrix()
    
translate(width/2, height/2)
scale(1, -1)

displayCoord(0, -20)
displayCoord(-30, 0)
displayCoord(28, 0)
displayCoord(0, 25)

```

---

<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: [June 15, 2020, 1:04am UTC](https://discourse.processing.org/t/changing-coordinate-system-without-mirroring-objects/21846/4 "2020-06-15T01:04:51Z")

</div>

Hello,

In my example I subtract all y values from height and fonts are fine.

This is a Processing JAVA version:

```auto
int x, y;

void setup() 
	{
  size(500, 300);
  textSize(24);
	}

void draw() 
	{
  background(255);
  
  x = 400;
  y = 200;
  
  line(0, height-0, x, height-y);
  
  fill(0);
  textAlign(CENTER, CENTER);
  text("T", x/2, height-y/2);
	}

```

`:)`

---

<div class="post-metadata">

### Author: ![renec112](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/renec112/32/9168_2.png) [@renec112](https://discourse.processing.org/u/renec112)
#### Post date: [June 15, 2020, 7:25am UTC](https://discourse.processing.org/t/changing-coordinate-system-without-mirroring-objects/21846/5 "2020-06-15T07:25:02Z")

</div>

Thank you everyone for your brilliant solutions! I already made myself a custom text function, so flipping as @tabreturn suggested was a solution that worked well for me.

I could get use to it @josephh I guess, but I plan on using p5 a lot so I would to make my life as easy as possible 😃

you guys are awesome.
