# Beginners

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

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

**Page:** 5

---

## [Hi ,who can tell me the way to upload a pic in P5.js editor? I am a beginner!](https://discourse.processing.org/t/hi-who-can-tell-me-the-way-to-upload-a-pic-in-p5-js-editor-i-am-a-beginner/38389)

<div class="topic-metadata">

**Author:** [@sallyzhai](https://discourse.processing.org/u/sallyzhai)\
**Replies:** 1\
**Last updated:** [August 17, 2022, 6:37am UTC](https://discourse.processing.org/t/hi-who-can-tell-me-the-way-to-upload-a-pic-in-p5-js-editor-i-am-a-beginner/38389 "2022-08-17T06:37:12Z")

</div>

Sorry, who can tell me the way to upload a picture in p5.js editor? They have changed the upload way from the previous one!

---

## [How to make score only go up by one when pressing spacebar?](https://discourse.processing.org/t/how-to-make-score-only-go-up-by-one-when-pressing-spacebar/38247)

<div class="topic-metadata">

**Author:** [@Mathamagic](https://discourse.processing.org/u/Mathamagic)\
**Replies:** 1\
**Last updated:** [August 15, 2022, 10:47pm UTC](https://discourse.processing.org/t/how-to-make-score-only-go-up-by-one-when-pressing-spacebar/38247 "2022-08-15T22:47:16Z")

</div>

I am trying to make a flappy bird clone and i was woundering how do i make it so that whenever you press the spacebar it increases the score by 1 and doesnt and more than 1 if you hold the space bar? let y = 200 ; let …

---

## [Using ES6 Modules in the p5.js Web Editor](https://discourse.processing.org/t/using-es6-modules-in-the-p5-js-web-editor/38258)

<div class="topic-metadata">

**Author:** [@Pieter](https://discourse.processing.org/u/Pieter)\
**Replies:** 4\
**Last updated:** [August 7, 2022, 4:32pm UTC](https://discourse.processing.org/t/using-es6-modules-in-the-p5-js-web-editor/38258 "2022-08-07T16:32:23Z")

</div>

I’m trying to use modules on the web editor, but I can’t seem to get it to work because it cannot resolve the relative paths. Is it even possible? Any help would be greatly appreciated, for my specific use case I want to…

---

## [Why is my code not working when I'm trying to show and hide the navbar](https://discourse.processing.org/t/why-is-my-code-not-working-when-im-trying-to-show-and-hide-the-navbar/38195)

<div class="topic-metadata">

**Author:** [@dija\_321](https://discourse.processing.org/u/dija_321)\
**Replies:** 0\
**Last updated:** [August 2, 2022, 2:18pm UTC](https://discourse.processing.org/t/why-is-my-code-not-working-when-im-trying-to-show-and-hide-the-navbar/38195 "2022-08-02T14:18:45Z")

</div>

HTML: \<!doctype html\> navbar Home CSS: .container{ background-color: black; height:100vh; width:0vw; } JS: l…

---

## [Fill from an array](https://discourse.processing.org/t/fill-from-an-array/38080)

<div class="topic-metadata">

**Author:** [@ablanton](https://discourse.processing.org/u/ablanton)\
**Replies:** 4\
**Last updated:** [July 24, 2022, 8:40pm UTC](https://discourse.processing.org/t/fill-from-an-array/38080 "2022-07-24T20:40:06Z")

</div>

hi all, i’m trying to input fill() from a global array and can’t see why this won’t work. it looks like a type conversion issue, but i thought this should work. any hints? let array\_main = \['0fb794', 2, 3\]; function s…

---

## [Shorthand code translation](https://discourse.processing.org/t/shorthand-code-translation/38050)

<div class="topic-metadata">

**Author:** [@Sunt](https://discourse.processing.org/u/Sunt)\
**Replies:** 11\
**Last updated:** [July 22, 2022, 7:09am UTC](https://discourse.processing.org/t/shorthand-code-translation/38050 "2022-07-22T07:09:13Z")

</div>

Hi. I found such lovely sketches on Twitter like this one below from @KomaTebe, but I can’t translate it into the usual (not shorthand) code. Could anyone do this? f=0,draw=a=\>{for(f||createCanvas(W=400,W,WEBGL),noStr…

---

## [Brackets live preview generates a 404](https://discourse.processing.org/t/brackets-live-preview-generates-a-404/38042)

<div class="topic-metadata">

**Author:** [@berndbausch](https://discourse.processing.org/u/berndbausch)\
**Replies:** 2\
**Last updated:** [July 21, 2022, 8:38pm UTC](https://discourse.processing.org/t/brackets-live-preview-generates-a-404/38042 "2022-07-21T20:38:50Z")

</div>

This is on a Windows PC. I am totally new to P5JS (and slightly less new to Processing) and try to use Brackets to edit and test my sketches. Originally, it worked. I downloaded the p5js ZIP file, unpacked it on the Des…

---

## [Print() function wants to print out the whole website](https://discourse.processing.org/t/print-function-wants-to-print-out-the-whole-website/37876)

<div class="topic-metadata">

**Author:** [@n0x](https://discourse.processing.org/u/n0x)\
**Replies:** 4\
**Last updated:** [July 7, 2022, 8:08pm UTC](https://discourse.processing.org/t/print-function-wants-to-print-out-the-whole-website/37876 "2022-07-07T20:08:34Z")

</div>

Whenever I have auto-refresh on and have written print() in draw then it wants to print out the websites like with ctrl + p and then when I try to close the tab I get a new one. I have lost code due to it. I’m wonder…

---

## [Examples from "Make: Getting Started with p5.js" not working](https://discourse.processing.org/t/examples-from-make-getting-started-with-p5-js-not-working/37835)

<div class="topic-metadata">

**Author:** [@MissAda](https://discourse.processing.org/u/MissAda)\
**Replies:** 4\
**Last updated:** [July 5, 2022, 3:21pm UTC](https://discourse.processing.org/t/examples-from-make-getting-started-with-p5-js-not-working/37835 "2022-07-05T15:21:03Z")

</div>

Hi hi, all! I’ve been working with p5 for a few months now. Going through the “getting started with p5.js” book from McCarthy + Reas. I’ve noticed that even if I copy the examples exactly as written, they sometimes don’t…

---

## [Black to white and then white to black](https://discourse.processing.org/t/black-to-white-and-then-white-to-black/26307)

<div class="topic-metadata">

**Author:** [@Jayda](https://discourse.processing.org/u/Jayda)\
**Replies:** 30\
**Last updated:** [July 5, 2022, 10:03am UTC](https://discourse.processing.org/t/black-to-white-and-then-white-to-black/26307 "2022-07-05T10:03:42Z")

</div>

Why it doesn’t work? Want the background turn from black to white and then white to black. Thank you! let bg; function setup() { createCanvas(400, 400); bg = 255; } function draw() { background(bg); bg -= 1; i…

---

## [Callback context](https://discourse.processing.org/t/callback-context/37768)

<div class="topic-metadata">

**Author:** [@anne](https://discourse.processing.org/u/anne)\
**Replies:** 6\
**Last updated:** [July 1, 2022, 10:34am UTC](https://discourse.processing.org/t/callback-context/37768 "2022-07-01T10:34:03Z")

</div>

How does one pass on the context to a callback in p5? fx in this code, the x i undefined: function setup() { createCanvas(400, 400); noLoop() } function draw() { background(128); let x = 100; loadImage(“birch.p…

---

## [Remove() and images](https://discourse.processing.org/t/remove-and-images/37756)

<div class="topic-metadata">

**Author:** [@caw](https://discourse.processing.org/u/caw)\
**Replies:** 2\
**Last updated:** [June 29, 2022, 11:02pm UTC](https://discourse.processing.org/t/remove-and-images/37756 "2022-06-29T23:02:21Z")

</div>

I have a misunderstanding about images and ‘removing’ them. The remove() function in p5.js Removes a Graphics object from the page and frees any resources associated with it. and one of the examples is: let bg; fun…

---

## [New to processing and just need some quick guidance please](https://discourse.processing.org/t/new-to-processing-and-just-need-some-quick-guidance-please/37695)

<div class="topic-metadata">

**Author:** [@NoobyDooby](https://discourse.processing.org/u/NoobyDooby)\
**Replies:** 6\
**Last updated:** [June 23, 2022, 9:31pm UTC](https://discourse.processing.org/t/new-to-processing-and-just-need-some-quick-guidance-please/37695 "2022-06-23T21:31:56Z")

</div>

Hello! I’m very new to processing and have been watching tons of code train videos. At the moment I’ve spent some time looking at projects from the openprocessing website and have had tons of fun with it. There are som…

---

## [Callback function arguments](https://discourse.processing.org/t/callback-function-arguments/37588)

<div class="topic-metadata">

**Author:** [@davidhurwich](https://discourse.processing.org/u/davidhurwich)\
**Replies:** 2\
**Last updated:** [June 17, 2022, 8:00pm UTC](https://discourse.processing.org/t/callback-function-arguments/37588 "2022-06-17T20:00:56Z")

</div>

Hi, question about attaching event callback functions to an object in P5. Can those callback functions take arguments? for instance could I do something like this: obj.mousePressed( function(argument)); ?

---

## [Callback function argument](https://discourse.processing.org/t/callback-function-argument/37553)

<div class="topic-metadata">

**Author:** [@davidhurwich](https://discourse.processing.org/u/davidhurwich)\
**Replies:** 1\
**Last updated:** [June 15, 2022, 5:08am UTC](https://discourse.processing.org/t/callback-function-argument/37553 "2022-06-15T05:08:14Z")

</div>

I am writing a program that connects P5 with the HTML DOM. I want to have a HTML button when pressed pass along an argument to a function I created. I know I can add an event and callback function to a variable. I am won…

---

## [Maximum number in noiseSeed() p5js](https://discourse.processing.org/t/maximum-number-in-noiseseed-p5js/37399)

<div class="topic-metadata">

**Author:** [@Nik](https://discourse.processing.org/u/Nik)\
**Replies:** 2\
**Last updated:** [June 8, 2022, 11:22am UTC](https://discourse.processing.org/t/maximum-number-in-noiseseed-p5js/37399 "2022-06-08T11:22:39Z")

</div>

Hello! What is maximum number that can be used in noiseSeed() in P5JS? Just like for randomSeed() integer range 0 to 4294967295 or not? Thanks!

---

## [Why is a new canvas element added to the DOM every time createGraphics is called?](https://discourse.processing.org/t/why-is-a-new-canvas-element-added-to-the-dom-every-time-creategraphics-is-called/37346)

<div class="topic-metadata">

**Author:** [@sspboyd](https://discourse.processing.org/u/sspboyd)\
**Replies:** 2\
**Last updated:** [June 6, 2022, 3:43pm UTC](https://discourse.processing.org/t/why-is-a-new-canvas-element-added-to-the-dom-every-time-creategraphics-is-called/37346 "2022-06-06T15:43:16Z")

</div>

I have run into an unexpected issue with createGraphics(). Each time I define a new variable to hold a createGraphics object I am getting another canvas element added to the DOM. Here’s a minimalist example and a link t…

---

## [Maximum number in randomSeed() p5js](https://discourse.processing.org/t/maximum-number-in-randomseed-p5js/37352)

<div class="topic-metadata">

**Author:** [@Nik](https://discourse.processing.org/u/Nik)\
**Replies:** 3\
**Last updated:** [June 6, 2022, 12:51pm UTC](https://discourse.processing.org/t/maximum-number-in-randomseed-p5js/37352 "2022-06-06T12:51:39Z")

</div>

Hello! What is maximum number that can be used in randomSeed() in P5JS?

---

## [Any way to add a single word attribute to a dom element?](https://discourse.processing.org/t/any-way-to-add-a-single-word-attribute-to-a-dom-element/37173)

<div class="topic-metadata">

**Author:** [@bluemoon](https://discourse.processing.org/u/bluemoon)\
**Replies:** 1\
**Last updated:** [May 28, 2022, 9:35pm UTC](https://discourse.processing.org/t/any-way-to-add-a-single-word-attribute-to-a-dom-element/37173 "2022-05-28T21:35:39Z")

</div>

For instance, if I wanted to add the ‘autofocus’ attribute to an ‘input’, the normal html would be: \<input type="text" autofocus\> Is there a way to add such a tag in p5js? The following does not work because ‘.attribu…

---

## [Drawing context and p5.Graphics](https://discourse.processing.org/t/drawing-context-and-p5-graphics/37158)

<div class="topic-metadata">

**Author:** [@vjjv](https://discourse.processing.org/u/vjjv)\
**Replies:** 1\
**Last updated:** [May 28, 2022, 11:08am UTC](https://discourse.processing.org/t/drawing-context-and-p5-graphics/37158 "2022-05-28T11:08:34Z")

</div>

Hello! I was using this function to generate quick shadows: drawingContext.shadowColor = color(0, 0, 0, 0.6); drawingContext.shadowBlur = 50; drawingContext.shadowOffsetX = -25; drawingContext.shadowOffsetY = -…

---

## [Traversing elements inside an array which is inside another array in p5js](https://discourse.processing.org/t/traversing-elements-inside-an-array-which-is-inside-another-array-in-p5js/36923)

<div class="topic-metadata">

**Author:** [@lvndr](https://discourse.processing.org/u/lvndr)\
**Replies:** 1\
**Last updated:** [May 17, 2022, 8:32pm UTC](https://discourse.processing.org/t/traversing-elements-inside-an-array-which-is-inside-another-array-in-p5js/36923 "2022-05-17T20:32:28Z")

</div>

Is there a way in p5js to traverse elements inside an array that is inside another array? This is the CSV file I am using, and I want to access the elements inside the ingredients column one by one. Since each row ha…

---

## [Printing a Vector before and after changing it produces unexpected results](https://discourse.processing.org/t/printing-a-vector-before-and-after-changing-it-produces-unexpected-results/32111)

<div class="topic-metadata">

**Author:** [@norm\_krumpe](https://discourse.processing.org/u/norm_krumpe)\
**Replies:** 16\
**Last updated:** [May 4, 2022, 6:33am UTC](https://discourse.processing.org/t/printing-a-vector-before-and-after-changing-it-produces-unexpected-results/32111 "2022-05-04T06:33:36Z")

</div>

I’m putting together a short exercise for my students on p5.Vector and its operations. The output of the code below surprises me, and I was hoping someone could explain what’s going on. I’ve been programming in Processin…

---

## [Uploading a file to the P5 Web Editor](https://discourse.processing.org/t/uploading-a-file-to-the-p5-web-editor/36700)

<div class="topic-metadata">

**Author:** [@NationalRex22](https://discourse.processing.org/u/NationalRex22)\
**Replies:** 1\
**Last updated:** [May 3, 2022, 8:16pm UTC](https://discourse.processing.org/t/uploading-a-file-to-the-p5-web-editor/36700 "2022-05-03T20:16:44Z")

</div>

Hello, How do I upload a file or a picture while I’m working in your p5.js Web Editor?

---

## [Including a library?](https://discourse.processing.org/t/including-a-library/36701)

<div class="topic-metadata">

**Author:** [@NationalRex22](https://discourse.processing.org/u/NationalRex22)\
**Replies:** 0\
**Last updated:** [May 3, 2022, 6:49pm UTC](https://discourse.processing.org/t/including-a-library/36701 "2022-05-03T18:49:55Z")

</div>

Hello, How do I add a library with the code I’m working with on the p5.js Web Editor?

---

## [Fullscreen() choice of return values](https://discourse.processing.org/t/fullscreen-choice-of-return-values/36618)

<div class="topic-metadata">

**Author:** [@fabiopettinati](https://discourse.processing.org/u/fabiopettinati)\
**Replies:** 4\
**Last updated:** [April 28, 2022, 5:53pm UTC](https://discourse.processing.org/t/fullscreen-choice-of-return-values/36618 "2022-04-28T17:53:58Z")

</div>

I was playing with fullscreen() in p5.js and the prototypical way of toggling state in the reference: let fs = fullscreen(); fullscreen(!fs); The values returned for fs depend on the state: Windowed mode… undefined F…

---

## [Finding the color of a pixel](https://discourse.processing.org/t/finding-the-color-of-a-pixel/36555)

<div class="topic-metadata">

**Author:** [@hermitdog](https://discourse.processing.org/u/hermitdog)\
**Replies:** 2\
**Last updated:** [April 24, 2022, 12:06am UTC](https://discourse.processing.org/t/finding-the-color-of-a-pixel/36555 "2022-04-24T00:06:23Z")

</div>

Blockquote In previous versions of Processing, I could find the color of a pixel using get(x,y) But in P5js get(x,y) gives me something like \[146, 200 150, 255\] What I need is some way to check that the location is …

---

## [How do I get trailing lines not dots?](https://discourse.processing.org/t/how-do-i-get-trailing-lines-not-dots/36522)

<div class="topic-metadata">

**Author:** [@locky.mcdonald](https://discourse.processing.org/u/locky.mcdonald)\
**Replies:** 11\
**Last updated:** [April 22, 2022, 5:09pm UTC](https://discourse.processing.org/t/how-do-i-get-trailing-lines-not-dots/36522 "2022-04-22T17:09:58Z")

</div>

\`function setup() { createCanvas(800, 800); } function draw() { background("#ffffff04"); if (mouseIsPressed) { stroke(mouseX, 0, mouseY); strokeWeight(10); smooth(); point(mouseX-5, mouseY-5, pmouseX, pmouseY ); poi…

---

## [P5.js image not appearing](https://discourse.processing.org/t/p5-js-image-not-appearing/36435)

<div class="topic-metadata">

**Author:** [@cardgame](https://discourse.processing.org/u/cardgame)\
**Replies:** 2\
**Last updated:** [April 19, 2022, 2:15pm UTC](https://discourse.processing.org/t/p5-js-image-not-appearing/36435 "2022-04-19T14:15:23Z")

</div>

Hi, I was just following the tutorials from ml5.js and I could not see the images I don’t know why, I moved the image file to the folder which has the html.

---

## [How to reverse a animation loop that pulls values from an array](https://discourse.processing.org/t/how-to-reverse-a-animation-loop-that-pulls-values-from-an-array/36242)

<div class="topic-metadata">

**Author:** [@gary](https://discourse.processing.org/u/gary)\
**Replies:** 6\
**Last updated:** [April 13, 2022, 6:16pm UTC](https://discourse.processing.org/t/how-to-reverse-a-animation-loop-that-pulls-values-from-an-array/36242 "2022-04-13T18:16:21Z")

</div>

I’m having difficulty figuring out how to reverse the direction of an animated loop when it reaches the end of an array. I found an example online that creates two “states” with an additive and subtractive loop within ea…

---

## [iOS15: How to use rotationX, accelerationX](https://discourse.processing.org/t/ios15-how-to-use-rotationx-accelerationx/36278)

<div class="topic-metadata">

**Author:** [@Ingo](https://discourse.processing.org/u/Ingo)\
**Replies:** 2\
**Last updated:** [April 11, 2022, 2:34pm UTC](https://discourse.processing.org/t/ios15-how-to-use-rotationx-accelerationx/36278 "2022-04-11T14:34:29Z")

</div>

Hi, I’d like to write some webapps with my students, but the old code doesn’t work anymore, because of security reasons, I think. So found this video: https://www.youtube.com/watch?v=AbB9ayaffTc and tried it, but it doe…

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

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