# Coding Questions

**URL:** https://discourse.processing.org/c/p5js/p5js-questions/18.md?page=20

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

**Page:** 21

---

## [Responsive grid](https://discourse.processing.org/t/responsive-grid/29507)

<div class="topic-metadata">

**Author:** [@henryM](https://discourse.processing.org/u/henryM)\
**Replies:** 1\
**Last updated:** [April 20, 2021, 8:04am UTC](https://discourse.processing.org/t/responsive-grid/29507 "2021-04-20T08:04:33Z")

</div>

I am making a small little testing thing I am trying to make it so when the mouse is over it turns a different color here is the code. https://editor.p5js.org/Henhog1234/sketches/ehfcx4O9f I am probably doing everythi…

---

## [Need help: Grid with increasing number of columns + incremental greyscale gradient](https://discourse.processing.org/t/need-help-grid-with-increasing-number-of-columns-incremental-greyscale-gradient/29438)

<div class="topic-metadata">

**Author:** [@abk](https://discourse.processing.org/u/abk)\
**Replies:** 10\
**Last updated:** [April 19, 2021, 9:36pm UTC](https://discourse.processing.org/t/need-help-grid-with-increasing-number-of-columns-incremental-greyscale-gradient/29438 "2021-04-19T21:36:50Z")

</div>

Hi I’m trying to do something like this in p5: I’m a total beginner, so I think this should be pretty basic stuff for most :slight\_smile: So far I’ve got this snippet of code: function setup() { createCanvas(w…

---

## [How to use an image as a link between different html pages](https://discourse.processing.org/t/how-to-use-an-image-as-a-link-between-different-html-pages/29487)

<div class="topic-metadata">

**Author:** [@juju](https://discourse.processing.org/u/juju)\
**Replies:** 4\
**Last updated:** [April 19, 2021, 11:32am UTC](https://discourse.processing.org/t/how-to-use-an-image-as-a-link-between-different-html-pages/29487 "2021-04-19T11:32:55Z")

</div>

I see you can use createA() in P5 to add hyperlinks on texts, is there anyway to use an image as a hyperlink in P5? please format code with \</\> button \* homework policy \* asking questions

---

## [Not defined issue](https://discourse.processing.org/t/not-defined-issue/29476)

<div class="topic-metadata">

**Author:** [@YenX2](https://discourse.processing.org/u/YenX2)\
**Replies:** 3\
**Last updated:** [April 18, 2021, 8:05pm UTC](https://discourse.processing.org/t/not-defined-issue/29476 "2021-04-18T20:05:53Z")

</div>

Hi, I’ve been trying to figure out how to fix this. I keep getting an error message saying that Particle is not defined. type or paste code here let myParticle= \[\]; let buttonA let buttonH let buttonF let buttonB fu…

---

## [If statement in arrays](https://discourse.processing.org/t/if-statement-in-arrays/29454)

<div class="topic-metadata">

**Author:** [@henryM](https://discourse.processing.org/u/henryM)\
**Replies:** 3\
**Last updated:** [April 17, 2021, 6:38pm UTC](https://discourse.processing.org/t/if-statement-in-arrays/29454 "2021-04-17T18:38:39Z")

</div>

So I am making a prototype for my game to try and demonstrate what I am trying to do. https://editor.p5js.org/henhog123/sketches/B0QwRqpXj In the editor, you can see only one circle moves but I want all the circles to …

---

## [Cycle Images on Mouse Click P5Js](https://discourse.processing.org/t/cycle-images-on-mouse-click-p5js/29447)

<div class="topic-metadata">

**Author:** [@Wiltraveller](https://discourse.processing.org/u/Wiltraveller)\
**Replies:** 4\
**Last updated:** [April 17, 2021, 3:50pm UTC](https://discourse.processing.org/t/cycle-images-on-mouse-click-p5js/29447 "2021-04-17T15:50:36Z")

</div>

var img1; var img2; var img3; function preload() { img1 = loadImage("bckgrnd.png"); img2 = loadImage("moon.png"); img3 = loadImage("tuktuk2.png"); } function setup() { createCanvas(windowWidth, windowHeight…

---

## [How to resolve the delay after event occurs](https://discourse.processing.org/t/how-to-resolve-the-delay-after-event-occurs/29440)

<div class="topic-metadata">

**Author:** [@turtle](https://discourse.processing.org/u/turtle)\
**Replies:** 3\
**Last updated:** [April 17, 2021, 11:14am UTC](https://discourse.processing.org/t/how-to-resolve-the-delay-after-event-occurs/29440 "2021-04-17T11:14:26Z")

</div>

the code as following let bgColor = 200; let div; function setup() { createCanvas(windowWidth, windowHeight); background(bgColor); div = createDiv(); div.style("background","rgb(123, 0, 0, 0.1)"); div.style("…

---

## [P5.js camera movement control with keys, how to assign limits to it?](https://discourse.processing.org/t/p5-js-camera-movement-control-with-keys-how-to-assign-limits-to-it/29342)

<div class="topic-metadata">

**Author:** [@camila](https://discourse.processing.org/u/camila)\
**Replies:** 7\
**Last updated:** [April 14, 2021, 2:28pm UTC](https://discourse.processing.org/t/p5-js-camera-movement-control-with-keys-how-to-assign-limits-to-it/29342 "2021-04-14T14:28:31Z")

</div>

Hello people, I’m trying to set up a fully functional camera in my code that responds to movements assigned by the computer keys, that I’ve accomplished. Now I’m trying to assign a limit to those movements, for example:…

---

## [Local to global positions](https://discourse.processing.org/t/local-to-global-positions/29333)

<div class="topic-metadata">

**Author:** [@saul](https://discourse.processing.org/u/saul)\
**Replies:** 6\
**Last updated:** [April 13, 2021, 7:09pm UTC](https://discourse.processing.org/t/local-to-global-positions/29333 "2021-04-13T19:09:20Z")

</div>

Hi there; Been dipping my toe in a little p5 and ran into what might be a common problem with what I hope is a common answer (although I couldn’t find one) I have a sketch that creates a secondary canvas and centers it…

---

## [HTML, P5, and Material Design](https://discourse.processing.org/t/html-p5-and-material-design/29308)

<div class="topic-metadata">

**Author:** [@karenmsn](https://discourse.processing.org/u/karenmsn)\
**Replies:** 2\
**Last updated:** [April 13, 2021, 1:04pm UTC](https://discourse.processing.org/t/html-p5-and-material-design/29308 "2021-04-13T13:04:45Z")

</div>

I’m trying to follow this code https://codepen.io/katehummer/pen/jOyGzJp to create a carousel of instructions for the virtual installation I’m creating, but when I tried adding a new card to the list, it inserted it unde…

---

## [API POST error - not sure what's causing it](https://discourse.processing.org/t/api-post-error-not-sure-whats-causing-it/29311)

<div class="topic-metadata">

**Author:** [@psemme](https://discourse.processing.org/u/psemme)\
**Replies:** 2\
**Last updated:** [April 12, 2021, 10:45pm UTC](https://discourse.processing.org/t/api-post-error-not-sure-whats-causing-it/29311 "2021-04-12T22:45:52Z")

</div>

I’m trying to pull in RGB palette info from this cool color API - Colormind API - extracting colors from photos and video. I have it working in other API tools but when I place the code in P5 I get this error: Uncaugh…

---

## ['Exploding' or 'dissolving' an ellipse?](https://discourse.processing.org/t/exploding-or-dissolving-an-ellipse/29205)

<div class="topic-metadata">

**Author:** [@gctwnl](https://discourse.processing.org/u/gctwnl)\
**Replies:** 5\
**Last updated:** [April 12, 2021, 12:06pm UTC](https://discourse.processing.org/t/exploding-or-dissolving-an-ellipse/29205 "2021-04-12T12:06:35Z")

</div>

I am new to p5.js (and to Javascript to be honest) and I was wondering if I can (with the help of other libraries if need be) have an ellipse object either explode, go up in smoke, implode, or visually disappear-in-place…

---

## [Some please help me with my code](https://discourse.processing.org/t/some-please-help-me-with-my-code/29254)

<div class="topic-metadata">

**Author:** [@Bryce](https://discourse.processing.org/u/Bryce)\
**Replies:** 3\
**Last updated:** [April 10, 2021, 2:32am UTC](https://discourse.processing.org/t/some-please-help-me-with-my-code/29254 "2021-04-10T02:32:31Z")

</div>

Hi, my name is Bryce, I am confused about how to make the squares disappear once to circle hits them. Here is my code // circX is for the smaller circle let circX; // circY is for the smaller circle let circY; //b…

---

## [Help with my code](https://discourse.processing.org/t/help-with-my-code/29013)

<div class="topic-metadata">

**Author:** [@Bryce](https://discourse.processing.org/u/Bryce)\
**Replies:** 3\
**Last updated:** [April 9, 2021, 9:43pm UTC](https://discourse.processing.org/t/help-with-my-code/29013 "2021-04-09T21:43:04Z")

</div>

Hello, my name is Bryce, I have been working on a project for a while and I just cant get it. This is what I'm supposed to do: “Your job is to create a game where there is a row of boxes along the top of the canvas…

---

## [Qualtrics and p5.js](https://discourse.processing.org/t/qualtrics-and-p5-js/29184)

<div class="topic-metadata">

**Author:** [@Jwebstercrowd](https://discourse.processing.org/u/Jwebstercrowd)\
**Replies:** 2\
**Last updated:** [April 7, 2021, 11:52am UTC](https://discourse.processing.org/t/qualtrics-and-p5-js/29184 "2021-04-07T11:52:04Z")

</div>

Hey! I was wondering if anyone has had any success with implenting a p5 sketch inside of a Qualtrics survey? I have been unable to get it to work thus far, and now I’m wondering if it is even possible. I added the p5 lib…

---

## [P5.js basic webworkers tutorial](https://discourse.processing.org/t/p5-js-basic-webworkers-tutorial/29155)

<div class="topic-metadata">

**Author:** [@kris.dpd](https://discourse.processing.org/u/kris.dpd)\
**Replies:** 4\
**Last updated:** [April 7, 2021, 9:36am UTC](https://discourse.processing.org/t/p5-js-basic-webworkers-tutorial/29155 "2021-04-07T09:36:06Z")

</div>

Hi! I am having a bit of trouble getting webworkers to properly work with P5.js is anyone familiar with a basic getting started tutorial in P5.js? Here is a basic sketch but somehow the old response gets stuck in the b…

---

## [Glitch effect with or without pixels](https://discourse.processing.org/t/glitch-effect-with-or-without-pixels/13556)

<div class="topic-metadata">

**Author:** [@l3ehfar](https://discourse.processing.org/u/l3ehfar)\
**Replies:** 14\
**Last updated:** [April 6, 2021, 9:47pm UTC](https://discourse.processing.org/t/glitch-effect-with-or-without-pixels/13556 "2021-04-06T21:47:45Z")

</div>

I’ve been working on a project which has been developed with pure p5js code, but I wanna have a glitch effect as a reaction to sound though, as I know the actual glitch effect works much better on image pixels (although …

---

## [p5JS server side render - using node-canvas](https://discourse.processing.org/t/p5js-server-side-render-using-node-canvas/29126)

<div class="topic-metadata">

**Author:** [@DCsan](https://discourse.processing.org/u/DCsan)\
**Replies:** 4\
**Last updated:** [April 6, 2021, 7:53am UTC](https://discourse.processing.org/t/p5js-server-side-render-using-node-canvas/29126 "2021-04-06T07:53:09Z")

</div>

I’d like to render images from a P5 script, for preview thumbnails. Has someone got advice on that? The node-canvas library would seem to be a good fit for this, but not sure how p5 deals with things like the event loop…

---

## [TypeError: Cannot set property '0' of undefined](https://discourse.processing.org/t/typeerror-cannot-set-property-0-of-undefined/29139)

<div class="topic-metadata">

**Author:** [@xbix](https://discourse.processing.org/u/xbix)\
**Replies:** 6\
**Last updated:** [April 6, 2021, 7:30am UTC](https://discourse.processing.org/t/typeerror-cannot-set-property-0-of-undefined/29139 "2021-04-06T07:30:13Z")

</div>

In my constructor I define my variable like this: constructor(){ this.myvar = \[\]; } and then, inside a function, I init the array like this: initSutff(){ for (let i = 0; i \< labels.length; i++) { this.m…

---

## [Switch with createCheckbox()](https://discourse.processing.org/t/switch-with-createcheckbox/28945)

<div class="topic-metadata">

**Author:** [@Mem](https://discourse.processing.org/u/Mem)\
**Replies:** 10\
**Last updated:** [April 5, 2021, 1:41pm UTC](https://discourse.processing.org/t/switch-with-createcheckbox/28945 "2021-04-05T13:41:59Z")

</div>

Hi Again Sorry, I’m a beginner, I didn’t understand what was formatting the code. I hope now I will get some help :slightly\_smiling\_face: I would like to be able to select different circle A and B with a createCheckbox…

---

## [P5.js video upload into switch statement](https://discourse.processing.org/t/p5-js-video-upload-into-switch-statement/29107)

<div class="topic-metadata">

**Author:** [@empero1615](https://discourse.processing.org/u/empero1615)\
**Replies:** 5\
**Last updated:** [April 5, 2021, 7:18am UTC](https://discourse.processing.org/t/p5-js-video-upload-into-switch-statement/29107 "2021-04-05T07:18:45Z")

</div>

How can I upload a video into a switch statement and get it to play? I have referred to the video canvas example and have applied that code within my program but it still doesn’t run, I’m not sure if P5 allows me to uplo…

---

## [Detect p5 1.1.9 vs 1.0.0?](https://discourse.processing.org/t/detect-p5-1-1-9-vs-1-0-0/22920)

<div class="topic-metadata">

**Author:** [@grege2](https://discourse.processing.org/u/grege2)\
**Replies:** 5\
**Last updated:** [April 5, 2021, 6:19am UTC](https://discourse.processing.org/t/detect-p5-1-1-9-vs-1-0-0/22920 "2021-04-05T06:19:43Z")

</div>

Hi folks, Since p5.js 0.7.2 I’ve been able to distinguish what release I’m running on by checking that “typeof” some function or constant is “undefined” or not. This relies on new functions etc. being available to check…

---

## [Coding problem 123 (Messy Curve Draw)](https://discourse.processing.org/t/coding-problem-123-messy-curve-draw/29085)

<div class="topic-metadata">

**Author:** [@fxddf](https://discourse.processing.org/u/fxddf)\
**Replies:** 4\
**Last updated:** [April 4, 2021, 9:18am UTC](https://discourse.processing.org/t/coding-problem-123-messy-curve-draw/29085 "2021-04-04T09:18:23Z")

</div>

I found this code from the following site, but I do not see anything by changing the values. Can anyone help me?

---

## [globalCompositeOperation in P5](https://discourse.processing.org/t/globalcompositeoperation-in-p5/29105)

<div class="topic-metadata">

**Author:** [@hellonearthis](https://discourse.processing.org/u/hellonearthis)\
**Replies:** 1\
**Last updated:** [April 4, 2021, 6:55am UTC](https://discourse.processing.org/t/globalcompositeoperation-in-p5/29105 "2021-04-04T06:55:30Z")

</div>

I was watching the video below talk about the globalCompositeOperation And I wondered how this is used in P5.js It’s similar but different to (blendmode)\[ \<blend-mode\> - CSS: Cascading Style Sheets | MDN\] So I made th…

---

## [Is there a way to detect 2 key presses at once?](https://discourse.processing.org/t/is-there-a-way-to-detect-2-key-presses-at-once/29100)

<div class="topic-metadata">

**Author:** [@graph100](https://discourse.processing.org/u/graph100)\
**Replies:** 2\
**Last updated:** [April 3, 2021, 11:14pm UTC](https://discourse.processing.org/t/is-there-a-way-to-detect-2-key-presses-at-once/29100 "2021-04-03T23:14:39Z")

</div>

Hi, I’ve mainly been working in p5.js, and some time ago, I was porting one of my javascript games to processing and I noticed there isn’t really and equivalent in processing. I’ve tried: if (keyPressed) { switch key …

---

## [Help with 3d object transfiguration/distortion effect](https://discourse.processing.org/t/help-with-3d-object-transfiguration-distortion-effect/28795)

<div class="topic-metadata">

**Author:** [@senhorcodigo](https://discourse.processing.org/u/senhorcodigo)\
**Replies:** 3\
**Last updated:** [April 2, 2021, 11:32pm UTC](https://discourse.processing.org/t/help-with-3d-object-transfiguration-distortion-effect/28795 "2021-04-02T23:32:34Z")

</div>

Hello, I’m trying to a project where there is an interaction with a 3d object and the user, and the interaction being when the user moves/clicks his mouse the vertices of the object move randomly. The project is still …

---

## [Convert P5js shader to Java Processing shader](https://discourse.processing.org/t/convert-p5js-shader-to-java-processing-shader/29017)

<div class="topic-metadata">

**Author:** [@Flolo](https://discourse.processing.org/u/Flolo)\
**Replies:** 1\
**Last updated:** [March 31, 2021, 8:01pm UTC](https://discourse.processing.org/t/convert-p5js-shader-to-java-processing-shader/29017 "2021-03-31T20:01:53Z")

</div>

Hey, I saw this program the other day: The Programm Stupidly it is programmed in P5js but I would like to program the same in Processing Java… Could someone translate this for me? Thank you

---

## [Is noTint() not compatible with WEBGL?](https://discourse.processing.org/t/is-notint-not-compatible-with-webgl/28985)

<div class="topic-metadata">

**Author:** [@marcela](https://discourse.processing.org/u/marcela)\
**Replies:** 0\
**Last updated:** [March 30, 2021, 2:28pm UTC](https://discourse.processing.org/t/is-notint-not-compatible-with-webgl/28985 "2021-03-30T14:28:27Z")

</div>

Hi everyone, I just can’t use noTint() in WEBGL, but I wasn’t able to find any info about that. Is that really the case, or am I doing something wrong? I reproduced the issue that I am having in this sketch here: http…

---

## [Problem with faces obj](https://discourse.processing.org/t/problem-with-faces-obj/28961)

<div class="topic-metadata">

**Author:** [@pedrojateruel](https://discourse.processing.org/u/pedrojateruel)\
**Replies:** 5\
**Last updated:** [March 29, 2021, 9:42pm UTC](https://discourse.processing.org/t/problem-with-faces-obj/28961 "2021-03-29T21:42:38Z")

</div>

Good night . I have a problem when I export figures from blender in .obj. I can create the model in the canvas and it works, but vertex of the figure are not together. There is a gap between faces. I have the same pr…

---

## [Cannot read property 'split' of undefined](https://discourse.processing.org/t/cannot-read-property-split-of-undefined/28877)

<div class="topic-metadata">

**Author:** [@quargsgreene](https://discourse.processing.org/u/quargsgreene)\
**Replies:** 9\
**Last updated:** [March 29, 2021, 8:29pm UTC](https://discourse.processing.org/t/cannot-read-property-split-of-undefined/28877 "2021-03-29T20:29:44Z")

</div>

I am trying to create something which generates some gibberish from a box which the user inputs text and I keep getting the ‘cannot read property ‘split’ of undefined’ error when the mousePressed event fires. This error …

[Previous page](https://discourse.processing.org/c/p5js/p5js-questions/18.md?page=19)

[Next page](https://discourse.processing.org/c/p5js/p5js-questions/18.md?page=21)
