> For the complete documentation index, see [llms.txt](https://learnpython.strivemath.com/p5-python-web/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://learnpython.strivemath.com/p5-python-web/reference/shapes/2d/triangle.md).

# triangle()

### Example

![](/files/rpxZyQ8hBCPNSYt5tIbo)

```python
triangle(100, 100, 200, 300,300,100)
```

### Syntax

```python
triangle(x1, y1, x2, y2, x3, y3)
```

<table><thead><tr><th width="167">Input</th><th>Description</th></tr></thead><tbody><tr><td>x1</td><td>x co-ordinate of the left corner</td></tr><tr><td>y1</td><td>y co-ordinate of the left corner</td></tr><tr><td>x2</td><td>x co-ordinate of the middle corner</td></tr><tr><td>y2</td><td>y co-ordinate of the middle corner</td></tr><tr><td>x3</td><td>x co-ordinate of the right corner</td></tr><tr><td>y3</td><td>y co-ordinate of the right corner</td></tr></tbody></table>

<figure><img src="/files/7UTqymbDsW9YMFDwcbup" alt=""><figcaption></figcaption></figure>

### Description

**triangle()** draws a triangle on the canvas, using the inputs to determine the positions of the 3 corners. Even though this is the simplest 2D shape, it takes the most complicated form of input, since total freedom to specify the shape is given.

{% hint style="info" %}
Find these documents helpful? Let the people who made them help your child learn to code at [**Strivemath**](https://www.strivemath.com/)<mark style="color:blue;">**!**</mark>

We'd love to hear your Feedback/Comments [here](https://docs.google.com/forms/d/e/1FAIpQLSeqorBAGTya-YBRI-VFjJxtgQtCz3ucGDI96K96sNyuaGuvdw/viewform?usp=sf_link).
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learnpython.strivemath.com/p5-python-web/reference/shapes/2d/triangle.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
