# Coding Questions

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

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

**Page:** 40

---

## [mousePressed() with several objects](https://discourse.processing.org/t/mousepressed-with-several-objects/14157)

<div class="topic-metadata">

**Author:** [@Paulo](https://discourse.processing.org/u/Paulo)\
**Replies:** 2\
**Last updated:** [September 25, 2019, 1:24pm UTC](https://discourse.processing.org/t/mousepressed-with-several-objects/14157 "2019-09-25T13:24:38Z")

</div>

Hi, The code below shows how to used mousePressed() with a form, but I have no idea how to use it with several forms. I am building an Org Chart with hundreds of nodes and I would like to use mousePressed() to collapse…

---

## [Blurred Image instead of pixels visible](https://discourse.processing.org/t/blurred-image-instead-of-pixels-visible/14071)

<div class="topic-metadata">

**Author:** [@mikolaskoa](https://discourse.processing.org/u/mikolaskoa)\
**Replies:** 4\
**Last updated:** [September 21, 2019, 4:59pm UTC](https://discourse.processing.org/t/blurred-image-instead-of-pixels-visible/14071 "2019-09-21T16:59:32Z")

</div>

Hello, how can I make the pixels of an image stay sharp on screen? When I create them directly with the set-Method, they stay sharp. When creating an image - they get blurred (which is usefull if there are gradients,…

---

## [Help with sine waves](https://discourse.processing.org/t/help-with-sine-waves/14040)

<div class="topic-metadata">

**Author:** [@erinhasplants](https://discourse.processing.org/u/erinhasplants)\
**Replies:** 3\
**Last updated:** [September 18, 2019, 5:46pm UTC](https://discourse.processing.org/t/help-with-sine-waves/14040 "2019-09-18T17:46:31Z")

</div>

https://editor.p5js.org/johnbeesley/sketches/UBFN-z8ob i have this sketch ^ and its going all well, but i cant figure out how I can make the circles go different ways, and make a sine wave. i have the sine wave out of …

---

## [createGraphics on mobile device](https://discourse.processing.org/t/creategraphics-on-mobile-device/13987)

<div class="topic-metadata">

**Author:** [@b\_and\_z](https://discourse.processing.org/u/b_and_z)\
**Replies:** 2\
**Last updated:** [September 18, 2019, 3:43pm UTC](https://discourse.processing.org/t/creategraphics-on-mobile-device/13987 "2019-09-18T15:43:23Z")

</div>

so working with createGraphics and hi DPI screens is a known issue which apparently has been fixed. However, I still have some struggles with working with Graphics on mobile devices. I have this code where stuff is draw…

---

## [Pass image path into loadimage](https://discourse.processing.org/t/pass-image-path-into-loadimage/13966)

<div class="topic-metadata">

**Author:** [@KicksTV](https://discourse.processing.org/u/KicksTV)\
**Replies:** 5\
**Last updated:** [September 13, 2019, 12:05pm UTC](https://discourse.processing.org/t/pass-image-path-into-loadimage/13966 "2019-09-13T12:05:33Z")

</div>

I am having the problem where I want to pass a variable with image path into loadImage(). However, I am getting the error: This must be possible but I don’t see anything in docs or online demonstrating this.

---

## [Making shapes and deleting them?](https://discourse.processing.org/t/making-shapes-and-deleting-them/13888)

<div class="topic-metadata">

**Author:** [@freek\_b](https://discourse.processing.org/u/freek_b)\
**Replies:** 8\
**Last updated:** [September 9, 2019, 3:58pm UTC](https://discourse.processing.org/t/making-shapes-and-deleting-them/13888 "2019-09-09T15:58:04Z")

</div>

i have tried to find a way to add shapes (circles and so) while its running just the problem is i am not able to find the right command i have found a few people saying that i should use something alike new circle(20,2…

---

## [How do I get my sketch to show the steps of a drawing](https://discourse.processing.org/t/how-do-i-get-my-sketch-to-show-the-steps-of-a-drawing/13808)

<div class="topic-metadata">

**Author:** [@rbytes](https://discourse.processing.org/u/rbytes)\
**Replies:** 2\
**Last updated:** [September 5, 2019, 1:04am UTC](https://discourse.processing.org/t/how-do-i-get-my-sketch-to-show-the-steps-of-a-drawing/13808 "2019-09-05T01:04:31Z")

</div>

When I run my sketch “Spiral of Theodore’s” on OpenProcessing, the entire drawing appears almost instantly. I would prefer that it appear triangle by triangle, so that other viewers could see the progress. I have been …

---

## [Using the Mouse as a Drawing Tool](https://discourse.processing.org/t/using-the-mouse-as-a-drawing-tool/13833)

<div class="topic-metadata">

**Author:** [@van326](https://discourse.processing.org/u/van326)\
**Replies:** 2\
**Last updated:** [September 6, 2019, 2:34am UTC](https://discourse.processing.org/t/using-the-mouse-as-a-drawing-tool/13833 "2019-09-06T02:34:11Z")

</div>

Hi! I am currently playing around with coding the ability to draw in p5.js, and so far it’s turning out okay, but I have a question about using the mouse as a brush. Ideally, I would like to have it where whenever the us…

---

## [Find EOF on CSV file](https://discourse.processing.org/t/find-eof-on-csv-file/13807)

<div class="topic-metadata">

**Author:** [@GuilhermeVolker](https://discourse.processing.org/u/GuilhermeVolker)\
**Replies:** 4\
**Last updated:** [September 5, 2019, 12:13am UTC](https://discourse.processing.org/t/find-eof-on-csv-file/13807 "2019-09-05T00:13:06Z")

</div>

Hi. I have to find the EOF (end of the file) in javaScript. I have try’d some possibilities without success. let i = myFile.realine(); if(myFile == EOF){ ... } with this code appears the following message: TypeError…

---

## [Storing functions in array or arraylist returns null pointer](https://discourse.processing.org/t/storing-functions-in-array-or-arraylist-returns-null-pointer/13749)

<div class="topic-metadata">

**Author:** [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Replies:** 2\
**Last updated:** [September 1, 2019, 8:03pm UTC](https://discourse.processing.org/t/storing-functions-in-array-or-arraylist-returns-null-pointer/13749 "2019-09-01T20:03:28Z")

</div>

I’m converting code from p5 to processing. I was storing functions in an array. These functions create the buttons which I’m using in my application and allowed me to loop through the array to draw and manipulate the but…

---

## [Applying a background image to a rect()](https://discourse.processing.org/t/applying-a-background-image-to-a-rect/13711)

<div class="topic-metadata">

**Author:** [@Bubblebyb](https://discourse.processing.org/u/Bubblebyb)\
**Replies:** 2\
**Last updated:** [August 31, 2019, 11:43pm UTC](https://discourse.processing.org/t/applying-a-background-image-to-a-rect/13711 "2019-08-31T23:43:27Z")

</div>

Is it possible to have a background image for a rect() in p5? I’ve seem some answers that suggest a workaround by using a mask but all I’m looking for is having an image as a background for a shape such as a rect().

---

## [Catching a specific string position from a txt file](https://discourse.processing.org/t/catching-a-specific-string-position-from-a-txt-file/13685)

<div class="topic-metadata">

**Author:** [@GuilhermeVolker](https://discourse.processing.org/u/GuilhermeVolker)\
**Replies:** 5\
**Last updated:** [August 29, 2019, 3:04pm UTC](https://discourse.processing.org/t/catching-a-specific-string-position-from-a-txt-file/13685 "2019-08-29T15:04:36Z")

</div>

Hi I’am loading a .txt file, it has a lot of data, each line has 16 values and i need to read separetly each colum and store in a variable. Here is what i have try’d let year; let data; function preload(){ data = lo…

---

## [Natural Movement with Noise](https://discourse.processing.org/t/natural-movement-with-noise/13684)

<div class="topic-metadata">

**Author:** [@vchinner](https://discourse.processing.org/u/vchinner)\
**Replies:** 1\
**Last updated:** [August 29, 2019, 1:43pm UTC](https://discourse.processing.org/t/natural-movement-with-noise/13684 "2019-08-29T13:43:02Z")

</div>

Im creating a an object that randomly moves in a natural way using noise like this (works as intended): thisRabbit.x = \_world.width \* (noise(thisRabbit.t)); thisRabbit.y = \_world.height \* (noise(thisRabbit.t+5))…

---

## [Hide all bezier curves except the one on mouse hover](https://discourse.processing.org/t/hide-all-bezier-curves-except-the-one-on-mouse-hover/13618)

<div class="topic-metadata">

**Author:** [@VMK](https://discourse.processing.org/u/VMK)\
**Replies:** 26\
**Last updated:** [August 29, 2019, 12:08pm UTC](https://discourse.processing.org/t/hide-all-bezier-curves-except-the-one-on-mouse-hover/13618 "2019-08-29T12:08:24Z")

</div>

Greetings! I have four bezier curves (pasted code for two below as MCVE), and would like to be able to show only one if the mouse is hovered over the respective one. I tried finding how to assign a class to the curve,…

---

## [Resize Background Image when Resizing Window in p5.js?](https://discourse.processing.org/t/resize-background-image-when-resizing-window-in-p5-js/13671)

<div class="topic-metadata">

**Author:** [@zacharyfruhling](https://discourse.processing.org/u/zacharyfruhling)\
**Replies:** 1\
**Last updated:** [August 28, 2019, 8:36pm UTC](https://discourse.processing.org/t/resize-background-image-when-resizing-window-in-p5-js/13671 "2019-08-28T20:36:10Z")

</div>

I’m having trouble getting the background image for a p5.js sketch to resize along with the window resize function. Basically I’m preloading the image in the preload function, resizing it to match the current window widt…

---

## [Solving an Unexpected Identifier](https://discourse.processing.org/t/solving-an-unexpected-identifier/13645)

<div class="topic-metadata">

**Author:** [@VMK](https://discourse.processing.org/u/VMK)\
**Replies:** 4\
**Last updated:** [August 28, 2019, 12:25pm UTC](https://discourse.processing.org/t/solving-an-unexpected-identifier/13645 "2019-08-28T12:25:15Z")

</div>

Greetings! I’m trying to create a class to draw a bezier curve but seeing ‘unexpected identifier’ error which doesn’t make sense to me : http://tiny.cc/xy7sbz https://editor.p5js.org/VMK/sketches/D-GpdoGiM Any help wo…

---

## [Colored circles](https://discourse.processing.org/t/colored-circles/13656)

<div class="topic-metadata">

**Author:** [@BennyElie](https://discourse.processing.org/u/BennyElie)\
**Replies:** 1\
**Last updated:** [August 28, 2019, 1:26am UTC](https://discourse.processing.org/t/colored-circles/13656 "2019-08-28T01:26:49Z")

</div>

Hi, If I have a series of circles and I would like to color them one by one, let’s say their initial state is white and I would like them to one by one change to red, how would I be able to approach this? regarding t…

---

## [Upload pGraphics to server](https://discourse.processing.org/t/upload-pgraphics-to-server/13558)

<div class="topic-metadata">

**Author:** [@philipplehmann](https://discourse.processing.org/u/philipplehmann)\
**Replies:** 3\
**Last updated:** [August 26, 2019, 3:07pm UTC](https://discourse.processing.org/t/upload-pgraphics-to-server/13558 "2019-08-26T15:07:10Z")

</div>

I’d like to save a pGraphics object as a PNG-image to the server. I found a way to upload the canvas object. Is it possible to export a pGraphics object in a similar way? function saveImage() { // Export canvas …

---

## [createGraphics save the whole sketch](https://discourse.processing.org/t/creategraphics-save-the-whole-sketch/13594)

<div class="topic-metadata">

**Author:** [@l3ehfar](https://discourse.processing.org/u/l3ehfar)\
**Replies:** 5\
**Last updated:** [August 26, 2019, 12:17pm UTC](https://discourse.processing.org/t/creategraphics-save-the-whole-sketch/13594 "2019-08-26T12:17:40Z")

</div>

how can I pass the whole sketch as a function to the createGraphics variable and not get the error as “img.pattern is not a function”?

---

## [Motion Detection - Chrome Browser Crashes or No Image](https://discourse.processing.org/t/motion-detection-chrome-browser-crashes-or-no-image/13400)

<div class="topic-metadata">

**Author:** [@stilts77](https://discourse.processing.org/u/stilts77)\
**Replies:** 4\
**Last updated:** [August 25, 2019, 5:02pm UTC](https://discourse.processing.org/t/motion-detection-chrome-browser-crashes-or-no-image/13400 "2019-08-25T17:02:51Z")

</div>

I found some code… I have adapted it slightly (following watching a Dan Shiffman Processing video) - but can’t get it to work. Here is the page I’ve created: Webcam motion detection In the Shiffman video online - we se…

---

## [Problem with conditional structure with « if » into loop](https://discourse.processing.org/t/problem-with-conditional-structure-with-if-into-loop/13551)

<div class="topic-metadata">

**Author:** [@jerome51](https://discourse.processing.org/u/jerome51)\
**Replies:** 2\
**Last updated:** [August 23, 2019, 8:29am UTC](https://discourse.processing.org/t/problem-with-conditional-structure-with-if-into-loop/13551 "2019-08-23T08:29:11Z")

</div>

Hi, Sorry for my english, i’m french. I’d like to check each pixel from image by step of 5 and write coordinates into an array of each pixel whose value is under 150. I used a loops to check pixels and a « if » to ver…

---

## [How to clean this JSON?](https://discourse.processing.org/t/how-to-clean-this-json/13511)

<div class="topic-metadata">

**Author:** [@vjjv](https://discourse.processing.org/u/vjjv)\
**Replies:** 6\
**Last updated:** [August 21, 2019, 5:56pm UTC](https://discourse.processing.org/t/how-to-clean-this-json/13511 "2019-08-21T17:56:37Z")

</div>

Hellooo! im using google Apis to request data from a blog. I want to be able to acces the content of a post, but in the json file the body of the text is between html code. how can i remove it ? in orden to get only the…

---

## [How to have a p5 sketch continue to run while not in the selected tab?](https://discourse.processing.org/t/how-to-have-a-p5-sketch-continue-to-run-while-not-in-the-selected-tab/13476)

<div class="topic-metadata">

**Author:** [@Quillbert1](https://discourse.processing.org/u/Quillbert1)\
**Replies:** 2\
**Last updated:** [August 19, 2019, 5:47pm UTC](https://discourse.processing.org/t/how-to-have-a-p5-sketch-continue-to-run-while-not-in-the-selected-tab/13476 "2019-08-19T17:47:30Z")

</div>

I am making a p5 sketch, and I want it to be able to run while it is in the background, but whenever its tab is not selected, it pauses. How do I fix this?

---

## [Weird arc full circle (bug?)](https://discourse.processing.org/t/weird-arc-full-circle-bug/13439)

<div class="topic-metadata">

**Author:** [@atuco](https://discourse.processing.org/u/atuco)\
**Replies:** 1\
**Last updated:** [August 17, 2019, 10:53pm UTC](https://discourse.processing.org/t/weird-arc-full-circle-bug/13439 "2019-08-17T22:53:58Z")

</div>

Hi, I try to export a processing sketch in js but I’ve a strange behaviour. There are stranges randoms (and always in the begining of the sketch) full circles only in the js You can see in this page: https://codepen.io…

---

## [Drag & Drop Folders impossible?](https://discourse.processing.org/t/drag-drop-folders-impossible/13394)

<div class="topic-metadata">

**Author:** [@kaotiklabs](https://discourse.processing.org/u/kaotiklabs)\
**Replies:** 1\
**Last updated:** [August 16, 2019, 11:48pm UTC](https://discourse.processing.org/t/drag-drop-folders-impossible/13394 "2019-08-16T23:48:45Z")

</div>

Hi, I need to drop files or folders into my p5js canvas. I’m using cnv.drop() but it only allows for a single file or an array of files. How could I also drop folders? How are you doing it? Thanks in advance.

---

## [Blockly javascript code](https://discourse.processing.org/t/blockly-javascript-code/13288)

<div class="topic-metadata">

**Author:** [@deseingalt](https://discourse.processing.org/u/deseingalt)\
**Replies:** 5\
**Last updated:** [August 16, 2019, 5:55pm UTC](https://discourse.processing.org/t/blockly-javascript-code/13288 "2019-08-16T17:55:33Z")

</div>

Hi, Does anybody know how to adapt a blockly javascript code to P5.Js…? Thanks

---

## [Positioning styled Dom elements](https://discourse.processing.org/t/positioning-styled-dom-elements/13369)

<div class="topic-metadata">

**Author:** [@rkdnson](https://discourse.processing.org/u/rkdnson)\
**Replies:** 1\
**Last updated:** [August 14, 2019, 1:45am UTC](https://discourse.processing.org/t/positioning-styled-dom-elements/13369 "2019-08-14T01:45:31Z")

</div>

I am having trouble positioning a checkbox after calling the style.transform function to scale it. In posting this I am finding similar topics using select() but am still unsure. Below, my goal would be that the checkbo…

---

## [P5.js and WebGL: drawing lines](https://discourse.processing.org/t/p5-js-and-webgl-drawing-lines/13274)

<div class="topic-metadata">

**Author:** [@graysonh](https://discourse.processing.org/u/graysonh)\
**Replies:** 3\
**Last updated:** [August 12, 2019, 8:38pm UTC](https://discourse.processing.org/t/p5-js-and-webgl-drawing-lines/13274 "2019-08-12T20:38:08Z")

</div>

Hi All, I’m very new to p5 (coming from Processing) and am attempting to convert one of my processing sketches into p5 so I can run it on OpenProcessing. My sketch involves using a texture, so I am using WebGL, but the…

---

## ["focused" in iOS Safari](https://discourse.processing.org/t/focused-in-ios-safari/12007)

<div class="topic-metadata">

**Author:** [@phoebus](https://discourse.processing.org/u/phoebus)\
**Replies:** 3\
**Last updated:** [August 12, 2019, 5:19pm UTC](https://discourse.processing.org/t/focused-in-ios-safari/12007 "2019-08-12T17:19:55Z")

</div>

Hello focused parameter doesn’t seem to work ok on Safari for iOS My website works fine on FireFox / Chrome / Edge on Mac / Windows / Linux / Android / iOS but on Safari/iOS it doesn’t get that “focused” is true Haven…

---

## [mouseWheel in Safari not active?](https://discourse.processing.org/t/mousewheel-in-safari-not-active/7428)

<div class="topic-metadata">

**Author:** [@maxbatt](https://discourse.processing.org/u/maxbatt)\
**Replies:** 5\
**Last updated:** [August 10, 2019, 10:29pm UTC](https://discourse.processing.org/t/mousewheel-in-safari-not-active/7428 "2019-08-10T22:29:52Z")

</div>

Hello all! Just signed up today and excited to be part of the forum. I am wondering if there is a way to activate mouseWheel in safari? For me, the example at p5.org doesn’t work in safari, and the page I am trying to b…

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

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