# Processing 3 Translate and Rotate function taking triangle out of canvas

**URL:** <https://discourse.processing.org/t/processing-3-translate-and-rotate-function-taking-triangle-out-of-canvas/33509>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [November 14, 2021, 6:12pm UTC](https://discourse.processing.org/t/processing-3-translate-and-rotate-function-taking-triangle-out-of-canvas/33509 "2021-11-14T18:12:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sebest\_design](https://avatars.discourse-cdn.com/v4/letter/s/ee7513/32.png) [@sebest\_design](https://discourse.processing.org/u/sebest_design)\
**Post date:** [November 14, 2021, 6:12pm UTC](https://discourse.processing.org/t/processing-3-translate-and-rotate-function-taking-triangle-out-of-canvas/33509/1 "2021-11-14T18:12:14Z")

</div>

Hi. I am trying to horizontally flip a triangle and have it placed on the canvas. I want to create buttons for a carousel slide… Here’s the code:

```auto
//Buttons
noStroke();
triangle(triangleRX1, triangleRY1, triangleRX2and3, triangleRY2, triangleRX2and3, triangleRY3);
pushMatrix();
translate(1053.75, 0);
rotate(radians(180));
translate(width/2,height/2);
triangle(triangleRX1, triangleRY1, triangleRX2and3, triangleRY2, triangleRX2and3, triangleRY3);
popMatrix();

```

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

If it were a rectangle I could have kept the origin at the center using rectmode(). Unfortunately, for a triangle, I don’t know how the rotate function is supposed to work. What am I doing wrong?  
Here’s a zipped version of the processing file if that helps:

> **[v8.zip](https://drive.google.com/file/d/1pWZffwznf9N0ZixureCD8lEWf6zrhDAB/view?usp=sharing)**
>
> Google Drive file.

---

<div class="post-metadata">

**Author:** ![sebest\_design](https://avatars.discourse-cdn.com/v4/letter/s/ee7513/32.png) [@sebest\_design](https://discourse.processing.org/u/sebest_design)\
**Post date:** [November 14, 2021, 6:14pm UTC](https://discourse.processing.org/t/processing-3-translate-and-rotate-function-taking-triangle-out-of-canvas/33509/2 "2021-11-14T18:14:34Z")

</div>

Oops, my bad. The zipped file might have the rotate and the translate function commented up. So you might have to uncomment it before hitting run. Sorry.
