# Beginners

**URL:** https://discourse.processing.org/c/p5js/p5js-beginners/16.md?page=7

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

**Page:** 8

---

## [Browser not refreshing](https://discourse.processing.org/t/browser-not-refreshing/32448)

<div class="topic-metadata">

**Author:** [@philspitler](https://discourse.processing.org/u/philspitler)\
**Replies:** 3\
**Last updated:** [September 27, 2021, 7:50pm UTC](https://discourse.processing.org/t/browser-not-refreshing/32448 "2021-09-27T19:50:19Z")

</div>

I am having an issue with a P5 sketch that won’t update in Chrome. If I do my tweaks, re-upload via FTP and refresh my browser, the updates don’t show in Chrome. If I open a new incognito tab I do see the updates as ex…

---

## [What does it mean to say noise() returns a value between 0.0 and 1.0?](https://discourse.processing.org/t/what-does-it-mean-to-say-noise-returns-a-value-between-0-0-and-1-0/32387)

<div class="topic-metadata">

**Author:** [@norm\_krumpe](https://discourse.processing.org/u/norm_krumpe)\
**Replies:** 2\
**Last updated:** [September 23, 2021, 12:09pm UTC](https://discourse.processing.org/t/what-does-it-mean-to-say-noise-returns-a-value-between-0-0-and-1-0/32387 "2021-09-23T12:09:24Z")

</div>

The documentation for noise() simply says that the function returns a value between 0.0 and 1.0. By contrast, the documentation for random(n) says that the function returns a value between 0.0 (inclusive) and n (exclusi…

---

## [Remove Audio Library](https://discourse.processing.org/t/remove-audio-library/32381)

<div class="topic-metadata">

**Author:** [@philspitler](https://discourse.processing.org/u/philspitler)\
**Replies:** 2\
**Last updated:** [September 23, 2021, 4:06am UTC](https://discourse.processing.org/t/remove-audio-library/32381 "2021-09-23T04:06:43Z")

</div>

Hi, I am getting an audio error when using P5 in chrome. p5 The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page. I understand why I’m getting the error. I am not…

---

## [Upload image to p5 via a dialog box](https://discourse.processing.org/t/upload-image-to-p5-via-a-dialog-box/32291)

<div class="topic-metadata">

**Author:** [@philspitler](https://discourse.processing.org/u/philspitler)\
**Replies:** 8\
**Last updated:** [September 22, 2021, 5:41am UTC](https://discourse.processing.org/t/upload-image-to-p5-via-a-dialog-box/32291 "2021-09-22T05:41:25Z")

</div>

Hi, I am thinking of moving one of my Processing projects over to p5 and would like to have the user upload their own image to get processed. Is there a way to have a dialog box prompt a file upload? Thanks Phil

---

## [Autocomplete and documentation for "imported" p5js](https://discourse.processing.org/t/autocomplete-and-documentation-for-imported-p5js/31927)

<div class="topic-metadata">

**Author:** [@atcold](https://discourse.processing.org/u/atcold)\
**Replies:** 17\
**Last updated:** [September 20, 2021, 11:57pm UTC](https://discourse.processing.org/t/autocomplete-and-documentation-for-imported-p5js/31927 "2021-09-20T23:57:11Z")

</div>

I spent countless hours to get my editor (VSC) to autocomplete P5JS. This worked only after adding this line to the main script: import "./p5" Now everything is accessible only if prefixed by p5, and the editor autoco…

---

## [Resize Image question](https://discourse.processing.org/t/resize-image-question/32327)

<div class="topic-metadata">

**Author:** [@philspitler](https://discourse.processing.org/u/philspitler)\
**Replies:** 2\
**Last updated:** [September 20, 2021, 6:46pm UTC](https://discourse.processing.org/t/resize-image-question/32327 "2021-09-20T18:46:33Z")

</div>

Hi, I’m using the resize() function to resize my P5 image and want to loop through all the resized pixels, sample them and draw a circle with the color values to basically create a dot pattern style image. It seems like…

---

## [Pause / stop / \`noLoop()\` p5 sketch when not actively seen by the user (e.g. after scrolling out of window)](https://discourse.processing.org/t/pause-stop-noloop-p5-sketch-when-not-actively-seen-by-the-user-e-g-after-scrolling-out-of-window/32294)

<div class="topic-metadata">

**Author:** [@janmaltel](https://discourse.processing.org/u/janmaltel)\
**Replies:** 1\
**Last updated:** [September 18, 2021, 3:51am UTC](https://discourse.processing.org/t/pause-stop-noloop-p5-sketch-when-not-actively-seen-by-the-user-e-g-after-scrolling-out-of-window/32294 "2021-09-18T03:51:18Z")

</div>

Hi everyone, is there a setting that would automatically pause my sketch when the user cannot currently see it? For example, I got this blog post here where there’s one sketch at the very top and another sketch at the …

---

## [「Processing」「P5.js」Matrix arrangement calculation difference](https://discourse.processing.org/t/processing-p5-js-matrix-arrangement-calculation-difference/32265)

<div class="topic-metadata">

**Author:** [@niuuin](https://discourse.processing.org/u/niuuin)\
**Replies:** 2\
**Last updated:** [September 15, 2021, 10:47am UTC](https://discourse.processing.org/t/processing-p5-js-matrix-arrangement-calculation-difference/32265 "2021-09-15T10:47:10Z")

</div>

The same calculation method gets different results in 「processing」 and 「P5.js」. Processing: int total; float itemSize; void setup() { size(400, 400); total = 6; itemSize = width/total; } void draw() { clear()…

---

## [P5.js on the web](https://discourse.processing.org/t/p5-js-on-the-web/32206)

<div class="topic-metadata">

**Author:** [@bcabc](https://discourse.processing.org/u/bcabc)\
**Replies:** 1\
**Last updated:** [September 12, 2021, 2:29am UTC](https://discourse.processing.org/t/p5-js-on-the-web/32206 "2021-09-12T02:29:13Z")

</div>

I have been working on some P5.js code and I’d like to share it on the internet. I know that it’s quite easy to load it onto the P5.js editor site and get a hyperlink - but I’m wondering if there is guide or tutorial for…

---

## [P5.js not working in blogger](https://discourse.processing.org/t/p5-js-not-working-in-blogger/32086)

<div class="topic-metadata">

**Author:** [@processing\_user](https://discourse.processing.org/u/processing_user)\
**Replies:** 12\
**Last updated:** [September 5, 2021, 5:31pm UTC](https://discourse.processing.org/t/p5-js-not-working-in-blogger/32086 "2021-09-05T17:31:02Z")

</div>

Hi, Does p5.js work on blogger.com platform? It is not working for me. Tried with simple p5.js with canvas and included the cdn link but does not work. Has anyone tried p5.js on blogger?

---

## [My code for selectable resolution does not work](https://discourse.processing.org/t/my-code-for-selectable-resolution-does-not-work/32045)

<div class="topic-metadata">

**Author:** [@Quorum](https://discourse.processing.org/u/Quorum)\
**Replies:** 2\
**Last updated:** [September 5, 2021, 4:37pm UTC](https://discourse.processing.org/t/my-code-for-selectable-resolution-does-not-work/32045 "2021-09-05T16:37:49Z")

</div>

I want to change the canvas between some resolutions that I have preset. But my solution doesn’t work completely. It works with the first two, but when I select one of the other four, a resolution equal to one of the fi…

---

## [The different performance of noise() in processing and p5.js](https://discourse.processing.org/t/the-different-performance-of-noise-in-processing-and-p5-js/32019)

<div class="topic-metadata">

**Author:** [@niuuin](https://discourse.processing.org/u/niuuin)\
**Replies:** 2\
**Last updated:** [August 31, 2021, 5:37am UTC](https://discourse.processing.org/t/the-different-performance-of-noise-in-processing-and-p5-js/32019 "2021-08-31T05:37:39Z")

</div>

I am learning a tutorial from Vamoss and trying to implement it with Processing. But I encountered a problem in the noise() part of Chapter 2, which resulted in a different result from Vamoss. This is my code: int…

---

## [Textwrap is not defined](https://discourse.processing.org/t/textwrap-is-not-defined/31967)

<div class="topic-metadata">

**Author:** [@Omri](https://discourse.processing.org/u/Omri)\
**Replies:** 9\
**Last updated:** [August 27, 2021, 3:32pm UTC](https://discourse.processing.org/t/textwrap-is-not-defined/31967 "2021-08-27T15:32:35Z")

</div>

Hey, I’m trying to use the textWrap function but I got an error: “Uncaught (in promise) ReferenceError: textwrap is not defined”. I suspect that the problem is maybe in the p5.min.js library, is that make sense? how ca…

---

## [Why loadVideo() is not available?](https://discourse.processing.org/t/why-loadvideo-is-not-available/31622)

<div class="topic-metadata">

**Author:** [@matsuda](https://discourse.processing.org/u/matsuda)\
**Replies:** 6\
**Last updated:** [August 25, 2021, 2:51am UTC](https://discourse.processing.org/t/why-loadvideo-is-not-available/31622 "2021-08-25T02:51:57Z")

</div>

Hi there We can deal with an image using loadImage() and also using createImg(). However, in case of video, we can use createVideo() but “loadVideo()” is not available. It seems to be inconsistent. Is there any reas…

---

## [Uploading jpeg files= removed add file feature](https://discourse.processing.org/t/uploading-jpeg-files-removed-add-file-feature/31618)

<div class="topic-metadata">

**Author:** [@gregts13](https://discourse.processing.org/u/gregts13)\
**Replies:** 2\
**Last updated:** [August 8, 2021, 12:39am UTC](https://discourse.processing.org/t/uploading-jpeg-files-removed-add-file-feature/31618 "2021-08-08T00:39:09Z")

</div>

as you can see someone has removed the browse the computer for files to upload on the add files I wanted to upload a few pictures to an existing p5.js sketch, but can’t as the feature is gone what do I do now??

---

## [Beginner question/s for a simple project](https://discourse.processing.org/t/beginner-question-s-for-a-simple-project/31570)

<div class="topic-metadata">

**Author:** [@sloppy](https://discourse.processing.org/u/sloppy)\
**Replies:** 4\
**Last updated:** [August 5, 2021, 8:52am UTC](https://discourse.processing.org/t/beginner-question-s-for-a-simple-project/31570 "2021-08-05T08:52:59Z")

</div>

Hi everyone, I’ve just started learning P5 and have just made an simplistic randomized program. I’m looking to make it a touch more complex but the 3 things I want to do, I don’t even have the coding vocabulary/thought…

---

## [3D Lighting problems with Custom Shapes](https://discourse.processing.org/t/3d-lighting-problems-with-custom-shapes/31466)

<div class="topic-metadata">

**Author:** [@Sayochi](https://discourse.processing.org/u/Sayochi)\
**Replies:** 7\
**Last updated:** [July 28, 2021, 10:06am UTC](https://discourse.processing.org/t/3d-lighting-problems-with-custom-shapes/31466 "2021-07-28T10:06:04Z")

</div>

Im trying to convert my 2d terrain generator to 3d. i learnt about beginShape also works in 3d. watched few tutorials. but i have this lighting problem with my overall shape. i even tried to construct every individual tr…

---

## [Display Issue - Same sketch displays diff on diff computers](https://discourse.processing.org/t/display-issue-same-sketch-displays-diff-on-diff-computers/31305)

<div class="topic-metadata">

**Author:** [@BigBigRed](https://discourse.processing.org/u/BigBigRed)\
**Replies:** 6\
**Last updated:** [July 17, 2021, 10:10pm UTC](https://discourse.processing.org/t/display-issue-same-sketch-displays-diff-on-diff-computers/31305 "2021-07-17T22:10:58Z")

</div>

I have a p5js sketch that displays differently on my desktop computer than on my laptop computer. The problem apparently comes from from the graphic(s) named Mandlebrot. On the laptop computer, the image for mandleb…

---

## [Drawing images with the image function seems to be very slow](https://discourse.processing.org/t/drawing-images-with-the-image-function-seems-to-be-very-slow/31031)

<div class="topic-metadata">

**Author:** [@modusponens](https://discourse.processing.org/u/modusponens)\
**Replies:** 7\
**Last updated:** [July 15, 2021, 8:26pm UTC](https://discourse.processing.org/t/drawing-images-with-the-image-function-seems-to-be-very-slow/31031 "2021-07-15T20:26:18Z")

</div>

I’m trying to write a game engine using p5, but I’ve hit a huge snag: unless I’m doing something wrong (which is definitely possible), the image function seems really slow. If I call it even just about 40 or 50 times per…

---

## [Jumping from Processing to p5.js... whaaa?](https://discourse.processing.org/t/jumping-from-processing-to-p5-js-whaaa/31249)

<div class="topic-metadata">

**Author:** [@Eamoex](https://discourse.processing.org/u/Eamoex)\
**Replies:** 2\
**Last updated:** [July 15, 2021, 6:09am UTC](https://discourse.processing.org/t/jumping-from-processing-to-p5-js-whaaa/31249 "2021-07-15T06:09:37Z")

</div>

Hi, getting into Javascript (p5.js) from Processing to embed sketches on my website. Right from the start there are two things I don’t get. variables have no declared type? arrays have no declared length? Here is a p…

---

## [Can't use math functions inside class constructor](https://discourse.processing.org/t/cant-use-math-functions-inside-class-constructor/31251)

<div class="topic-metadata">

**Author:** [@seanc4s](https://discourse.processing.org/u/seanc4s)\
**Replies:** 4\
**Last updated:** [July 14, 2021, 11:16pm UTC](https://discourse.processing.org/t/cant-use-math-functions-inside-class-constructor/31251 "2021-07-14T23:16:13Z")

</div>

Can’t use math functions inside class constructor, and some other functions like print(“Hi”) for example. I don’t mind, but it kinda makes my code look ugly having to use JavaScript Math.random() for example. Which has …

---

## [How can I rename, annotate name or save to sub-directory images in a folder following classification?](https://discourse.processing.org/t/how-can-i-rename-annotate-name-or-save-to-sub-directory-images-in-a-folder-following-classification/31100)

<div class="topic-metadata">

**Author:** [@Tegan](https://discourse.processing.org/u/Tegan)\
**Replies:** 2\
**Last updated:** [July 7, 2021, 9:38am UTC](https://discourse.processing.org/t/how-can-i-rename-annotate-name-or-save-to-sub-directory-images-in-a-folder-following-classification/31100 "2021-07-07T09:38:37Z")

</div>

I am running a basic image classification model (trained on the teachable machine) but now want to be able to annotate the file names or move them to a sub directory based on the classification. I would prefer not to cop…

---

## [Can't select \<span\> element in DOM bug](https://discourse.processing.org/t/cant-select-span-element-in-dom-bug/30980)

<div class="topic-metadata">

**Author:** [@griff](https://discourse.processing.org/u/griff)\
**Replies:** 2\
**Last updated:** [June 30, 2021, 4:41pm UTC](https://discourse.processing.org/t/cant-select-span-element-in-dom-bug/30980 "2021-06-30T16:41:34Z")

</div>

I am having trouble using select() to get a span element in the DOM. It looks like it is a bug or I’m doing something wrong. Here is the link: https://editor.p5js.org/im-griff/sketches/D7tf9TAC0 Or below here is the cod…

---

## [Why are there two width and height values in the P5.js sketch canvas tag?](https://discourse.processing.org/t/why-are-there-two-width-and-height-values-in-the-p5-js-sketch-canvas-tag/30930)

<div class="topic-metadata">

**Author:** [@sspboyd](https://discourse.processing.org/u/sspboyd)\
**Replies:** 1\
**Last updated:** [June 27, 2021, 3:50am UTC](https://discourse.processing.org/t/why-are-there-two-width-and-height-values-in-the-p5-js-sketch-canvas-tag/30930 "2021-06-27T03:50:50Z")

</div>

The canvas objects created by p5.js have two width and height values. I hadn’t noticed this before and now I’m curious! The example below is the from the p5 editor. \<canvas id="defaultCanvas0" class="p5Canvas" style="w…

---

## [How to make a variable random in p5.js](https://discourse.processing.org/t/how-to-make-a-variable-random-in-p5-js/30892)

<div class="topic-metadata">

**Author:** [@x06](https://discourse.processing.org/u/x06)\
**Replies:** 5\
**Last updated:** [June 25, 2021, 7:53pm UTC](https://discourse.processing.org/t/how-to-make-a-variable-random-in-p5-js/30892 "2021-06-25T19:53:39Z")

</div>

Hi, I’m playing around with a color wheel by kgrnbrg. I want to randomize the segmentCount so the color wheel can change shape and thereby adjusting the number of colors available. I can’t use random in the top and if …

---

## [How could I have acces to DOM elements p5.js](https://discourse.processing.org/t/how-could-i-have-acces-to-dom-elements-p5-js/30852)

<div class="topic-metadata">

**Author:** [@WaningJupiter](https://discourse.processing.org/u/WaningJupiter)\
**Replies:** 4\
**Last updated:** [June 22, 2021, 4:50pm UTC](https://discourse.processing.org/t/how-could-i-have-acces-to-dom-elements-p5-js/30852 "2021-06-22T16:50:24Z")

</div>

Hi community, I’ve watched Handling DOM Events with Callbacks of Coding Train. In this vidéo, Daniel Shiffman created a button element in sketch.js , using a mousePressed() function to control the randomness of backgro…

---

## [Multiply an array with a number](https://discourse.processing.org/t/multiply-an-array-with-a-number/30778)

<div class="topic-metadata">

**Author:** [@Sayochi](https://discourse.processing.org/u/Sayochi)\
**Replies:** 1\
**Last updated:** [June 18, 2021, 3:17pm UTC](https://discourse.processing.org/t/multiply-an-array-with-a-number/30778 "2021-06-18T15:17:13Z")

</div>

I need to multiply a float array with a float value without looping over every item. I checked internet a bit and tried some stuff. array.map(number); looks okay to me but Im getting an error: cannot invoke map(float) o…

---

## [Printing Partial Name From Array](https://discourse.processing.org/t/printing-partial-name-from-array/30630)

<div class="topic-metadata">

**Author:** [@cottonchipper](https://discourse.processing.org/u/cottonchipper)\
**Replies:** 4\
**Last updated:** [June 10, 2021, 6:33pm UTC](https://discourse.processing.org/t/printing-partial-name-from-array/30630 "2021-06-10T18:33:41Z")

</div>

I’ve got an array made up of function names: Gz = \[Waterpump, Cyclotron, Conveyor, BoxDance, Tumblers, Giza, Lunar, Luxor, Trapeze, Sticks, Plus3, Bowtie, FourWalls, SquarePeg, Clockwork, Atomic, Batman, Robin, PolloLoc…

---

## [Embedding p5.js web editor in external site](https://discourse.processing.org/t/embedding-p5-js-web-editor-in-external-site/18400)

<div class="topic-metadata">

**Author:** [@Jithin](https://discourse.processing.org/u/Jithin)\
**Replies:** 6\
**Last updated:** [June 9, 2021, 7:43am UTC](https://discourse.processing.org/t/embedding-p5-js-web-editor-in-external-site/18400 "2021-06-09T07:43:08Z")

</div>

Is there any way to embed the whole p5 text editor in some external site rather than just the sketch part. This would help users to edit the code then and there itself to get the feedback.

---

## [Using Fisher-Yates Shuffle For Array](https://discourse.processing.org/t/using-fisher-yates-shuffle-for-array/30488)

<div class="topic-metadata">

**Author:** [@cottonchipper](https://discourse.processing.org/u/cottonchipper)\
**Replies:** 6\
**Last updated:** [June 6, 2021, 4:46am UTC](https://discourse.processing.org/t/using-fisher-yates-shuffle-for-array/30488 "2021-06-06T04:46:19Z")

</div>

I’ve got an array that I need to shuffle, but I need the results to be deterministic based on a seeded PRNG. I’m attempting to use the following code which I found at https://bost.ocks.org/mike/shuffle/ I’ve replaced “M…

[Previous page](https://discourse.processing.org/c/p5js/p5js-beginners/16.md?page=6)

[Next page](https://discourse.processing.org/c/p5js/p5js-beginners/16.md?page=8)
