# How could I make p5 work in a cartesian coordinate system?

**URL:** <https://discourse.processing.org/t/how-could-i-make-p5-work-in-a-cartesian-coordinate-system/19376>\
**Category:** Coding Questions\
**Created:** [April 4, 2020, 12:26am UTC](https://discourse.processing.org/t/how-could-i-make-p5-work-in-a-cartesian-coordinate-system/19376 "2020-04-04T00:26:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Night-11010](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/night-11010/32/8638_2.png) [@Night-11010](https://discourse.processing.org/u/Night-11010)\
**Post date:** [April 4, 2020, 12:26am UTC](https://discourse.processing.org/t/how-could-i-make-p5-work-in-a-cartesian-coordinate-system/19376/1 "2020-04-04T00:26:35Z")

</div>

I kind of get what I want but I still have problems using mouseX and mouseY, they don’t work propertly when I try to change it.

---

<div class="post-metadata">

**Author:** ![TfGuy44](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tfguy44/32/41_2.png) [@TfGuy44](https://discourse.processing.org/u/TfGuy44)\
**Post date:** [April 4, 2020, 12:38am UTC](https://discourse.processing.org/t/how-could-i-make-p5-work-in-a-cartesian-coordinate-system/19376/2 "2020-04-04T00:38:31Z")

</div>

mouseX is how many pixels from the left edge the mouse is.

mouseY is how many pixels from the top edge the mouse is.

This is slightly different from a mathematical coordinate system, which usually has the positive Y direction going up from the bottom edge.

---

<div class="post-metadata">

**Author:** ![Night-11010](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/night-11010/32/8638_2.png) [@Night-11010](https://discourse.processing.org/u/Night-11010)\
**Post date:** [April 4, 2020, 12:50am UTC](https://discourse.processing.org/t/how-could-i-make-p5-work-in-a-cartesian-coordinate-system/19376/3 "2020-04-04T00:50:36Z")

</div>

Yeah, I know, but I mean if I try to change it, how could I do for making those variables to work if they should in the system that I’m trying to use?

---

<div class="post-metadata">

**Author:** ![TfGuy44](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tfguy44/32/41_2.png) [@TfGuy44](https://discourse.processing.org/u/TfGuy44)\
**Post date:** [April 4, 2020, 3:24am UTC](https://discourse.processing.org/t/how-could-i-make-p5-work-in-a-cartesian-coordinate-system/19376/4 "2020-04-04T03:24:40Z")

</div>

Just use `(height-mouseY)` instead of `mouseY`!

---

<div class="post-metadata">

**Author:** ![Night-11010](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/night-11010/32/8638_2.png) [@Night-11010](https://discourse.processing.org/u/Night-11010)\
**Post date:** [April 4, 2020, 10:46am UTC](https://discourse.processing.org/t/how-could-i-make-p5-work-in-a-cartesian-coordinate-system/19376/5 "2020-04-04T10:46:24Z")

</div>

Thank you for your answer!

---

<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:** [April 4, 2020, 1:55pm UTC](https://discourse.processing.org/t/how-could-i-make-p5-work-in-a-cartesian-coordinate-system/19376/7 "2020-04-04T13:55:41Z")

</div>

A couple of things (be sure to comment one or the other) I have done in the past to modify what I plot to screen:

```auto
void setup() 
  {
  size(500, 500);
   }

void draw() 
  {
  background(0);
  
  //Method 1 This is one.
  //scale(1, -1);
  //translate(0, -height);
  
  for (int x=0; x<width; x++)
    {
    int y = x;
    y = height -y; //Method 2 wherever there is a y. This is the other.
    strokeWeight(3);
    stroke(255, 255, 0);
    point(x, y);
    }  
}

```

`:)`
