# How to use the drawTriangles function?

**URL:** https://phaser.discourse.group/t/how-to-use-the-drawtriangles-function/15194
**Category:** Phaser 2 / CE
**Created:** [March 6, 2025, 8:44pm UTC](https://phaser.discourse.group/t/how-to-use-the-drawtriangles-function/15194 "2025-03-06T20:44:00Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Lex](https://avatars.discourse-cdn.com/v4/letter/l/c68b51/32.png) [@Lex](https://phaser.discourse.group/u/Lex)
#### Post date: [March 6, 2025, 8:44pm UTC](https://phaser.discourse.group/t/how-to-use-the-drawtriangles-function/15194/1 "2025-03-06T20:44:00Z")

</div>

I’m learning Phaser and found the “drawTriangles” function. It’s in the Graphics object.

The “drawTriangles” function is needed for the project, please tell me how to use it correctly in Phaser?

Looked at the codes [Phaser](https://phaser.io/examples/v3.85.0). Not in the examples?

---

<div class="post-metadata">

### Author: ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)
#### Post date: [March 7, 2025, 3:37pm UTC](https://phaser.discourse.group/t/how-to-use-the-drawtriangles-function/15194/2 "2025-03-07T15:37:18Z")

</div>

Phaser 3 Graphics has no `drawTriangles()`, but it has `fillTriangle()`, `fillTriangleShape()`, `strokeTriangle()`, `strokeTriangleShape()`.

---

<div class="post-metadata">

### Author: ![Lex](https://avatars.discourse-cdn.com/v4/letter/l/c68b51/32.png) [@Lex](https://phaser.discourse.group/u/Lex)
#### Post date: [March 7, 2025, 3:55pm UTC](https://phaser.discourse.group/t/how-to-use-the-drawtriangles-function/15194/3 "2025-03-07T15:55:56Z")

</div>

There is such a function, for some reason my link was removed. Here is the link to the library:

[https://cdnjs.cloudflare.com/ajax/libs/phaser/2.4.4/phaser.js](https://cdnjs.cloudflare.com/ajax/libs/phaser/2.4.4/phaser.js)

Just type in the Phaser script search to quickly find the line you need:

> Phaser.Graphics.prototype.drawTriangles = function(vertices, indices, cull)

---

<div class="post-metadata">

### Author: ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)
#### Post date: [March 7, 2025, 4:24pm UTC](https://phaser.discourse.group/t/how-to-use-the-drawtriangles-function/15194/4 "2025-03-07T16:24:51Z")

</div>

The [Phaser 2 drawTriangles() method](https://phaserjs.github.io/phaser-ce/Phaser.Graphics.html#drawTriangles) isn’t in Phaser 3.

---

<div class="post-metadata">

### Author: ![Lex](https://avatars.discourse-cdn.com/v4/letter/l/c68b51/32.png) [@Lex](https://phaser.discourse.group/u/Lex)
#### Post date: [March 7, 2025, 5:07pm UTC](https://phaser.discourse.group/t/how-to-use-the-drawtriangles-function/15194/5 "2025-03-07T17:07:33Z")

</div>

I asked for an example with drawTriangles, not a link to the library. There is no example anywhere.

---

<div class="post-metadata">

### Author: ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)
#### Post date: [March 7, 2025, 5:20pm UTC](https://phaser.discourse.group/t/how-to-use-the-drawtriangles-function/15194/6 "2025-03-07T17:20:48Z")

</div>

Are you using Phaser 2 or Phaser 3 in your project?

---

<div class="post-metadata">

### Author: ![Lex](https://avatars.discourse-cdn.com/v4/letter/l/c68b51/32.png) [@Lex](https://phaser.discourse.group/u/Lex)
#### Post date: [March 7, 2025, 6:16pm UTC](https://phaser.discourse.group/t/how-to-use-the-drawtriangles-function/15194/7 "2025-03-07T18:16:34Z")

</div>

I use Phaser 2 because I need the drawTriangles function.

---

<div class="post-metadata">

### Author: ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)
#### Post date: [March 7, 2025, 6:29pm UTC](https://phaser.discourse.group/t/how-to-use-the-drawtriangles-function/15194/8 "2025-03-07T18:29:24Z")

</div>

I would really recommend you use any of the Phaser 3 Graphics triangle methods.

I don’t know of any Phaser 2 `drawTriangles()` examples, but it would work like this:

```js
// Phaser 2
const graphics = this.add.graphics(0, 0);

graphics.lineStyle(10, 0xffd900, 1);
graphics.beginFill(0xFF3300);
graphics.drawTriangles([0, 0, 50, 50, 100, 0, 150, 50, 200, 0, 250, 50]);
graphics.endFill();

```
