# p5.js

**URL:** https://discourse.processing.org/c/p5js/10.md?page=65

[Latest](https://discourse.processing.org/latest.md) · [Categories](https://discourse.processing.org/categories.md) · [Tags](https://discourse.processing.org/tags.md)

**Page:** 66

---

## [How to move pad with touch](https://discourse.processing.org/t/how-to-move-pad-with-touch/22506)

<div class="topic-metadata">

**Author:** [@bismarck](https://discourse.processing.org/u/bismarck)\
**Replies:** 2\
**Last updated:** [July 10, 2020, 10:00pm UTC](https://discourse.processing.org/t/how-to-move-pad-with-touch/22506 "2020-07-10T22:00:43Z")

</div>

let position1 = 100; let position2 = 100; function setup() { createCanvas(400, 400); } function draw() { background(220); rect(0,position2,10,100); rect(width-10,position1,10,100); if(mouseX \> width/2){…

---

## [Making a photo scanner with transforming picture](https://discourse.processing.org/t/making-a-photo-scanner-with-transforming-picture/22539)

<div class="topic-metadata">

**Author:** [@lin.liangchen](https://discourse.processing.org/u/lin.liangchen)\
**Replies:** 0\
**Last updated:** [July 10, 2020, 5:04pm UTC](https://discourse.processing.org/t/making-a-photo-scanner-with-transforming-picture/22539 "2020-07-10T17:04:30Z")

</div>

Hi everyone, I am new here. I am trying to program a code which is making a photo scanner, to scan the photo pixels with mouse moving. However, I change the photo size by ratio to make smaller, but the scanner only up…

---

## [Webgl 3d point mouse interaction](https://discourse.processing.org/t/webgl-3d-point-mouse-interaction/22526)

<div class="topic-metadata">

**Author:** [@nomad](https://discourse.processing.org/u/nomad)\
**Replies:** 2\
**Last updated:** [July 10, 2020, 4:26pm UTC](https://discourse.processing.org/t/webgl-3d-point-mouse-interaction/22526 "2020-07-10T16:26:34Z")

</div>

Hello there, I have a collection of points in 3d space. they are rotating around a center. Would like to create a simple mouse interaction where they change color when I hover the mouse on them. my code is as follows …

---

## [noFill() not working in p5js](https://discourse.processing.org/t/nofill-not-working-in-p5js/22416)

<div class="topic-metadata">

**Author:** [@CND](https://discourse.processing.org/u/CND)\
**Replies:** 11\
**Last updated:** [July 9, 2020, 7:29pm UTC](https://discourse.processing.org/t/nofill-not-working-in-p5js/22416 "2020-07-09T19:29:47Z")

</div>

noFill() in p5js is not working for me. Is this a bug?

---

## [How to use p5.js with my own IDE](https://discourse.processing.org/t/how-to-use-p5-js-with-my-own-ide/22509)

<div class="topic-metadata">

**Author:** [@Hookie](https://discourse.processing.org/u/Hookie)\
**Replies:** 3\
**Last updated:** [July 9, 2020, 7:09pm UTC](https://discourse.processing.org/t/how-to-use-p5-js-with-my-own-ide/22509 "2020-07-09T19:09:03Z")

</div>

Hi, everyone. I have so many problems about starting using p5.js in my local IDE and 8th-wall IDE(an AR js platform). I used online link: First, I’m curious that in the official examples, preload(), setup() … are onl…

---

## [Processing to p5js for a web page](https://discourse.processing.org/t/processing-to-p5js-for-a-web-page/22487)

<div class="topic-metadata">

**Author:** [@relindwto6](https://discourse.processing.org/u/relindwto6)\
**Replies:** 1\
**Last updated:** [July 8, 2020, 11:49pm UTC](https://discourse.processing.org/t/processing-to-p5js-for-a-web-page/22487 "2020-07-08T23:49:28Z")

</div>

Been using Processing for a few years. I’ve made a sketch that loads an audio file and is a visualizer that starts when you click on it. I want to turn this into a portfolio webpage with more of these visualizer objects,…

---

## [Question About Multiple Collisions At Once (Kinda)](https://discourse.processing.org/t/question-about-multiple-collisions-at-once-kinda/22461)

<div class="topic-metadata">

**Author:** [@The99thTroll](https://discourse.processing.org/u/The99thTroll)\
**Replies:** 7\
**Last updated:** [July 8, 2020, 9:20pm UTC](https://discourse.processing.org/t/question-about-multiple-collisions-at-once-kinda/22461 "2020-07-08T21:20:15Z")

</div>

So, I’m in the process of making a tower defense game. Currently the way it works is that when an enemy touches the collider of the tower, the tower locks on to that enemy and no others until that enemy is out of range o…

---

## [Does video.size() function doesn’t work properly for pixel manipulation](https://discourse.processing.org/t/does-video-size-function-doesn-t-work-properly-for-pixel-manipulation/22489)

<div class="topic-metadata">

**Author:** [@maddyna](https://discourse.processing.org/u/maddyna)\
**Replies:** 0\
**Last updated:** [July 8, 2020, 8:09pm UTC](https://discourse.processing.org/t/does-video-size-function-doesn-t-work-properly-for-pixel-manipulation/22489 "2020-07-08T20:09:30Z")

</div>

\<does video.size() function doesn’t work properly for pixel manipulation. the moment i am using it I am getting a black screen in the canvas though the video is running in the browser I am sending the code: let video; …

---

## [How to make a better zoom with orbitControl()?](https://discourse.processing.org/t/how-to-make-a-better-zoom-with-orbitcontrol/12978)

<div class="topic-metadata">

**Author:** [@NeilTheSeal](https://discourse.processing.org/u/NeilTheSeal)\
**Replies:** 4\
**Last updated:** [July 6, 2020, 5:48pm UTC](https://discourse.processing.org/t/how-to-make-a-better-zoom-with-orbitcontrol/12978 "2020-07-06T17:48:24Z")

</div>

I have been trying to figure out a way to adjust the sensitivity of the scroll wheel in WebGL mode, because zooming in and out on my sketch is extremely difficult and you have to be almost violent with your scroll wheel …

---

## [Can someone explain why there are trails for the ellipse?](https://discourse.processing.org/t/can-someone-explain-why-there-are-trails-for-the-ellipse/22455)

<div class="topic-metadata">

**Author:** [@BSiemens](https://discourse.processing.org/u/BSiemens)\
**Replies:** 5\
**Last updated:** [July 7, 2020, 6:58pm UTC](https://discourse.processing.org/t/can-someone-explain-why-there-are-trails-for-the-ellipse/22455 "2020-07-07T18:58:25Z")

</div>

https://p5js.org/examples/structure-create-graphics.html

---

## [Processing Desktop Editor and p5.js: \`The class "let" does not exist\`](https://discourse.processing.org/t/processing-desktop-editor-and-p5-js-the-class-let-does-not-exist/22454)

<div class="topic-metadata">

**Author:** [@Vertigo81](https://discourse.processing.org/u/Vertigo81)\
**Replies:** 2\
**Last updated:** [July 7, 2020, 6:43pm UTC](https://discourse.processing.org/t/processing-desktop-editor-and-p5-js-the-class-let-does-not-exist/22454 "2020-07-07T18:43:35Z")

</div>

Idiot question I’m sure… I can make things work fine on openprocessing.org, but when I try to run the same code on the desktop compiler it doesn’t recognize… Like, anything. Seems likely the issue is the bane of most…

---

## [Maximum image size saveable from offscreen buffer?](https://discourse.processing.org/t/maximum-image-size-saveable-from-offscreen-buffer/22429)

<div class="topic-metadata">

**Author:** [@grege2](https://discourse.processing.org/u/grege2)\
**Replies:** 5\
**Last updated:** [July 7, 2020, 7:05am UTC](https://discourse.processing.org/t/maximum-image-size-saveable-from-offscreen-buffer/22429 "2020-07-07T07:05:02Z")

</div>

Hi folks, I’m trying to verify and understand the maximum image size that can be saved from an offscreen createGraphics() buffer. Here’s a sketch I used to test it. https://editor.p5js.org/grege2/sketches/OchyJsPRY I …

---

## [Getting Right Click and Middle Mouse](https://discourse.processing.org/t/getting-right-click-and-middle-mouse/22422)

<div class="topic-metadata">

**Author:** [@SavageGarrett](https://discourse.processing.org/u/SavageGarrett)\
**Replies:** 1\
**Last updated:** [July 6, 2020, 9:17pm UTC](https://discourse.processing.org/t/getting-right-click-and-middle-mouse/22422 "2020-07-06T21:17:09Z")

</div>

I am working in a browser i.e. including my sketch.js file in an html document. Using the mouseClicked() function I can get left clicks but mouseButton only gives me left click. I would like to be able to right click o…

---

## [Is it possible to check if a sprite was destroyed?](https://discourse.processing.org/t/is-it-possible-to-check-if-a-sprite-was-destroyed/22369)

<div class="topic-metadata">

**Author:** [@The99thTroll](https://discourse.processing.org/u/The99thTroll)\
**Replies:** 1\
**Last updated:** [July 5, 2020, 8:44am UTC](https://discourse.processing.org/t/is-it-possible-to-check-if-a-sprite-was-destroyed/22369 "2020-07-05T08:44:03Z")

</div>

The title basically says it all. Is there a way to detect if a sprite is destroyed so I can manipulate a different sprite later on?

---

## [How to change a line stroke after its been set?](https://discourse.processing.org/t/how-to-change-a-line-stroke-after-its-been-set/22386)

<div class="topic-metadata">

**Author:** [@FireMe](https://discourse.processing.org/u/FireMe)\
**Replies:** 5\
**Last updated:** [July 4, 2020, 6:40pm UTC](https://discourse.processing.org/t/how-to-change-a-line-stroke-after-its-been-set/22386 "2020-07-04T18:40:46Z")

</div>

Hi All, Im completely new here and to code tbh, I followed this tutorial on a gift wrapping algorithm, which of course was fairly easy to follow, problems arise when i want to do something different to the tutorial. The…

---

## [Mouse dragged in P5js](https://discourse.processing.org/t/mouse-dragged-in-p5js/22066)

<div class="topic-metadata">

**Author:** [@AKAC](https://discourse.processing.org/u/AKAC)\
**Replies:** 6\
**Last updated:** [July 4, 2020, 3:08pm UTC](https://discourse.processing.org/t/mouse-dragged-in-p5js/22066 "2020-07-04T15:08:33Z")

</div>

Hi I’m new in P5 and need a help with “mouse dragged” my code is: let imgB; let imgC; let imgD; let sz = 70 let y = 0; let x = 0; let y1 = 0; let x1 = 0; let y2 = 0; let x2 = 0; let startX = 0; let startY =…

---

## [Can someone tell me what is wrong with my conversion of this code?](https://discourse.processing.org/t/can-someone-tell-me-what-is-wrong-with-my-conversion-of-this-code/22370)

<div class="topic-metadata">

**Author:** [@tinkrit](https://discourse.processing.org/u/tinkrit)\
**Replies:** 1\
**Last updated:** [July 4, 2020, 1:17am UTC](https://discourse.processing.org/t/can-someone-tell-me-what-is-wrong-with-my-conversion-of-this-code/22370 "2020-07-04T01:17:36Z")

</div>

// // Conversione in P5.js di "Quasicrystals as sums of waves in the plane" // http://mainisusuallyafunction.blogspot.it/2011/10/quasicrystals-as-sums-of-waves-in-plane.html // var dimPix = 0.4; var numeroLivelli = 7; …

---

## [How to access p5js functions when using ES6 modules](https://discourse.processing.org/t/how-to-access-p5js-functions-when-using-es6-modules/21359)

<div class="topic-metadata">

**Author:** [@dansumption](https://discourse.processing.org/u/dansumption)\
**Replies:** 6\
**Last updated:** [July 3, 2020, 3:36pm UTC](https://discourse.processing.org/t/how-to-access-p5js-functions-when-using-es6-modules/21359 "2020-07-03T15:36:39Z")

</div>

I am trying to write an app using ES6 modules and the voronoi library, and in this environment all of the processing instance functions (background, stroke, random, etc) are not in the module’s namespace. I have got aro…

---

## [Do ... while ... throws 'Unexpected token '{' when line break inside](https://discourse.processing.org/t/do-while-throws-unexpected-token-when-line-break-inside/22352)

<div class="topic-metadata">

**Author:** [@Laurent](https://discourse.processing.org/u/Laurent)\
**Replies:** 4\
**Last updated:** [July 3, 2020, 2:34pm UTC](https://discourse.processing.org/t/do-while-throws-unexpected-token-when-line-break-inside/22352 "2020-07-03T14:34:03Z")

</div>

Hi everyone, Maybe I’m very tired and have a a dummy question but I’m in trouble with a simple do … while … statement… The following one: var number; do{ number = random(1, 101); print(number); …

---

## [Error with video= IndexSizeError: Index or size is negative or greater than the allowed amount](https://discourse.processing.org/t/error-with-video-indexsizeerror-index-or-size-is-negative-or-greater-than-the-allowed-amount/22306)

<div class="topic-metadata">

**Author:** [@akenaton](https://discourse.processing.org/u/akenaton)\
**Replies:** 1\
**Last updated:** [July 2, 2020, 5:18pm UTC](https://discourse.processing.org/t/error-with-video-indexsizeerror-index-or-size-is-negative-or-greater-than-the-allowed-amount/22306 "2020-07-02T17:18:01Z")

</div>

i have a sketch in which there is a video; not any problem with the code (it seems!) - When i run the sketch i get often and not always this error: “IndexSizeError: Index or size is negative or greater than the allowed …

---

## [TypeError: arraySequence\[0\] is undefined](https://discourse.processing.org/t/typeerror-arraysequence-0-is-undefined/22005)

<div class="topic-metadata">

**Author:** [@antocreo](https://discourse.processing.org/u/antocreo)\
**Replies:** 7\
**Last updated:** [July 3, 2020, 9:42am UTC](https://discourse.processing.org/t/typeerror-arraysequence-0-is-undefined/22005 "2020-07-03T09:42:36Z")

</div>

Hi all, I am getting this error since Firefox update to 77.0.1 TypeError: arraySequence\[0\] is undefined I think it might related to the p5-sound library as it’s the only place where I’ve found arraySequence\[0\]. I’v…

---

## [Setup method runs twice](https://discourse.processing.org/t/setup-method-runs-twice/21275)

<div class="topic-metadata">

**Author:** [@dansumption](https://discourse.processing.org/u/dansumption)\
**Replies:** 3\
**Last updated:** [July 2, 2020, 6:36pm UTC](https://discourse.processing.org/t/setup-method-runs-twice/21275 "2020-07-02T18:36:17Z")

</div>

My p5js app runs the setup function twice. I have stripped the whole thing down as much as possible, and it’s still happening. This is messing with my app because (a) I wish to run some fairly heavy operations in setup a…

---

## [Referencing functions within object properties does not work](https://discourse.processing.org/t/referencing-functions-within-object-properties-does-not-work/22150)

<div class="topic-metadata">

**Author:** [@kdmb](https://discourse.processing.org/u/kdmb)\
**Replies:** 11\
**Last updated:** [July 2, 2020, 1:13pm UTC](https://discourse.processing.org/t/referencing-functions-within-object-properties-does-not-work/22150 "2020-07-02T13:13:56Z")

</div>

When I press a key, I have the following: function action1 () { // Do some action. } keys = { ArrowUp: action1; } // Function from P5.js function keyPressed () { console.log( \`Key ${key} pressed!\` ); if ( …

---

## [Multiple html pages and CSS sketch with editor.p5js.org](https://discourse.processing.org/t/multiple-html-pages-and-css-sketch-with-editor-p5js-org/22294)

<div class="topic-metadata">

**Author:** [@Laurent](https://discourse.processing.org/u/Laurent)\
**Replies:** 3\
**Last updated:** [July 1, 2020, 7:27pm UTC](https://discourse.processing.org/t/multiple-html-pages-and-css-sketch-with-editor-p5js-org/22294 "2020-07-01T19:27:21Z")

</div>

Hi everybody, I’ve used the p5.js online editor with my students for remote teaching during the covid19 period. And it’s really a great tool that simplify programming learning! Thanks a lot all its developpers! Teachin…

---

## [Converting inputs into int types](https://discourse.processing.org/t/converting-inputs-into-int-types/22276)

<div class="topic-metadata">

**Author:** [@olorin](https://discourse.processing.org/u/olorin)\
**Replies:** 4\
**Last updated:** [July 1, 2020, 11:13am UTC](https://discourse.processing.org/t/converting-inputs-into-int-types/22276 "2020-07-01T11:13:14Z")

</div>

I’m trying to take in user number inputs, convert them into int types, multiply, convert the outcome back into a string, and print this out. I keep getting the Not a Number result when ever i try int(input.value()). does…

---

## [Saturation returning the wrong values](https://discourse.processing.org/t/saturation-returning-the-wrong-values/22286)

<div class="topic-metadata">

**Author:** [@JoeMcKay](https://discourse.processing.org/u/JoeMcKay)\
**Replies:** 2\
**Last updated:** [July 1, 2020, 8:41am UTC](https://discourse.processing.org/t/saturation-returning-the-wrong-values/22286 "2020-07-01T08:41:49Z")

</div>

Hi all. I’m trying to make a color picker and ran into a bug - saturation() isn’t giving me the correct values. I created a gradient using hsb color. When I mouseOver the gradient and use get(mouseX, mouseY) to collect…

---

## [Make line shape fade away after x seconds](https://discourse.processing.org/t/make-line-shape-fade-away-after-x-seconds/22233)

<div class="topic-metadata">

**Author:** [@arala22](https://discourse.processing.org/u/arala22)\
**Replies:** 4\
**Last updated:** [June 30, 2020, 5:47pm UTC](https://discourse.processing.org/t/make-line-shape-fade-away-after-x-seconds/22233 "2020-06-30T17:47:43Z")

</div>

whats the best way to fade a line out? I have this here: https://codepen.io/itsMeAra/pen/e6ebe0dec2d370f50217809c547052e7 Trying to figure out how to make the line fade away after .5 seconds to make sort of a trailing …

---

## [Pixel correspondence with live capture](https://discourse.processing.org/t/pixel-correspondence-with-live-capture/22248)

<div class="topic-metadata">

**Author:** [@maddyna](https://discourse.processing.org/u/maddyna)\
**Replies:** 4\
**Last updated:** [June 30, 2020, 11:24am UTC](https://discourse.processing.org/t/pixel-correspondence-with-live-capture/22248 "2020-06-30T11:24:03Z")

</div>

\<I have asked this question but not getting a successful answer.Tring to scale the video feed from the capture object into a small size and then mapping it into a larger canvas but some how even 1:1 pixel manipulation d…

---

## [Using sound classification to trigger a camera?](https://discourse.processing.org/t/using-sound-classification-to-trigger-a-camera/22259)

<div class="topic-metadata">

**Author:** [@FloydW2](https://discourse.processing.org/u/FloydW2)\
**Replies:** 2\
**Last updated:** [June 30, 2020, 7:18am UTC](https://discourse.processing.org/t/using-sound-classification-to-trigger-a-camera/22259 "2020-06-30T07:18:12Z")

</div>

Hi All, I’m a bit new to all of this, and working with my kid to try and figure something out. We’ve followed the Coding Train Teachable Machine Sound Classification tutorial, and got it done while having a ton of fun.…

---

## [How do I make a sprite rotate to face another sprite?](https://discourse.processing.org/t/how-do-i-make-a-sprite-rotate-to-face-another-sprite/22266)

<div class="topic-metadata">

**Author:** [@The99thTroll](https://discourse.processing.org/u/The99thTroll)\
**Replies:** 3\
**Last updated:** [June 30, 2020, 1:20am UTC](https://discourse.processing.org/t/how-do-i-make-a-sprite-rotate-to-face-another-sprite/22266 "2020-06-30T01:20:16Z")

</div>

I’m working on a tower defense game but I am unable to find a way for my towers to rotate to look at the current enemy they’re targeting. Any solutions?

[Previous page](https://discourse.processing.org/c/p5js/10.md?page=64)

[Next page](https://discourse.processing.org/c/p5js/10.md?page=66)
