# Map point onto 135-degree line then onto x- and y-axis intercepts

**URL:** <https://discourse.processing.org/t/map-point-onto-135-degree-line-then-onto-x-and-y-axis-intercepts/7870>\
**Category:** Coding Questions\
**Created:** [January 27, 2019, 4:43am UTC](https://discourse.processing.org/t/map-point-onto-135-degree-line-then-onto-x-and-y-axis-intercepts/7870 "2019-01-27T04:43:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ottenm](https://avatars.discourse-cdn.com/v4/letter/o/f08c70/32.png) [@ottenm](https://discourse.processing.org/u/ottenm)\
**Post date:** [January 27, 2019, 4:43am UTC](https://discourse.processing.org/t/map-point-onto-135-degree-line-then-onto-x-and-y-axis-intercepts/7870/1 "2019-01-27T04:43:22Z")

</div>

Given any point on the screen (mouseX, mouseY) I need to draw a triangle bordered by a 135-degree line through that point (slope == -1) and by the left and bottom axes. In other words, anchored on the bottom-left corner of the screen (0,height-1) and on the x- and y-axis points where the 135-degree line would intersect them.

My friend Matt and I had numerous issues with our Geometry teacher a few decades ago. As did he with us. 😉

Thanks for any help!

---

<div class="post-metadata">

**Author:** ![Lexyth](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lexyth/32/7403_2.png) [@Lexyth](https://discourse.processing.org/u/Lexyth)\
**Post date:** [January 27, 2019, 6:14am UTC](https://discourse.processing.org/t/map-point-onto-135-degree-line-then-onto-x-and-y-axis-intercepts/7870/2 "2019-01-27T06:14:59Z")

</div>

This might be just me who doesn‘t quite understand it, but could you include an Image of how it should Look like? Better 2 images with different mouseX and y points, so that we can See what you mean better ^^

---

<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:** [January 27, 2019, 7:04am UTC](https://discourse.processing.org/t/map-point-onto-135-degree-line-then-onto-x-and-y-axis-intercepts/7870/3 "2019-01-27T07:04:26Z")

</div>

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

void draw(){
  background(0);
  float v = mouseX + height - mouseY;
  triangle(0,height,0,height-v,v,height);
}

```

---

<div class="post-metadata">

**Author:** ![ottenm](https://avatars.discourse-cdn.com/v4/letter/o/f08c70/32.png) [@ottenm](https://discourse.processing.org/u/ottenm)\
**Post date:** [January 27, 2019, 2:20pm UTC](https://discourse.processing.org/t/map-point-onto-135-degree-line-then-onto-x-and-y-axis-intercepts/7870/4 "2019-01-27T14:20:46Z")

</div>

That’s _beautiful_ TfGuy44! Couldn’t the simplicity of it without your help.  
Thanks a million!
