# Variable/interactive beginShape() kind?

**URL:** https://discourse.processing.org/t/variable-interactive-beginshape-kind/10354
**Category:** Beginners
**Created:** [April 16, 2019, 4:35pm UTC](https://discourse.processing.org/t/variable-interactive-beginshape-kind/10354 "2019-04-16T16:35:03Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![cyanblue](https://avatars.discourse-cdn.com/v4/letter/c/ec9cab/32.png) [@cyanblue](https://discourse.processing.org/u/cyanblue)
#### Post date: [April 16, 2019, 4:35pm UTC](https://discourse.processing.org/t/variable-interactive-beginshape-kind/10354/1 "2019-04-16T16:35:03Z")

</div>

I have a set of vertices I’m drawing within beginShape(), and I wanted to cycle through the different options each time the mouse is clicked i.e. beginShape(TRIANGLES), beginShape(POINTS), beginShape(LINES) etc.

I’ve made an array of the different options:

`String[] shapeType = {"POINTS", "LINES", "TRIANGLES", "TRIANGLE_FAN", "TRIANGLE_STRIP", "QUADS", "QUAD_STRIP"};`

and what I’m trying to achieve is something like this:

`beginShape(shapeType[n]);`  
`vertex(x, y);`  
`...etc`  
`endShape();`

Where n is cycled through the shapeType[] array on mousePressed().

The only problem is that **POINTS** , **LINES** , etc are not Strings but I don’t know what else they could be! (I’m guessing they are constants?).  
I’m getting the error “beginShape() expects parameters like beginShape(int)”.  
But surely TRIANGLES etc isn’t an integer??!

Is there any way to achieve this kind of variable shape type?

Many thanks!

---

<div class="post-metadata">

### Author: ![zenemig](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/zenemig/32/4418_2.png) [@zenemig](https://discourse.processing.org/u/zenemig)
#### Post date: [April 16, 2019, 4:59pm UTC](https://discourse.processing.org/t/variable-interactive-beginshape-kind/10354/2 "2019-04-16T16:59:33Z")

</div>

Hi @cyanblue,

You’re rigth, the parameters in `beginShape()` are constants that are equal to integers.

If you look in the source code of Processing you can know to what integer correspond every option your list:

```auto
static final int POINTS = 3; // vertices
static final int LINES = 5; // beginShape(), createShape()
static final int TRIANGLES = 9; // vertices
static final int TRIANGLE_STRIP = 10; // vertices
static final int TRIANGLE_FAN = 11; // vertices
static final int QUADS = 17; // vertices
static final int QUAD_STRIP = 18; // vertices

```

Having that you can try with a int array instead.

See [source](https://github.com/processing/processing/blob/master/core/src/processing/core/PConstants.java)

---

<div class="post-metadata">

### Author: ![cyanblue](https://avatars.discourse-cdn.com/v4/letter/c/ec9cab/32.png) [@cyanblue](https://discourse.processing.org/u/cyanblue)
#### Post date: [April 16, 2019, 6:25pm UTC](https://discourse.processing.org/t/variable-interactive-beginshape-kind/10354/3 "2019-04-16T18:25:47Z")

</div>

Thank you so much @zenemig!  
That worked perfectly - and thanks for the link to the processing source code, that was really fascinating 🙂

---

<div class="post-metadata">

### Author: ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)
#### Post date: [April 19, 2019, 5:35pm UTC](https://discourse.processing.org/t/variable-interactive-beginshape-kind/10354/4 "2019-04-19T17:35:49Z")

</div>

If you are using the PDE editor you will also notice that capitalized PConstants (like `TRIANGLE_FAN` or `P2D` or `CENTER` or `UP`) are never written in quotes – they are variable names – and are automatically highlighted in the editor in a green-gray color.
