# Apple Pencil in P5.js

**URL:** <https://discourse.processing.org/t/apple-pencil-in-p5-js/9384>\
**Category:** Gallery\
**Created:** [March 17, 2019, 4:02pm UTC](https://discourse.processing.org/t/apple-pencil-in-p5-js/9384 "2019-03-17T16:02:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sableraph](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sableraph/32/251_2.png) [@sableraph](https://discourse.processing.org/u/sableraph)\
**Post date:** [March 17, 2019, 4:02pm UTC](https://discourse.processing.org/t/apple-pencil-in-p5-js/9384/1 "2019-03-17T16:02:54Z")

</div>

Hey everyone,

I just made a basic drawing app in p5.js with support for the Apple Pencil.

It uses [Pressure.js](https://pressurejs.com/) to handle the pointer events so it should work with other input devices too. Let me know if you try it with other pencils and/or tablets! [edit: it also works with regular touch events on iPhone]

Online demo: [https://editor.p5js.org/SableRaf/full/PNSk4uR9v](https://editor.p5js.org/SableRaf/full/PNSk4uR9v)  
Repository: [https://github.com/SableRaf/PencilToP5](https://github.com/SableRaf/PencilToP5)

Here’s how it looks:

 ![pencilToP5](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/5/5ca66489863f3176d2297c09707abe6e0c096374.jpeg)

Thanks to Abe Pazos (a.k.a Hamoid) for the help figuring out the tricky parts 🙂

---

<div class="post-metadata">

**Author:** ![lucifer1004](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lucifer1004/32/5401_2.png) [@lucifer1004](https://discourse.processing.org/u/lucifer1004)\
**Post date:** [May 29, 2019, 6:55am UTC](https://discourse.processing.org/t/apple-pencil-in-p5-js/9384/2 "2019-05-29T06:55:41Z")

</div>

When I draw a line and release the mouse, drawing will not stop immediately, instead, it keeps going absurdly and leaves a long trail. Do you have a more optimized version? I am interested in it.

---

<div class="post-metadata">

**Author:** ![sableraph](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sableraph/32/251_2.png) [@sableraph](https://discourse.processing.org/u/sableraph)\
**Post date:** [June 11, 2019, 10:11am UTC](https://discourse.processing.org/t/apple-pencil-in-p5-js/9384/3 "2019-06-11T10:11:46Z")

</div>

Hi Lucifer1004,

This is a feature of the pressure.js library I use to capture the levels of pressure of the Apple pencil. When using an input device that doesn’t have pressure (like your mouse), it simulates pressure in this way (rising slowly as you keep the button pressed, and falling slowly after you release). This can be configured in the parameters of the pressure.js library.

However, if what you need is a sketch that lets you draw with your mouse, you’d be better of with something like this tutorial: [http://coursescript.com/notes/interactivecomputing/drawingapp/index.html](http://coursescript.com/notes/interactivecomputing/drawingapp/index.html)

---

<div class="post-metadata">

**Author:** ![zooey105](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/zooey105/32/5535_2.png) [@zooey105](https://discourse.processing.org/u/zooey105)\
**Post date:** [June 11, 2019, 11:16pm UTC](https://discourse.processing.org/t/apple-pencil-in-p5-js/9384/4 "2019-06-11T23:16:32Z")

</div>

This is super cool! If you’ve got a minute, do you know if pressurejs supports Wacom tablets? Just out of curiosity for those of us who don’t have an iPad pro, haha.

EDIT: It looks like they do if anyone’s curious, I’d be super interested to see how its sensitivity/latency compares against the apple pencil or a surface.
