# Library creation help

**URL:** <https://discourse.processing.org/t/library-creation-help/22923>\
**Category:** Development\
**Created:** [July 30, 2020, 8:10am UTC](https://discourse.processing.org/t/library-creation-help/22923 "2020-07-30T08:10:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![SamuelCobb](https://avatars.discourse-cdn.com/v4/letter/s/73ab20/32.png) [@SamuelCobb](https://discourse.processing.org/u/SamuelCobb)\
**Post date:** [July 30, 2020, 8:10am UTC](https://discourse.processing.org/t/library-creation-help/22923/1 "2020-07-30T08:10:29Z")

</div>

Hey guys,

So, I am not the most experienced p5 user but I am trying to write a “Picking” library for a specific project of mine. In the picking library, I need to create a “buffer” which is basically a hidden canvas which the user can interact with.

I am basing a lot of my code of the original Picking library made by [Nicolas Clavaud](http://n.clavaud.free.fr/) for Processing. After decompiling the .jar file I have found a few things which I am struggling to think of a way to implement in JS.

The original picking library has a “buffer” class, which is basically a replica of the canvas. This class extends P3D so that it can do this.

I have 2 questions regarding this. Primarily, how would I extend the WEBGL renderer (p5.RendererGL) with a new class? (or function since classes are different in .js)

My second question is a bit naive since I do not have much experience in .js but what is the equivalent of a public void?

Thanks guys

EDIT: here is the link to the decompiled .jar files from the original Picking lib

> **[Picking.jar.src.zip](https://drive.google.com/file/d/1JyrPrD37cfqpJual0yPAnKxA4YmZHHbI/view?usp=sharing)**
>
> Google Drive file.

---

<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:** [July 31, 2020, 10:17pm UTC](https://discourse.processing.org/t/library-creation-help/22923/2 "2020-07-31T22:17:37Z")

</div>

> [@SamuelCobb](#):
>
> , how would I extend the WEBGL renderer (p5.RendererGL) with a new class?

You can create a `class` which `extends` p5.RendererGL: 🤓

> **[extends - JavaScript | MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/extends)**
>
> The extends keyword is used in class declarations or class expressions to create a class that is a child of another class.

> [@SamuelCobb](#):
>
> … but what is the equivalent of a `public void`?

Just ignore it. 😉

---

<div class="post-metadata">

**Author:** ![SamuelCobb](https://avatars.discourse-cdn.com/v4/letter/s/73ab20/32.png) [@SamuelCobb](https://discourse.processing.org/u/SamuelCobb)\
**Post date:** [August 1, 2020, 2:07am UTC](https://discourse.processing.org/t/library-creation-help/22923/3 "2020-08-01T02:07:15Z")

</div>

dang, is it really that simple? I thought I would need to do like a bunch of stuff with prototype…

@GoToLoop this is more like ES6 syntax right?

---

<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:** [August 1, 2020, 2:22am UTC](https://discourse.processing.org/t/library-creation-help/22923/4 "2020-08-01T02:22:36Z")

</div>

> [@SamuelCobb](#):
>
> … this is more like ES6 syntax right?

ES6 is from 2015 and by 2017 most browsers had most of its new features, including `class`: ⛵

> **[ECMAScript](https://en.wikipedia.org/wiki/ECMAScript#6th_Edition_%E2%80%93_ECMAScript_2015)**
>
> ECMAScript (/ˈɛkməskrɪpt/; ES) is a standard for scripting languages, including JavaScript, JScript, and ActionScript. It is best known as a JavaScript standard intended to ensure the interoperability of web pages across different web browsers. It is standardized by Ecma International in the document ECMA-262.
> ECMAScript is commonly used for client-side scripting on the World Wide Web, and it is increasingly being used for server-side applications and services using runtime environments - Node.j...

---

<div class="post-metadata">

**Author:** ![SamuelCobb](https://avatars.discourse-cdn.com/v4/letter/s/73ab20/32.png) [@SamuelCobb](https://discourse.processing.org/u/SamuelCobb)\
**Post date:** [August 1, 2020, 7:13am UTC](https://discourse.processing.org/t/library-creation-help/22923/5 "2020-08-01T07:13:08Z")

</div>

Dang, that’s useful

If I may, can I ask whether you would know if I could recreate the Processing [PApplet’s .record](https://processing.github.io/processing-javadocs/core/processing/core/PApplet.html) function somehow? It’s pretty necessary for my lib.

I was thinking copy() could be used in a similar way to .record but I’m not entirely sure.

> Just ignore it 😉  
> should I use function or something?

---

<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:** [August 1, 2020, 12:33pm UTC](https://discourse.processing.org/t/library-creation-help/22923/6 "2020-08-01T12:33:47Z")

</div>

> [@SamuelCobb](#):
>
> It’s pretty necessary for my lib.

1st step you should take in order to make a lib is creating a repo for it: 🐙

> **[Creating a new repository - GitHub Docs](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-new-repository)**
>
> You can create a new repository on your personal account or any organization where you have sufficient permissions.

You can post the original “.java” file(s) you’re attempting to convert to JS there. ☕

Then create a new “.js” file w/ you attempt conversion, so others can chime in too. 🛎

---

<div class="post-metadata">

**Author:** ![SamuelCobb](https://avatars.discourse-cdn.com/v4/letter/s/73ab20/32.png) [@SamuelCobb](https://discourse.processing.org/u/SamuelCobb)\
**Post date:** [August 1, 2020, 1:32pm UTC](https://discourse.processing.org/t/library-creation-help/22923/7 "2020-08-01T13:32:40Z")

</div>

thanks man, means a lot to me

I already have a repo but I haven’t filled it in yet. I’ll make a post when I have got everything set up 🙂

thanks again.
