# Coding Questions

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

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

**Page:** 25

---

## [Game with arrow key](https://discourse.processing.org/t/game-with-arrow-key/26314)

<div class="topic-metadata">

**Author:** [@Jayda](https://discourse.processing.org/u/Jayda)\
**Replies:** 5\
**Last updated:** [December 17, 2020, 3:27pm UTC](https://discourse.processing.org/t/game-with-arrow-key/26314 "2020-12-17T15:27:19Z")

</div>

Here is three things I want to do Keep the red ball remain in the canvas when it meets the boundary. (the whole interface disappears when it meets the boundary) Create a random “Green” target, and the goal is to u…

---

## [Making use of the GPU to render huge amount of objects](https://discourse.processing.org/t/making-use-of-the-gpu-to-render-huge-amount-of-objects/26267)

<div class="topic-metadata">

**Author:** [@lettuceburrito](https://discourse.processing.org/u/lettuceburrito)\
**Replies:** 10\
**Last updated:** [December 17, 2020, 12:56pm UTC](https://discourse.processing.org/t/making-use-of-the-gpu-to-render-huge-amount-of-objects/26267 "2020-12-17T12:56:11Z")

</div>

Hi, I’m new to p5.js and WebGL, so I’m not sure if I’m using the right terminology. Let’s start with the problem: We’re currently displaying a map of objects (simple rectangles with text in them, plus some single line…

---

## [Visualize data from API in p5.js](https://discourse.processing.org/t/visualize-data-from-api-in-p5-js/26246)

<div class="topic-metadata">

**Author:** [@fullmotion](https://discourse.processing.org/u/fullmotion)\
**Replies:** 4\
**Last updated:** [December 16, 2020, 3:07pm UTC](https://discourse.processing.org/t/visualize-data-from-api-in-p5-js/26246 "2020-12-16T15:07:25Z")

</div>

Hello, I am trying to create a data visualization from data form an API. I would like to visualize every point in the array on the sketch and include the type of the incident (i.e: theft). what’s the best way or path to …

---

## [Running Camera with buttons in p5.js](https://discourse.processing.org/t/running-camera-with-buttons-in-p5-js/26281)

<div class="topic-metadata">

**Author:** [@fullmotion](https://discourse.processing.org/u/fullmotion)\
**Replies:** 3\
**Last updated:** [December 16, 2020, 11:20am UTC](https://discourse.processing.org/t/running-camera-with-buttons-in-p5-js/26281 "2020-12-16T11:20:11Z")

</div>

Hello, debugging the camera option in this sketch. 1) Why isn’t camera opening inside the canvas? 2) How can I make the buttons disappear when the camera opens on the canvas? https://editor.p5js.org/fullmotion/sketches/…

---

## [Unexpected code behaviour: nested loops vs manual](https://discourse.processing.org/t/unexpected-code-behaviour-nested-loops-vs-manual/26266)

<div class="topic-metadata">

**Author:** [@Chudroy](https://discourse.processing.org/u/Chudroy)\
**Replies:** 2\
**Last updated:** [December 15, 2020, 12:10pm UTC](https://discourse.processing.org/t/unexpected-code-behaviour-nested-loops-vs-manual/26266 "2020-12-15T12:10:06Z")

</div>

Hi guys, new to the forum here, let me know if I’m doing anything obviously wrong. I made this sketch: My question is: why does the nested loop variation have a cross going through the middle? When I manually draw in…

---

## [P5 image and class](https://discourse.processing.org/t/p5-image-and-class/26105)

<div class="topic-metadata">

**Author:** [@vlafortune](https://discourse.processing.org/u/vlafortune)\
**Replies:** 4\
**Last updated:** [December 14, 2020, 3:56pm UTC](https://discourse.processing.org/t/p5-image-and-class/26105 "2020-12-14T15:56:54Z")

</div>

Hi! I’m having trouble with the image function in p5. I’m following Dan Shiffman tutorial: https://youtu.be/i2C1hrJMwz0 I keep getting the following friendly message : :cherry\_blossom: p5.js says: image() was expectin…

---

## [3D orienting particles using velocity and position vectors in p5js](https://discourse.processing.org/t/3d-orienting-particles-using-velocity-and-position-vectors-in-p5js/26188)

<div class="topic-metadata">

**Author:** [@kaspar.wtf](https://discourse.processing.org/u/kaspar.wtf)\
**Replies:** 0\
**Last updated:** [December 13, 2020, 11:42am UTC](https://discourse.processing.org/t/3d-orienting-particles-using-velocity-and-position-vectors-in-p5js/26188 "2020-12-13T11:42:26Z")

</div>

I’m currently writting a 3D implementation of the boids algorithm in P5.js but I’m having trouble orienting my boids according to their direction (velocity). I’m having a very hard time understand what rotation matrix wo…

---

## [Fixed backgroud in webpage](https://discourse.processing.org/t/fixed-backgroud-in-webpage/25962)

<div class="topic-metadata">

**Author:** [@Axxel](https://discourse.processing.org/u/Axxel)\
**Replies:** 2\
**Last updated:** [December 12, 2020, 8:02am UTC](https://discourse.processing.org/t/fixed-backgroud-in-webpage/25962 "2020-12-12T08:02:58Z")

</div>

Hi friends! I’m trying to add a p5js script as a background on a wordpress page. I did it but the problem I have is when I scroll the page the p5 is moving too and I want to get it fix. I tried by a CSS way using back…

---

## [Radio Buttons (Multiple Possible)](https://discourse.processing.org/t/radio-buttons-multiple-possible/25068)

<div class="topic-metadata">

**Author:** [@BigBigRed](https://discourse.processing.org/u/BigBigRed)\
**Replies:** 1\
**Last updated:** [December 11, 2020, 12:34am UTC](https://discourse.processing.org/t/radio-buttons-multiple-possible/25068 "2020-12-11T00:34:26Z")

</div>

On my sketch, I would like to have multiple groups of radio buttons. So group 1 would be ‘Feature 1 - turn On, turn Off’, group 2 would be ‘Feature 2 - turn On, turn Off’, group 3 would be ’ Feature 3 - either 0, 1, 2…

---

## [Pointer-Event: None like property for p5.js?](https://discourse.processing.org/t/pointer-event-none-like-property-for-p5-js/24339)

<div class="topic-metadata">

**Author:** [@hugoromo](https://discourse.processing.org/u/hugoromo)\
**Replies:** 1\
**Last updated:** [December 11, 2020, 12:13am UTC](https://discourse.processing.org/t/pointer-event-none-like-property-for-p5-js/24339 "2020-12-11T00:13:04Z")

</div>

Hello, So I was wondering if there is any way of making a click pass through from an object at front to an object behind, I’m in a 3D canvas I have a cube made of boxes, and would like to show the stroke of boxes aroun…

---

## [How to split string into words but saving the initial word position](https://discourse.processing.org/t/how-to-split-string-into-words-but-saving-the-initial-word-position/26045)

<div class="topic-metadata">

**Author:** [@jgsantos](https://discourse.processing.org/u/jgsantos)\
**Replies:** 4\
**Last updated:** [December 8, 2020, 7:03pm UTC](https://discourse.processing.org/t/how-to-split-string-into-words-but-saving-the-initial-word-position/26045 "2020-12-08T19:03:11Z")

</div>

Hi! I want to build a sketch where I draw text to the screen as it normally works, as a block of text, but then I want each word to behave separately. At first, I thought it would be easy, just using the spliString funct…

---

## [Why is my result stretched?](https://discourse.processing.org/t/why-is-my-result-stretched/26051)

<div class="topic-metadata">

**Author:** [@olaf000olaf](https://discourse.processing.org/u/olaf000olaf)\
**Replies:** 2\
**Last updated:** [December 8, 2020, 5:33pm UTC](https://discourse.processing.org/t/why-is-my-result-stretched/26051 "2020-12-08T17:33:57Z")

</div>

https://www.openprocessing.org/sketch/1037242 here is my code and this is the tutorial I followed https://www.youtube.com/watch?v=rNqaw8LT2ZU and this is the original image

---

## [How do I resize a loaded image file like you can with video capture?](https://discourse.processing.org/t/how-do-i-resize-a-loaded-image-file-like-you-can-with-video-capture/26047)

<div class="topic-metadata">

**Author:** [@olaf000olaf](https://discourse.processing.org/u/olaf000olaf)\
**Replies:** 1\
**Last updated:** [December 8, 2020, 1:30pm UTC](https://discourse.processing.org/t/how-do-i-resize-a-loaded-image-file-like-you-can-with-video-capture/26047 "2020-12-08T13:30:31Z")

</div>

How do I change the size of an image like a video capture. I want to do the same as in this video by the coding train but instead, load an image, not a video capture.

---

## [Is it possible to access html elements contained in an iframe?](https://discourse.processing.org/t/is-it-possible-to-access-html-elements-contained-in-an-iframe/26030)

<div class="topic-metadata">

**Author:** [@Bassam](https://discourse.processing.org/u/Bassam)\
**Replies:** 1\
**Last updated:** [December 8, 2020, 3:10am UTC](https://discourse.processing.org/t/is-it-possible-to-access-html-elements-contained-in-an-iframe/26030 "2020-12-08T03:10:04Z")

</div>

I want to access the form data of an html page that is displayed in an iframe from within sketch.js. Is this possible? Fullscreen view https://editor.p5js.org/Bassam/full/mwQs-ReOk Code https://editor.p5js.org/Bassam/…

---

## [Image to sine waves](https://discourse.processing.org/t/image-to-sine-waves/25938)

<div class="topic-metadata">

**Author:** [@blaueblume](https://discourse.processing.org/u/blaueblume)\
**Replies:** 6\
**Last updated:** [December 6, 2020, 8:24pm UTC](https://discourse.processing.org/t/image-to-sine-waves/25938 "2020-12-06T20:24:33Z")

</div>

Hello lovely community! I’m working on an p5.js algorithm to transform an image to sine waves, where the amplitude should visualize the grey level of the respective pixel. In my current solution I’m iterating over ever…

---

## [How do I make variations of variables?](https://discourse.processing.org/t/how-do-i-make-variations-of-variables/25936)

<div class="topic-metadata">

**Author:** [@olaf000olaf](https://discourse.processing.org/u/olaf000olaf)\
**Replies:** 19\
**Last updated:** [December 5, 2020, 4:47pm UTC](https://discourse.processing.org/t/how-do-i-make-variations-of-variables/25936 "2020-12-05T16:47:20Z")

</div>

stay with me but u know these brackets \[\] sometimes in other’s code I see it before the variable and idk what it does but I think it means you can have many variables that mean are the same in value but not exactly the s…

---

## [Text input division](https://discourse.processing.org/t/text-input-division/25942)

<div class="topic-metadata">

**Author:** [@Hamsoon22](https://discourse.processing.org/u/Hamsoon22)\
**Replies:** 2\
**Last updated:** [December 5, 2020, 10:13am UTC](https://discourse.processing.org/t/text-input-division/25942 "2020-12-05T10:13:41Z")

</div>

Hi! I am new here. I am now creating a text input and output. I could show the text input on the screen but I don’t know how can I divide the text and just go to the next line automatically. (Because the text input wil…

---

## [Drawing with text to points](https://discourse.processing.org/t/drawing-with-text-to-points/24210)

<div class="topic-metadata">

**Author:** [@GreenCell](https://discourse.processing.org/u/GreenCell)\
**Replies:** 2\
**Last updated:** [December 5, 2020, 12:27am UTC](https://discourse.processing.org/t/drawing-with-text-to-points/24210 "2020-12-05T00:27:26Z")

</div>

Hi! I’m using font’s textToPoints method so later on I can manipulate the points the deform the text, but I have 3 issues. I’m absolutely not asking for complete code here, just ideas that I can try out. I sort of so…

---

## [How do I make a 2 dimensional array?](https://discourse.processing.org/t/how-do-i-make-a-2-dimensional-array/25934)

<div class="topic-metadata">

**Author:** [@MisledWater079](https://discourse.processing.org/u/MisledWater079)\
**Replies:** 3\
**Last updated:** [December 3, 2020, 5:05pm UTC](https://discourse.processing.org/t/how-do-i-make-a-2-dimensional-array/25934 "2020-12-03T17:05:46Z")

</div>

I’m watching a Coding Train video “ Coding Challenge #11: 3D Terrain Generation with Perlin Noise in Processing” and he uses float\[\]\[\]; and it doesn’t work on p5.js and I was wondering if they changed it and what I can u…

---

## [Why do I get the min can only expected only 2 argument but received 4 even though it works like a dream?](https://discourse.processing.org/t/why-do-i-get-the-min-can-only-expected-only-2-argument-but-received-4-even-though-it-works-like-a-dream/25896)

<div class="topic-metadata">

**Author:** [@olaf000olaf](https://discourse.processing.org/u/olaf000olaf)\
**Replies:** 3\
**Last updated:** [December 2, 2020, 8:01pm UTC](https://discourse.processing.org/t/why-do-i-get-the-min-can-only-expected-only-2-argument-but-received-4-even-though-it-works-like-a-dream/25896 "2020-12-02T20:01:01Z")

</div>

I made a function that rounds numbers to the nearest number of your choice using dist and min, whenever the program does the min math it tells me that min can only receive 2 arguments, but it still works? It’s not a prob…

---

## [Applying Specific Colors to Grid Array](https://discourse.processing.org/t/applying-specific-colors-to-grid-array/25852)

<div class="topic-metadata">

**Author:** [@NeatCoder47](https://discourse.processing.org/u/NeatCoder47)\
**Replies:** 4\
**Last updated:** [December 1, 2020, 11:18am UTC](https://discourse.processing.org/t/applying-specific-colors-to-grid-array/25852 "2020-12-01T11:18:54Z")

</div>

Hi! I’m brand new to coding with P5JS and I need some help. I’m currently taking a class for it and I’ve been watching a bunch of The Coding Train videos. For my specific project I’m trying to implement 30 unique colors …

---

## [Use a live video stream (from WebRTC) in P5?](https://discourse.processing.org/t/use-a-live-video-stream-from-webrtc-in-p5/23018)

<div class="topic-metadata">

**Author:** [@banggeul](https://discourse.processing.org/u/banggeul)\
**Replies:** 2\
**Last updated:** [December 1, 2020, 3:22am UTC](https://discourse.processing.org/t/use-a-live-video-stream-from-webrtc-in-p5/23018 "2020-12-01T03:22:29Z")

</div>

Hello, I’d like to run this WebRTC example (https://github.com/webrtc/apprtc) and manipulate the videos (local as well as remote) using P5. How do I work with the live stream video that’s not created by createCapture()? …

---

## [General javascript question re: p5 tutorial](https://discourse.processing.org/t/general-javascript-question-re-p5-tutorial/25471)

<div class="topic-metadata">

**Author:** [@epignosis567](https://discourse.processing.org/u/epignosis567)\
**Replies:** 10\
**Last updated:** [November 30, 2020, 10:46pm UTC](https://discourse.processing.org/t/general-javascript-question-re-p5-tutorial/25471 "2020-11-30T22:46:40Z")

</div>

Hi. I’m following a p5.js tutorial and have the below code. Would anyone be able to help me understand how could add a second image to this fetch? Thanks! \` displayMyImg() .then(function (respons…

---

## [Custom 3d shapes in p5.js](https://discourse.processing.org/t/custom-3d-shapes-in-p5-js/25662)

<div class="topic-metadata">

**Author:** [@sarath.jasrin](https://discourse.processing.org/u/sarath.jasrin)\
**Replies:** 5\
**Last updated:** [November 26, 2020, 11:06pm UTC](https://discourse.processing.org/t/custom-3d-shapes-in-p5-js/25662 "2020-11-26T23:06:30Z")

</div>

I tried to create custom 3d shape using beginShape method. I have successfully created 2d view and added orbitControl. Now I can move around the shape but it looks flat. I tried to use z value but it’s looks different th…

---

## [How can I put html text on top of a 5pjs sketch in html?](https://discourse.processing.org/t/how-can-i-put-html-text-on-top-of-a-5pjs-sketch-in-html/24895)

<div class="topic-metadata">

**Author:** [@olaf000olaf](https://discourse.processing.org/u/olaf000olaf)\
**Replies:** 1\
**Last updated:** [November 26, 2020, 5:41pm UTC](https://discourse.processing.org/t/how-can-i-put-html-text-on-top-of-a-5pjs-sketch-in-html/24895 "2020-11-26T17:41:56Z")

</div>

I have a project I want to put as my background on a website I’m making in HTML, and I want some text to be on top of the project, how do I do that?

---

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

<div class="topic-metadata">

**Author:** [@MattC0des](https://discourse.processing.org/u/MattC0des)\
**Replies:** 2\
**Last updated:** [November 24, 2020, 1:33pm UTC](https://discourse.processing.org/t/cannot-read-property-of-split-undefined/25652 "2020-11-24T13:33:51Z")

</div>

Hello, I am quite new to p5js (on and off for the past few months) but as of recently, I have run into a problem that myself nor my peers or teacher can solve. We are working on an application that is like a word per min…

---

## [Rotation movement during noLoop](https://discourse.processing.org/t/rotation-movement-during-noloop/25629)

<div class="topic-metadata">

**Author:** [@sally](https://discourse.processing.org/u/sally)\
**Replies:** 3\
**Last updated:** [November 23, 2020, 7:47pm UTC](https://discourse.processing.org/t/rotation-movement-during-noloop/25629 "2020-11-23T19:47:17Z")

</div>

Hi, I’m new to coding for my student work. I’m making combining random objects + random words. I’m trying to put related code and some point it’s working. But when I put noLoop, the rotation movement is not working… …

---

## [Bulk preload images with different variable name from JSON - p5.js web](https://discourse.processing.org/t/bulk-preload-images-with-different-variable-name-from-json-p5-js-web/25610)

<div class="topic-metadata">

**Author:** [@patkosd](https://discourse.processing.org/u/patkosd)\
**Replies:** 1\
**Last updated:** [November 23, 2020, 2:15am UTC](https://discourse.processing.org/t/bulk-preload-images-with-different-variable-name-from-json-p5-js-web/25610 "2020-11-23T02:15:48Z")

</div>

Hi, I have a JSON file populated with “brandName” and “brandLogo” fields. I’m trying to preload 30ish logos to my project so I can display them when needed later on in the code. I’d also like to assign the images to va…

---

## [How will you approach this picture?](https://discourse.processing.org/t/how-will-you-approach-this-picture/24837)

<div class="topic-metadata">

**Author:** [@Huno](https://discourse.processing.org/u/Huno)\
**Replies:** 23\
**Last updated:** [November 21, 2020, 10:15am UTC](https://discourse.processing.org/t/how-will-you-approach-this-picture/24837 "2020-11-21T10:15:20Z")

</div>

Like a lot of us, I’ve been a fan of Autechre since 2001 (I was 11) and I’ve been always amazed by their covers. There are a couple of covers that always make me think of raw code. So my question is, how will you appro…

---

## [Using mask to reveal background image](https://discourse.processing.org/t/using-mask-to-reveal-background-image/25528)

<div class="topic-metadata">

**Author:** [@andypurbrick](https://discourse.processing.org/u/andypurbrick)\
**Replies:** 2\
**Last updated:** [November 20, 2020, 4:22pm UTC](https://discourse.processing.org/t/using-mask-to-reveal-background-image/25528 "2020-11-20T16:22:06Z")

</div>

Hi, I’m trying to write a sketch that uses mask to temporarily reveal a background/bottom image when the mouse pointer moves but does not permanently draw over it. I have a sketch written based on reading docs and looki…

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

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