# Porting a project from Processing to p5.js, getting stuck on an error

**URL:** <https://discourse.processing.org/t/porting-a-project-from-processing-to-p5-js-getting-stuck-on-an-error/26454>\
**Category:** Beginners\
**Created:** [December 22, 2020, 11:16pm UTC](https://discourse.processing.org/t/porting-a-project-from-processing-to-p5-js-getting-stuck-on-an-error/26454 "2020-12-22T23:16:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jjjolton](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jjjolton/32/11530_2.png) [@jjjolton](https://discourse.processing.org/u/jjjolton)\
**Post date:** [December 22, 2020, 11:16pm UTC](https://discourse.processing.org/t/porting-a-project-from-processing-to-p5-js-getting-stuck-on-an-error/26454/1 "2020-12-22T23:16:20Z")

</div>

I’ve been working on getting a Processing project ported to p5.js, mostly just to figure out how to make it work. I’ve been stuck on an error ("There’s an error due to “MakeTriangle” not being defined in the current scope ") that I can’t seem to get past, and I think it has something to do with how I’m using an included .js file with a constructor. My experience is so-so with this, so I’d appreciate any thoughts on what I’m doing wrong. You can find the project here: [https://www.openprocessing.org/sketch/1048797](https://www.openprocessing.org/sketch/1048797)

Thanks!

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [December 22, 2020, 11:42pm UTC](https://discourse.processing.org/t/porting-a-project-from-processing-to-p5-js-getting-stuck-on-an-error/26454/2 "2020-12-22T23:42:36Z")

</div>

> [@jjjolton](#):
>
> I’ve been working on getting a Processing project ported to p5.js,

If you got an already working sketch why don’t you post that as well? 🙄

> [@jjjolton](#):
>
> “There’s an error due to “MakeTriangle” not being defined in the current scope”

`function display()` ➡ `display()`

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [December 23, 2020, 12:29am UTC](https://discourse.processing.org/t/porting-a-project-from-processing-to-p5-js-getting-stuck-on-an-error/26454/3 "2020-12-23T00:29:01Z")

</div>

And in a class you have to use ‘this’ on every variable like strokeWeight(this.tempWeight);

---

<div class="post-metadata">

**Author:** ![jjjolton](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jjjolton/32/11530_2.png) [@jjjolton](https://discourse.processing.org/u/jjjolton)\
**Post date:** [December 23, 2020, 12:59am UTC](https://discourse.processing.org/t/porting-a-project-from-processing-to-p5-js-getting-stuck-on-an-error/26454/4 "2020-12-23T00:59:19Z")

</div>

The working sketch is in Processing - do I just copy/paste the code here?

I’ll try your suggestions. Thanks!

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [December 23, 2020, 1:03am UTC](https://discourse.processing.org/t/porting-a-project-from-processing-to-p5-js-getting-stuck-on-an-error/26454/5 "2020-12-23T01:03:23Z")

</div>

> [@jjjolton](#):
>
> Do I just copy/paste the code here?

Yup! But make sure to highlight it and hit CTRL + SHIFT + C.

You can also host it on [OpenProcessing.org](http://OpenProcessing.org) and switch to Mode Pjs at its right panel.

With some luck it’s gonna even run there online.

---

<div class="post-metadata">

**Author:** ![jjjolton](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jjjolton/32/11530_2.png) [@jjjolton](https://discourse.processing.org/u/jjjolton)\
**Post date:** [December 23, 2020, 2:07am UTC](https://discourse.processing.org/t/porting-a-project-from-processing-to-p5-js-getting-stuck-on-an-error/26454/6 "2020-12-23T02:07:19Z")

</div>

Well, both suggestions helped and it works! If you go to the same link in the original post, you’ll see the results. Thank you!
