# p5.js

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

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

**Page:** 61

---

## [Hi guys, the console is showing me the result "undefined" about the api](https://discourse.processing.org/t/hi-guys-the-console-is-showing-me-the-result-undefined-about-the-api/24154)

<div class="topic-metadata">

**Author:** [@kappo25](https://discourse.processing.org/u/kappo25)\
**Replies:** 2\
**Last updated:** [September 27, 2020, 3:30pm UTC](https://discourse.processing.org/t/hi-guys-the-console-is-showing-me-the-result-undefined-about-the-api/24154 "2020-09-27T15:30:45Z")

</div>

var weather; function setup() { loadJSON( 'https://restcountries.eu/rest/v2/capital/tallinn', gotData ); } function gotData(data) { weather = data; } function draw() { background(0); if (weather) { …

---

## [Code not working in p5.js with JSON data?](https://discourse.processing.org/t/code-not-working-in-p5-js-with-json-data/24152)

<div class="topic-metadata">

**Author:** [@sam101](https://discourse.processing.org/u/sam101)\
**Replies:** 1\
**Last updated:** [September 27, 2020, 2:30pm UTC](https://discourse.processing.org/t/code-not-working-in-p5-js-with-json-data/24152 "2020-09-27T14:30:04Z")

</div>

I’m trying to tell the system to let the number value stored within my JSON file to determine the size of the ellipse. I referenced this https://editor.p5js.org/bavazzanos1/sketches/Bkkdrs11M MY CODE SO FAR: var data; …

---

## [How do I draw a circle based on my JSON data information in p5.js?](https://discourse.processing.org/t/how-do-i-draw-a-circle-based-on-my-json-data-information-in-p5-js/24146)

<div class="topic-metadata">

**Author:** [@sam101](https://discourse.processing.org/u/sam101)\
**Replies:** 2\
**Last updated:** [September 27, 2020, 11:18am UTC](https://discourse.processing.org/t/how-do-i-draw-a-circle-based-on-my-json-data-information-in-p5-js/24146 "2020-09-27T11:18:31Z")

</div>

So, I’m trying to grab data from my JSON file to my code and display the circle size according to the number on my JSON file. So far this is the code. var data; var instagram, snapchat, messenger, facebook, email, ins…

---

## [How do I get the mousePressed function to change to different words each time on p5.js?](https://discourse.processing.org/t/how-do-i-get-the-mousepressed-function-to-change-to-different-words-each-time-on-p5-js/24134)

<div class="topic-metadata">

**Author:** [@sam101](https://discourse.processing.org/u/sam101)\
**Replies:** 4\
**Last updated:** [September 26, 2020, 11:50am UTC](https://discourse.processing.org/t/how-do-i-get-the-mousepressed-function-to-change-to-different-words-each-time-on-p5-js/24134 "2020-09-26T11:50:51Z")

</div>

Hi everyone! Was wondering how do I get the text to change every time I mousePress it. E.g. Sunday, then to Monday, then to Tuesday and so forth until it get to Saturday? Any help will be much appreciated Would I use …

---

## [Unable to get JSON file to work in p5.js](https://discourse.processing.org/t/unable-to-get-json-file-to-work-in-p5-js/24116)

<div class="topic-metadata">

**Author:** [@sam101](https://discourse.processing.org/u/sam101)\
**Replies:** 7\
**Last updated:** [September 26, 2020, 7:28am UTC](https://discourse.processing.org/t/unable-to-get-json-file-to-work-in-p5-js/24116 "2020-09-26T07:28:11Z")

</div>

I’m trying to load my p5.js sketch, but the sketch keeps coming up as loading. Then when I check to see, there is an error message saying"Uncaught (in promise) SyntaxError: Unexpected token / in JSON at position 0", whic…

---

## [Bug Bounty- Audio in IOS](https://discourse.processing.org/t/bug-bounty-audio-in-ios/23984)

<div class="topic-metadata">

**Author:** [@hikinghack](https://discourse.processing.org/u/hikinghack)\
**Replies:** 5\
**Last updated:** [September 25, 2020, 7:34pm UTC](https://discourse.processing.org/t/bug-bounty-audio-in-ios/23984 "2020-09-25T19:34:10Z")

</div>

Hi! I made this little game for kids for the Smithsonian in Panama to teach about FFT functions and how scientists use spectrograms to identify animals in audio. But it doesn’t work on safari or chrome on iphones or ipad…

---

## [Server to app communication](https://discourse.processing.org/t/server-to-app-communication/24098)

<div class="topic-metadata">

**Author:** [@gerome](https://discourse.processing.org/u/gerome)\
**Replies:** 1\
**Last updated:** [September 24, 2020, 12:46pm UTC](https://discourse.processing.org/t/server-to-app-communication/24098 "2020-09-24T12:46:50Z")

</div>

can p5.js be used for programming an interactive website with a server communicating to a processing app: Around 100 clients should be able to enter the page and set data. Then the server computes an output and a message…

---

## [How to trigger keypress events in p5.js](https://discourse.processing.org/t/how-to-trigger-keypress-events-in-p5-js/24082)

<div class="topic-metadata">

**Author:** [@yashkhasgiwala](https://discourse.processing.org/u/yashkhasgiwala)\
**Replies:** 1\
**Last updated:** [September 24, 2020, 12:02am UTC](https://discourse.processing.org/t/how-to-trigger-keypress-events-in-p5-js/24082 "2020-09-24T00:02:52Z")

</div>

I want my code to press keyboard keys if a certain condition is True in p5.js library. For example: a = true if (a) { // Press UP Key } else { // Press DOWN Key }

---

## [Text adventure game: go back a page using if-clause?](https://discourse.processing.org/t/text-adventure-game-go-back-a-page-using-if-clause/23967)

<div class="topic-metadata">

**Author:** [@DariusKempton](https://discourse.processing.org/u/DariusKempton)\
**Replies:** 1\
**Last updated:** [September 23, 2020, 3:58pm UTC](https://discourse.processing.org/t/text-adventure-game-go-back-a-page-using-if-clause/23967 "2020-09-23T15:58:07Z")

</div>

I am trying to make it so that if you accidentally select a race that you don’t like, or change your mind, you can choose to go back a page, but i cant quite figure out how to make it more streamlined. currently, if you …

---

## [The stroke color is mixed with the fill color](https://discourse.processing.org/t/the-stroke-color-is-mixed-with-the-fill-color/24058)

<div class="topic-metadata">

**Author:** [@san1](https://discourse.processing.org/u/san1)\
**Replies:** 1\
**Last updated:** [September 22, 2020, 8:29pm UTC](https://discourse.processing.org/t/the-stroke-color-is-mixed-with-the-fill-color/24058 "2020-09-22T20:29:10Z")

</div>

I drew black as the stroke color and set 1 as the weight, but the stroke color is not black. Please refer to the picture and code below. var canvasWidth = 640; var canvasHeight = 360; var blockSize = 30; function se…

---

## [Timers Not Frame Rate Dependent & Starting On Demand - Oh Please Oh Please :)](https://discourse.processing.org/t/timers-not-frame-rate-dependent-starting-on-demand-oh-please-oh-please/23994)

<div class="topic-metadata">

**Author:** [@mnoble](https://discourse.processing.org/u/mnoble)\
**Replies:** 11\
**Last updated:** [September 21, 2020, 11:44pm UTC](https://discourse.processing.org/t/timers-not-frame-rate-dependent-starting-on-demand-oh-please-oh-please/23994 "2020-09-21T23:44:06Z")

</div>

Hello Forum, I am making interactive visualizers that coordinate with sequenced visual automations and sound. I need to start a timer after a button is pushed (which I am pretty sure you can’t do with millis()) and I c…

---

## [Is millis() heavy on CPU program efficiency?](https://discourse.processing.org/t/is-millis-heavy-on-cpu-program-efficiency/23266)

<div class="topic-metadata">

**Author:** [@mnoble](https://discourse.processing.org/u/mnoble)\
**Replies:** 8\
**Last updated:** [September 21, 2020, 10:43pm UTC](https://discourse.processing.org/t/is-millis-heavy-on-cpu-program-efficiency/23266 "2020-09-21T22:43:23Z")

</div>

Hello Forum, I am working a project running p5js sketches from Open Processing on mobile devices. I have the need to create a series of timed events with millis() but this slowing things down greatly! Are there efficien…

---

## [Canvas not appearing in Div](https://discourse.processing.org/t/canvas-not-appearing-in-div/24008)

<div class="topic-metadata">

**Author:** [@minirachel](https://discourse.processing.org/u/minirachel)\
**Replies:** 2\
**Last updated:** [September 21, 2020, 10:13pm UTC](https://discourse.processing.org/t/canvas-not-appearing-in-div/24008 "2020-09-21T22:13:24Z")

</div>

Hi, I’m brand new. I’m building a project that relies on a section in the middle of the website generating a random output from a list. This is my p5 code: let words = \["stretching", "drink water", "sun" \] function set…

---

## [About the draw function](https://discourse.processing.org/t/about-the-draw-function/23974)

<div class="topic-metadata">

**Author:** [@Willian\_Xz](https://discourse.processing.org/u/Willian_Xz)\
**Replies:** 11\
**Last updated:** [September 21, 2020, 1:05pm UTC](https://discourse.processing.org/t/about-the-draw-function/23974 "2020-09-21T13:05:39Z")

</div>

Hello people!! I built a code on a lamp that goes on and off, the idea was to talk about the frequency in Hertz that a common lamp goes on and off, so I created a “simulation” of it. The draw function as far as I know …

---

## [Implementing WEBGL 3D with graphics objects](https://discourse.processing.org/t/implementing-webgl-3d-with-graphics-objects/23989)

<div class="topic-metadata">

**Author:** [@AlteredPhoenix](https://discourse.processing.org/u/AlteredPhoenix)\
**Replies:** 8\
**Last updated:** [September 21, 2020, 9:23am UTC](https://discourse.processing.org/t/implementing-webgl-3d-with-graphics-objects/23989 "2020-09-21T09:23:47Z")

</div>

Hello, I’m currently working on adding 3D functionality to a music visualizer program. Initially I planned to just add the WEBGL argument to the existing createCanvas(), but it caused formatting problems, so I switched t…

---

## [Class and arguments : can't make fish turn around](https://discourse.processing.org/t/class-and-arguments-cant-make-fish-turn-around/23937)

<div class="topic-metadata">

**Author:** [@vlafortune](https://discourse.processing.org/u/vlafortune)\
**Replies:** 11\
**Last updated:** [September 20, 2020, 11:16pm UTC](https://discourse.processing.org/t/class-and-arguments-cant-make-fish-turn-around/23937 "2020-09-20T23:16:59Z")

</div>

Hi! With p5.js, I made three fishes that move and have different colors and speed with arguments in a class. But when I tried to add conditional statements to turn around when reaching the border, it didn’t work and I c…

---

## [Error Message Help Pls](https://discourse.processing.org/t/error-message-help-pls/23924)

<div class="topic-metadata">

**Author:** [@BigBigRed](https://discourse.processing.org/u/BigBigRed)\
**Replies:** 2\
**Last updated:** [September 20, 2020, 1:28pm UTC](https://discourse.processing.org/t/error-message-help-pls/23924 "2020-09-20T13:28:11Z")

</div>

I am totally new to p5js. trying (I think) to execute p5js to run locally but get this error message from Windows. any ideas? I have no ideas.

---

## [Spherical Billboards](https://discourse.processing.org/t/spherical-billboards/23977)

<div class="topic-metadata">

**Author:** [@zackatoo](https://discourse.processing.org/u/zackatoo)\
**Replies:** 1\
**Last updated:** [September 20, 2020, 10:01am UTC](https://discourse.processing.org/t/spherical-billboards/23977 "2020-09-20T10:01:16Z")

</div>

I am trying to create a spherical billboard in the WEBGL version of p5.js. A spherical billboard is a 2D drawing which always faces the camera. I managed to create a cylindrical billboard (faces the camera, but only rota…

---

## [Text separation help](https://discourse.processing.org/t/text-separation-help/23859)

<div class="topic-metadata">

**Author:** [@DariusKempton](https://discourse.processing.org/u/DariusKempton)\
**Replies:** 8\
**Last updated:** [September 19, 2020, 7:45pm UTC](https://discourse.processing.org/t/text-separation-help/23859 "2020-09-19T19:45:15Z")

</div>

I am trying to create a Text Adventure game, but i am having problems trying to have both the title for the game and the game text display at the same time. Is there a way to create different text, so that i can have Sto…

---

## [Loading multiple .tsp or plain .txt files 70+ located in a directory](https://discourse.processing.org/t/loading-multiple-tsp-or-plain-txt-files-70-located-in-a-directory/23908)

<div class="topic-metadata">

**Author:** [@ChipperActual](https://discourse.processing.org/u/ChipperActual)\
**Replies:** 1\
**Last updated:** [September 19, 2020, 5:02pm UTC](https://discourse.processing.org/t/loading-multiple-tsp-or-plain-txt-files-70-located-in-a-directory/23908 "2020-09-19T17:02:53Z")

</div>

Hey All Very green with JS, stuck on how to load/read multiple files located within a directory(over 70 of them) was able to load one with the preload function ‘loadStrings’, any assistance would be much appreciated.

---

## [P5 transparent image problem](https://discourse.processing.org/t/p5-transparent-image-problem/23891)

<div class="topic-metadata">

**Author:** [@yhlaskerimov](https://discourse.processing.org/u/yhlaskerimov)\
**Replies:** 5\
**Last updated:** [September 18, 2020, 8:06pm UTC](https://discourse.processing.org/t/p5-transparent-image-problem/23891 "2020-09-18T20:06:05Z")

</div>

Hi, everyone. I have problem. My problem is: I want to load an transparent image to my p5 sketch. I used texture and rect to do that. But I couldn’t get right effect. I wanted to get this effect: I get this one(no…

---

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

<div class="topic-metadata">

**Author:** [@stevenraysimon](https://discourse.processing.org/u/stevenraysimon)\
**Replies:** 1\
**Last updated:** [September 18, 2020, 5:37pm UTC](https://discourse.processing.org/t/p5-js-not-working-in-ie11/23310 "2020-09-18T17:37:01Z")

</div>

Hi everyone, I’m having trouble getting p5.js to work in IE11 (Internet Explorer). I’m wondering if this is possible? Is there something within p5.js that is not supported in IE?

---

## [First project.. guidance with code for my music practice?](https://discourse.processing.org/t/first-project-guidance-with-code-for-my-music-practice/23836)

<div class="topic-metadata">

**Author:** [@HelloGoodPi](https://discourse.processing.org/u/HelloGoodPi)\
**Replies:** 1\
**Last updated:** [September 18, 2020, 10:11am UTC](https://discourse.processing.org/t/first-project-guidance-with-code-for-my-music-practice/23836 "2020-09-18T10:11:05Z")

</div>

Hey forum! Thanks for taking the time to read this! So i’m trying my first piece of code, with very little experience… My aim is to make a simple code that will show a letter/ note on screen (A to G) allong with an aud…

---

## [How to rewrite function without instancing random()](https://discourse.processing.org/t/how-to-rewrite-function-without-instancing-random/23840)

<div class="topic-metadata">

**Author:** [@bakursky](https://discourse.processing.org/u/bakursky)\
**Replies:** 3\
**Last updated:** [September 18, 2020, 9:49am UTC](https://discourse.processing.org/t/how-to-rewrite-function-without-instancing-random/23840 "2020-09-18T09:49:43Z")

</div>

I have the eye() function and I want to duplicate it several times that every eye look in a different direction (now random number copy to all function instances) let x=0; let y=0; function setup() { createCanvas…

---

## [strokeWeight() function behaviour and renderers comparison. p5.js v/s Processing Java](https://discourse.processing.org/t/strokeweight-function-behaviour-and-renderers-comparison-p5-js-v-s-processing-java/19510)

<div class="topic-metadata">

**Author:** [@Lapov](https://discourse.processing.org/u/Lapov)\
**Replies:** 2\
**Last updated:** [September 18, 2020, 7:59am UTC](https://discourse.processing.org/t/strokeweight-function-behaviour-and-renderers-comparison-p5-js-v-s-processing-java/19510 "2020-09-18T07:59:32Z")

</div>

Hi there! I am trying to switch from Processing 3 to p5.js. I am ok with everything but dissatisfied a bit with quality of geometry lines/edges rendering. It seems that it vary significantly in standard Processing P2D …

---

## [Wanting to load images/sprites onto tiles from a txt file 0=grass, 1=track, 2=start finish](https://discourse.processing.org/t/wanting-to-load-images-sprites-onto-tiles-from-a-txt-file-0-grass-1-track-2-start-finish/23909)

<div class="topic-metadata">

**Author:** [@ChipperActual](https://discourse.processing.org/u/ChipperActual)\
**Replies:** 0\
**Last updated:** [September 17, 2020, 1:22am UTC](https://discourse.processing.org/t/wanting-to-load-images-sprites-onto-tiles-from-a-txt-file-0-grass-1-track-2-start-finish/23909 "2020-09-17T01:22:16Z")

</div>

Hey All I am wanting to load images/sprites onto tiles from a txt file 0=grass, 1=track, 2=start finish, i have managed to read from the text file (shown in preview) Stuck on how to draw the tiles/images/sprites to the…

---

## [Where can I get a proper p5.dom.js](https://discourse.processing.org/t/where-can-i-get-a-proper-p5-dom-js/23752)

<div class="topic-metadata">

**Author:** [@ats3788](https://discourse.processing.org/u/ats3788)\
**Replies:** 1\
**Last updated:** [September 16, 2020, 3:40pm UTC](https://discourse.processing.org/t/where-can-i-get-a-proper-p5-dom-js/23752 "2020-09-16T15:40:10Z")

</div>

Hi Where can I get a proper p5.dom.js That all thx

---

## [Need help with the keyPressed () function](https://discourse.processing.org/t/need-help-with-the-keypressed-function/23863)

<div class="topic-metadata">

**Author:** [@The\_Rogue12](https://discourse.processing.org/u/The_Rogue12)\
**Replies:** 4\
**Last updated:** [September 15, 2020, 6:22pm UTC](https://discourse.processing.org/t/need-help-with-the-keypressed-function/23863 "2020-09-15T18:22:05Z")

</div>

So I am trying to write code that changes a variable when I press a certain key. The problem is, the keyPressed() function isn’t detecting any key presses. What am I doing wrong? My code: var x, y; var shape; function …

---

## [Seriously and p5serial](https://discourse.processing.org/t/seriously-and-p5serial/23853)

<div class="topic-metadata">

**Author:** [@paolopastorino](https://discourse.processing.org/u/paolopastorino)\
**Replies:** 0\
**Last updated:** [September 14, 2020, 3:59pm UTC](https://discourse.processing.org/t/seriously-and-p5serial/23853 "2020-09-14T15:59:26Z")

</div>

Hi to everyone, I am new here and i have not much experience in coding. I have a problem whit seriously.js library: i’ve copied the sketch from D. Shiffman tutorial about the library and then i’ve tried to change some …

---

## [High resolution print using p5 vs. Processing](https://discourse.processing.org/t/high-resolution-print-using-p5-vs-processing/23782)

<div class="topic-metadata">

**Author:** [@gjs](https://discourse.processing.org/u/gjs)\
**Replies:** 2\
**Last updated:** [September 15, 2020, 12:45am UTC](https://discourse.processing.org/t/high-resolution-print-using-p5-vs-processing/23782 "2020-09-15T00:45:25Z")

</div>

Casey Reas wrote a wonderful tutorial on printing \[https://processing.org/tutorials/print/\] that detailed instructions on how to export high-resolution files in Processing. I would like to do the same with my p5-generat…

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

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