> 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/beginshape.md).

# beginShape()

### Example

<figure><img src="/files/I1LHlLwkbswIgCaGpeBF" alt=""><figcaption></figcaption></figure>

```python
beginShape()
vertex(200, 100)
vertex(300, 150)
vertex(300, 250)
vertex(200, 300)
vertex(100, 250)
vertex(100, 150)
vertex(200, 100)
endShape()
```

### Syntax

```python
beginShape(FORMAT)
...
vertex(x1,y1)
vertex(x2,y2)
vertex(x3,y3)
etc.
...
endShape(MODE)
```

<table><thead><tr><th width="167">Input</th><th>Description</th></tr></thead><tbody><tr><td>beginShape()</td><td><strong>starts</strong> the list of co-ordinates</td></tr><tr><td>FORMAT</td><td>contains any of <strong>POINTS</strong>, <strong>LINES</strong>, <strong>TRIANGLES</strong>, <strong>QUADS, TESS</strong>, see Description</td></tr><tr><td>vertex(xi,yi)</td><td>The coordinates of the <strong>i-th vertex</strong> of the polygon</td></tr><tr><td>endShape()</td><td><strong>ends</strong> the list of co-ordinates</td></tr><tr><td>MODE</td><td><strong>CLOSE</strong> or nothing</td></tr></tbody></table>

<figure><img src="/files/dLMjuBy1iD75eJi5GYyV" alt=""><figcaption></figcaption></figure>

### Description

**beginShape()** and **endShape()** allow the drawing of shapes with many corners. After beginShape() is called, **corners** (vertices) should be listed, each on a separate line. After that, **endShape()** should be called to end the list. Corners are written in their x,y co-ordinates as **vertex(x,y)**

The inputs available for beginShape() are:

**TESS** Connects the edges and creates a closed region. This is the **default** behavior if nothing was given.

<figure><img src="/files/nPgNkA1lYCm2j7zKsUt9" alt=""><figcaption></figcaption></figure>

**POINTS** Draw a set of points

<figure><img src="/files/DvjfAfKzkdnWTtjAeXtt" alt=""><figcaption></figcaption></figure>

**LINES** Draw a set of unconnected line segments

<figure><img src="/files/Bw8XV2yJHABqfNDvVgUk" alt=""><figcaption></figcaption></figure>

**TRIANGLES** Draw a set of triangles

<figure><img src="/files/zNsx2hLCrKjlnIFjp2sO" alt=""><figcaption></figcaption></figure>

**QUADS** Draw a set of quadrilaterals

<figure><img src="/files/YqjgLntbObB2ilj4oOWb" alt=""><figcaption></figcaption></figure>

`endShape(CLOSE)` connects the last vertex to the first one

<figure><img src="/files/BO2t5Q9Mmze8FNgU51Eu" alt=""><figcaption></figcaption></figure>

`endShape()`

<figure><img src="/files/M1X82r3clNO6vAza7i1c" alt=""><figcaption></figcaption></figure>

{% 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 %}
