# beginShape()

### Example

<figure><img src="https://768248463-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqbs7pgU3AVBY06Rl9M31%2Fuploads%2FCYQm46gJ4tuWuKWL9eYm%2Fhexagon.png?alt=media&#x26;token=d6e46bd6-b883-4e0b-81c3-1049d4747fe0" 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="https://768248463-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqbs7pgU3AVBY06Rl9M31%2Fuploads%2FGJPnceu3pH7lF6BYGVlY%2Fhexagon.png?alt=media&#x26;token=9f4645c8-4b14-4ee0-8fd4-802d45b87f47" 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="https://768248463-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqbs7pgU3AVBY06Rl9M31%2Fuploads%2FdCWRGt0g1kWsZ0nEQOhT%2FTESS.png?alt=media&#x26;token=9bc3320a-43a2-4710-9692-b3fcdf764126" alt=""><figcaption></figcaption></figure>

**POINTS** Draw a set of points

<figure><img src="https://768248463-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqbs7pgU3AVBY06Rl9M31%2Fuploads%2FKDy1CsWe7l8UAGl6HWn0%2FPOINTS.png?alt=media&#x26;token=32bdf026-3872-49c8-bba8-3cd0ca48239f" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://768248463-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqbs7pgU3AVBY06Rl9M31%2Fuploads%2FwIstHl94UdFlW8bJHGsn%2FLINES.png?alt=media&#x26;token=ea876991-235b-41be-a8c5-e3de929129f3" alt=""><figcaption></figcaption></figure>

**TRIANGLES** Draw a set of triangles

<figure><img src="https://768248463-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqbs7pgU3AVBY06Rl9M31%2Fuploads%2Fs4UiMlvGJoYhlSsNZqnN%2FTRIANGLES.png?alt=media&#x26;token=9e9855d1-fd61-445f-a36c-9fd6407be51f" alt=""><figcaption></figcaption></figure>

**QUADS** Draw a set of quadrilaterals

<figure><img src="https://768248463-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqbs7pgU3AVBY06Rl9M31%2Fuploads%2FzqAhDAV8lKeZYKp1czA8%2FQUADS.png?alt=media&#x26;token=c50b0d55-316d-48a8-a6c8-b3007199bd25" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://768248463-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqbs7pgU3AVBY06Rl9M31%2Fuploads%2FFHI5OGnZPpTJoHKVSGbo%2FCLOSE.png?alt=media&#x26;token=64a2e975-302c-4ad1-ba8d-1556f9ddfb67" alt=""><figcaption></figcaption></figure>

`endShape()`

<figure><img src="https://768248463-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqbs7pgU3AVBY06Rl9M31%2Fuploads%2FToWR8Q70EYwS4aB0p5ZE%2FNOTHING.png?alt=media&#x26;token=a2cc2b3e-921b-4588-883c-0c1ff26739a6" 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 %}
