# Coding Questions

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

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

**Page:** 10

---

## [Update cursor immediately before and after a long loop](https://discourse.processing.org/t/update-cursor-immediately-before-and-after-a-long-loop/37867)

<div class="topic-metadata">

**Author:** [@nemecsek69](https://discourse.processing.org/u/nemecsek69)\
**Replies:** 2\
**Last updated:** [July 8, 2022, 11:10am UTC](https://discourse.processing.org/t/update-cursor-immediately-before-and-after-a-long-loop/37867 "2022-07-08T11:10:43Z")

</div>

JS newbie here. This is an extreme simplification of the real code but the general behavior is the same: after clicking the button I want to change the cursor to “wait”, execute a blocking loop for 3 seconds, and then r…

---

## [Url stream to canvas / frame updating](https://discourse.processing.org/t/url-stream-to-canvas-frame-updating/37810)

<div class="topic-metadata">

**Author:** [@Sofie](https://discourse.processing.org/u/Sofie)\
**Replies:** 8\
**Last updated:** [July 3, 2022, 6:27pm UTC](https://discourse.processing.org/t/url-stream-to-canvas-frame-updating/37810 "2022-07-03T18:27:25Z")

</div>

Hi, i’m struggeling to write a stream to the canvas. I can get one frame every time the sketch loads but its not updating the variable. My thought was that if i call image() in draw() it updates every cycle, but it doesn…

---

## [CreateElement() and Clear() not defined on page load even though it is called in function setup()](https://discourse.processing.org/t/createelement-and-clear-not-defined-on-page-load-even-though-it-is-called-in-function-setup/37733)

<div class="topic-metadata">

**Author:** [@bill.le](https://discourse.processing.org/u/bill.le)\
**Replies:** 1\
**Last updated:** [June 28, 2022, 4:30pm UTC](https://discourse.processing.org/t/createelement-and-clear-not-defined-on-page-load-even-though-it-is-called-in-function-setup/37733 "2022-06-28T16:30:54Z")

</div>

Hi! I’m currently working on a project (a chrome extension) that loads the canvas onto any site so I can draw on it. However, at random times, I would get errors saying that CreateElement() or Clear() is not defined. M…

---

## [Converting coding challenge 'Self-avoiding walk backtracing' from p5.js to Processing (Java)](https://discourse.processing.org/t/converting-coding-challenge-self-avoiding-walk-backtracing-from-p5-js-to-processing-java/35047)

<div class="topic-metadata">

**Author:** [@psamead](https://discourse.processing.org/u/psamead)\
**Replies:** 20\
**Last updated:** [June 25, 2022, 1:52am UTC](https://discourse.processing.org/t/converting-coding-challenge-self-avoiding-walk-backtracing-from-p5-js-to-processing-java/35047 "2022-06-25T01:52:15Z")

</div>

Hi my friends, I am trying to learn coding challenge Self-avoiding walk backtracing from Denial’s video 26:40 ; And converting the P5.js code to processing(java) code. But my code seems it is struggling on getting the a…

---

## [Environment mapping](https://discourse.processing.org/t/environment-mapping/37678)

<div class="topic-metadata">

**Author:** [@DaveH](https://discourse.processing.org/u/DaveH)\
**Replies:** 6\
**Last updated:** [June 22, 2022, 5:21pm UTC](https://discourse.processing.org/t/environment-mapping/37678 "2022-06-22T17:21:44Z")

</div>

Hi, I’m trying to use cubemaps in P5, they seem to work OK if I get the gl context, like const IDcanvas = document.getElementById("canvas"); gl = IDcanvas.getContext("webgl"); … and do the OpenGL TEXTURE\_CUBE\_MAP st…

---

## [How do I smoothly reduce the size of a large image?](https://discourse.processing.org/t/how-do-i-smoothly-reduce-the-size-of-a-large-image/37624)

<div class="topic-metadata">

**Author:** [@Chi3010](https://discourse.processing.org/u/Chi3010)\
**Replies:** 4\
**Last updated:** [June 21, 2022, 12:22pm UTC](https://discourse.processing.org/t/how-do-i-smoothly-reduce-the-size-of-a-large-image/37624 "2022-06-21T12:22:40Z")

</div>

Hello!!! I am having a simple problem. When I generate a large image with p5.graphics and then display it at a reduced size, it does not display nicely. For example, the following code generates p5.graphics with a siz…

---

## [Draw tinted image only once when it is changed with CreateFileInput](https://discourse.processing.org/t/draw-tinted-image-only-once-when-it-is-changed-with-createfileinput/37510)

<div class="topic-metadata">

**Author:** [@Annemiek](https://discourse.processing.org/u/Annemiek)\
**Replies:** 2\
**Last updated:** [June 20, 2022, 1:17pm UTC](https://discourse.processing.org/t/draw-tinted-image-only-once-when-it-is-changed-with-createfileinput/37510 "2022-06-20T13:17:37Z")

</div>

Hi! I’m quite new to programming and I’m trying to make a poster generator, therefore I want people to be able to upload an image which needs to have a tint. On top of that image there are elements like circles and text…

---

## [How to only play animation when deleting and creating new object](https://discourse.processing.org/t/how-to-only-play-animation-when-deleting-and-creating-new-object/37643)

<div class="topic-metadata">

**Author:** [@acorns](https://discourse.processing.org/u/acorns)\
**Replies:** 1\
**Last updated:** [June 19, 2022, 10:56pm UTC](https://discourse.processing.org/t/how-to-only-play-animation-when-deleting-and-creating-new-object/37643 "2022-06-19T22:56:34Z")

</div>

Hi guys, I am creating a cherry blossom branch where you add a new flower object (via pressing z key) and delete flower object (via pressing m key). I want to make it before it display(), it plays a blooming animation wh…

---

## [Set focus on canvas](https://discourse.processing.org/t/set-focus-on-canvas/37617)

<div class="topic-metadata">

**Author:** [@J\_Silva](https://discourse.processing.org/u/J_Silva)\
**Replies:** 5\
**Last updated:** [June 18, 2022, 3:02pm UTC](https://discourse.processing.org/t/set-focus-on-canvas/37617 "2022-06-18T15:02:41Z")

</div>

Hi. In my project, I want to select shapes with radio buttons and move them with my keyboard arrow keys. The problem is that I need to click on the canvas after each button choice, or else the radio buttons will altern…

---

## [Custom shape creates negative space when overlapping itself in WebGL mode](https://discourse.processing.org/t/custom-shape-creates-negative-space-when-overlapping-itself-in-webgl-mode/37262)

<div class="topic-metadata">

**Author:** [@neel](https://discourse.processing.org/u/neel)\
**Replies:** 1\
**Last updated:** [June 15, 2022, 11:22pm UTC](https://discourse.processing.org/t/custom-shape-creates-negative-space-when-overlapping-itself-in-webgl-mode/37262 "2022-06-15T23:22:46Z")

</div>

I’ve got a script that I’m trying to port from 2d mode to webgl mode, but the shapes are not behaving as expected. The following isn’t my script, but it’s a demonstration of the problem I run into. When I create a custom…

---

## [Compile Error in Java Program?](https://discourse.processing.org/t/compile-error-in-java-program/37533)

<div class="topic-metadata">

**Author:** [@shivambhatele](https://discourse.processing.org/u/shivambhatele)\
**Replies:** 1\
**Last updated:** [June 14, 2022, 12:26pm UTC](https://discourse.processing.org/t/compile-error-in-java-program/37533 "2022-06-14T12:26:40Z")

</div>

Hello All, I’ve recently faced some issues… I’ve been following some online tutorials and added the code from given source, I modify it a little, and it doesn’t work. First Java code which compiles on Interviewbit compi…

---

## [Help with Input Text Boxes and Arrays](https://discourse.processing.org/t/help-with-input-text-boxes-and-arrays/37456)

<div class="topic-metadata">

**Author:** [@Chigoz](https://discourse.processing.org/u/Chigoz)\
**Replies:** 2\
**Last updated:** [June 12, 2022, 1:33pm UTC](https://discourse.processing.org/t/help-with-input-text-boxes-and-arrays/37456 "2022-06-12T13:33:11Z")

</div>

Hi guys, please I need your help. I developed this app but it is not working as intended. If a set of values are imputed and one calculation is performed, a result is gotten, but if I edit the values in the text box and …

---

## [Could someone tell me why this isn't working please?](https://discourse.processing.org/t/could-someone-tell-me-why-this-isnt-working-please/37468)

<div class="topic-metadata">

**Author:** [@locky.mcdonald](https://discourse.processing.org/u/locky.mcdonald)\
**Replies:** 2\
**Last updated:** [June 12, 2022, 5:37am UTC](https://discourse.processing.org/t/could-someone-tell-me-why-this-isnt-working-please/37468 "2022-06-12T05:37:07Z")

</div>

// I know its a bit all over the place, but any little help would be much appreciated. The background is supposed to fade from cream to black and back while a circle moves up and down the screen, behind the waves at the …

---

## [Variable scope, \<script\> tage with type="module" option? (firebase)](https://discourse.processing.org/t/variable-scope-script-tage-with-type-module-option-firebase/37477)

<div class="topic-metadata">

**Author:** [@schuelaw](https://discourse.processing.org/u/schuelaw)\
**Replies:** 2\
**Last updated:** [June 11, 2022, 6:46pm UTC](https://discourse.processing.org/t/variable-scope-script-tage-with-type-module-option-firebase/37477 "2022-06-11T18:46:32Z")

</div>

I’m trying to use a firebase database in p5js to read and write a high score table for a game. I followed Shiffman’s Firebase: Saving Data - Programming with Text video, but it’s now out of date. I’m trying to build an e…

---

## [Fade between random colours for a background](https://discourse.processing.org/t/fade-between-random-colours-for-a-background/1433)

<div class="topic-metadata">

**Author:** [@Carpece](https://discourse.processing.org/u/Carpece)\
**Replies:** 13\
**Last updated:** [June 10, 2022, 11:15am UTC](https://discourse.processing.org/t/fade-between-random-colours-for-a-background/1433 "2022-06-10T11:15:49Z")

</div>

Hi, I’m trying to design a fading transition between random colours for the background (based on time). I thought it could be done with frameRate, but doesn’t respond. Any suggestion? Thanks in advance.

---

## [Using p5.js to generate SVG markup from a module](https://discourse.processing.org/t/using-p5-js-to-generate-svg-markup-from-a-module/37360)

<div class="topic-metadata">

**Author:** [@blundin](https://discourse.processing.org/u/blundin)\
**Replies:** 1\
**Last updated:** [June 8, 2022, 6:50pm UTC](https://discourse.processing.org/t/using-p5-js-to-generate-svg-markup-from-a-module/37360 "2022-06-08T18:50:53Z")

</div>

Hello all! I am an experienced web developer who is brand new to p5.js and generative art in general. I’ve spent several hours searching around for an answer to this question, and I suspect I am just thinking about this …

---

## [createGraphics referencing existing canvas context](https://discourse.processing.org/t/creategraphics-referencing-existing-canvas-context/21067)

<div class="topic-metadata">

**Author:** [@vheun](https://discourse.processing.org/u/vheun)\
**Replies:** 4\
**Last updated:** [June 8, 2022, 2:24pm UTC](https://discourse.processing.org/t/creategraphics-referencing-existing-canvas-context/21067 "2022-06-08T14:24:33Z")

</div>

Is there an easy way to bind an existing html canvas to the Graphics object you create with createGraphics()? Example: I have an existing painted 2D canvas that I would like to draw via image() into my existing WEBGL ca…

---

## [Rotate(); does not work in double for loop in createGraphics canvas](https://discourse.processing.org/t/rotate-does-not-work-in-double-for-loop-in-creategraphics-canvas/37304)

<div class="topic-metadata">

**Author:** [@Annemiek](https://discourse.processing.org/u/Annemiek)\
**Replies:** 3\
**Last updated:** [June 3, 2022, 8:12pm UTC](https://discourse.processing.org/t/rotate-does-not-work-in-double-for-loop-in-creategraphics-canvas/37304 "2022-06-03T20:12:24Z")

</div>

hi! I’m a trying to make a poster generator inside P5.js. I’m quite new to programming and for every new step I watch tutorials so I know what to do. Right now I am facing a problem with rotating my ellipses. At the mom…

---

## [Text array and size with function](https://discourse.processing.org/t/text-array-and-size-with-function/37291)

<div class="topic-metadata">

**Author:** [@luciaromancanivell](https://discourse.processing.org/u/luciaromancanivell)\
**Replies:** 1\
**Last updated:** [June 2, 2022, 10:03pm UTC](https://discourse.processing.org/t/text-array-and-size-with-function/37291 "2022-06-02T22:03:29Z")

</div>

Hello, I am trying to do this… And I have the following so far… how could I change the width depending on the word? so sorry for the many messages, thanks very much! var parrafo = "This is big and this small"; var …

---

## [Confusing Type Error](https://discourse.processing.org/t/confusing-type-error/37253)

<div class="topic-metadata">

**Author:** [@shodai](https://discourse.processing.org/u/shodai)\
**Replies:** 2\
**Last updated:** [May 31, 2022, 5:30pm UTC](https://discourse.processing.org/t/confusing-type-error/37253 "2022-05-31T17:30:45Z")

</div>

I am working on a project which is a game when a player circle goes around and eats other circles. I feel like I am really close to having everything working but when it gets down to the last circle remaining, I get a ty…

---

## [Word in array counter](https://discourse.processing.org/t/word-in-array-counter/37238)

<div class="topic-metadata">

**Author:** [@luciaromancanivell](https://discourse.processing.org/u/luciaromancanivell)\
**Replies:** 3\
**Last updated:** [May 31, 2022, 12:41pm UTC](https://discourse.processing.org/t/word-in-array-counter/37238 "2022-05-31T12:41:52Z")

</div>

please format code with \</\> button \* homework policy \* asking questions Hello, I am getting a bit confused here… I need to count how many times the word imagine shows up in the array but I do not know how to create t…

---

## [How to rotate view (cube interior) with mobile device gyroscope? - Issues with interaction](https://discourse.processing.org/t/how-to-rotate-view-cube-interior-with-mobile-device-gyroscope-issues-with-interaction/37227)

<div class="topic-metadata">

**Author:** [@jimmy](https://discourse.processing.org/u/jimmy)\
**Replies:** 0\
**Last updated:** [May 30, 2022, 1:59pm UTC](https://discourse.processing.org/t/how-to-rotate-view-cube-interior-with-mobile-device-gyroscope-issues-with-interaction/37227 "2022-05-30T13:59:31Z")

</div>

I’ve been working on a demo in P5.js that would display the inside of a cube with rotation followed by the rotation of a mobile device. We could call this poor-mans-AR, as I don’t need a camera feed, just the rotation. T…

---

## [Combining textToPoints with Daniel Shiffman’s Space Colonization Algorithm to create leaves](https://discourse.processing.org/t/combining-texttopoints-with-daniel-shiffman-s-space-colonization-algorithm-to-create-leaves/37138)

<div class="topic-metadata">

**Author:** [@\_tt\_tt](https://discourse.processing.org/u/_tt_tt)\
**Replies:** 1\
**Last updated:** [May 27, 2022, 12:40pm UTC](https://discourse.processing.org/t/combining-texttopoints-with-daniel-shiffman-s-space-colonization-algorithm-to-create-leaves/37138 "2022-05-27T12:40:50Z")

</div>

Hello! I am trying to create a project where i want to combine Daniel Shiffmans code from his Coding Challenge and a textToPoints Function. I want to use the points from the texttopoints array as leaves instead of his ra…

---

## [Need help w/ infinite world w/ random numbers](https://discourse.processing.org/t/need-help-w-infinite-world-w-random-numbers/37086)

<div class="topic-metadata">

**Author:** [@Voleia](https://discourse.processing.org/u/Voleia)\
**Replies:** 18\
**Last updated:** [May 26, 2022, 5:05pm UTC](https://discourse.processing.org/t/need-help-w-infinite-world-w-random-numbers/37086 "2022-05-26T17:05:22Z")

</div>

Hello. So, I am trying to make a program that generates an infinite world where each block has a 50% chance of being either blue or red. The program I have works fine when I move side to side, but when I move up and down…

---

## [How do I fix the buttons, I want the music to not play at first but then when you click the buttons it plays its respective music that is attached to the buttons?](https://discourse.processing.org/t/how-do-i-fix-the-buttons-i-want-the-music-to-not-play-at-first-but-then-when-you-click-the-buttons-it-plays-its-respective-music-that-is-attached-to-the-buttons/37098)

<div class="topic-metadata">

**Author:** [@matthew3032](https://discourse.processing.org/u/matthew3032)\
**Replies:** 0\
**Last updated:** [May 26, 2022, 3:50am UTC](https://discourse.processing.org/t/how-do-i-fix-the-buttons-i-want-the-music-to-not-play-at-first-but-then-when-you-click-the-buttons-it-plays-its-respective-music-that-is-attached-to-the-buttons/37098 "2022-05-26T03:50:46Z")

</div>

let buttons = \["Its Yours", "Dance On My Skin", "East of Eden", "Loathe"\]; let img; let font; let fft; let freqs = \["bass", "lowMid", "mid", "highMid", "treble"\]; let song1; let song2; let song3; let song4; function pre…

---

## [How to organize radio buttons in separate lines?](https://discourse.processing.org/t/how-to-organize-radio-buttons-in-separate-lines/10041)

<div class="topic-metadata">

**Author:** [@togo](https://discourse.processing.org/u/togo)\
**Replies:** 7\
**Last updated:** [May 23, 2022, 5:41pm UTC](https://discourse.processing.org/t/how-to-organize-radio-buttons-in-separate-lines/10041 "2022-05-23T17:41:41Z")

</div>

Hello, I’m currently working on radio buttons. Right now, I have the following code. gender = createRadio(); gender.option('male'); gender.option('female'); gender.option('prefer not to say'); gender.position(10, 30);…

---

## [Accessing local elements in another function in p5js](https://discourse.processing.org/t/accessing-local-elements-in-another-function-in-p5js/36978)

<div class="topic-metadata">

**Author:** [@lvndr](https://discourse.processing.org/u/lvndr)\
**Replies:** 0\
**Last updated:** [May 20, 2022, 5:20am UTC](https://discourse.processing.org/t/accessing-local-elements-in-another-function-in-p5js/36978 "2022-05-20T05:20:17Z")

</div>

I am pretty new to p5js and website building, I am doing a project for uni-related to emotion sensing Ai, basically, it generates recipes based on your emotion. I have built a random recipe generator but I need to append…

---

## [Differences between image(), createImage and createImg()](https://discourse.processing.org/t/differences-between-image-createimage-and-createimg/36913)

<div class="topic-metadata">

**Author:** [@teemee](https://discourse.processing.org/u/teemee)\
**Replies:** 0\
**Last updated:** [May 17, 2022, 7:33am UTC](https://discourse.processing.org/t/differences-between-image-createimage-and-createimg/36913 "2022-05-17T07:33:10Z")

</div>

I am curious about these three image functions image(); createImg(); createImage(); I have read the reference pages but still want some clear explanation. Is the creatImage() works with pixel related graphic and the …

---

## [Typing effect p5js](https://discourse.processing.org/t/typing-effect-p5js/36875)

<div class="topic-metadata">

**Author:** [@luciaromancanivell](https://discourse.processing.org/u/luciaromancanivell)\
**Replies:** 1\
**Last updated:** [May 13, 2022, 6:42pm UTC](https://discourse.processing.org/t/typing-effect-p5js/36875 "2022-05-13T18:42:56Z")

</div>

Hello, Sorry to bother you again, I am in a programming class and for our homework trying to animate and make a typography effect that repeats itself but I am getting a bit confused, any help? Thank you! var canvasWH = …

---

## [Replicating text](https://discourse.processing.org/t/replicating-text/36853)

<div class="topic-metadata">

**Author:** [@luciaromancanivell](https://discourse.processing.org/u/luciaromancanivell)\
**Replies:** 4\
**Last updated:** [May 13, 2022, 2:46pm UTC](https://discourse.processing.org/t/replicating-text/36853 "2022-05-13T14:46:10Z")

</div>

please format code with \</\> button \* homework policy \* asking questions Hello again, I am working on a school project where we have to create this with a loop… but I can only get a dark blur, here is the result I ne…

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

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