# Using Shapes in p5.js

**URL:** https://discourse.processing.org/t/using-shapes-in-p5-js/32058
**Category:** Coding Questions
**Created:** [September 2, 2021, 6:41am UTC](https://discourse.processing.org/t/using-shapes-in-p5-js/32058 "2021-09-02T06:41:01Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![bcabc](https://avatars.discourse-cdn.com/v4/letter/b/6a8cbe/32.png) [@bcabc](https://discourse.processing.org/u/bcabc)
#### Post date: [September 2, 2021, 6:41am UTC](https://discourse.processing.org/t/using-shapes-in-p5-js/32058/1 "2021-09-02T06:41:01Z")

</div>

Hi there -

I’m newish to Processing and looking to get a sketch up and running.  
Using Example 03: Objects Array from the Examples Folder, I’d like to replace the “ellipse” with a tailored “createShape” - but it doesn’t seem to be working. I’d appreciate if someone could tell me where I’ve gone wrong.

```auto
class Jitter {
  constructor() {
    this.x = random(width);
    this.y = random(height);
    this.diameter = random(10, 30);
    this.speed = 1;
  }

  move() {
    this.x += random(-this.speed, this.speed);
    this.y += random(-this.speed, this.speed);
  }

  display() {
    var s = createShape();
    s.beginShape(TRIANGLE_FAN);
    s.strokeWeight(random(0.28));
    s.vertex(100, -30);
    s.vertex(90, 20);
    s.vertex(3, -100)
    s.endShape(CLOSE);
  }
}

```

---

<div class="post-metadata">

### Author: ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)
#### Post date: [September 2, 2021, 8:06am UTC](https://discourse.processing.org/t/using-shapes-in-p5-js/32058/2 "2021-09-02T08:06:26Z")

</div>

Hi @bcabc,

I assume you are using p5js (JavaScript) and not Processing (Java) so there is no `createShape()` function in the [reference](https://p5js.org/reference/).

One solution is to only use `beginShape()` and `endShape()`:

```auto
beginShape(TRIANGLE_FAN);
strokeWeight(random(0.28));
vertex(100, -30);
vertex(90, 20);
vertex(3, -100)
endShape(CLOSE);

```
