# Coding Questions

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

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

**Page:** 33

---

## [Strange performance issue](https://discourse.processing.org/t/strange-performance-issue/20976)

<div class="topic-metadata">

**Author:** [@Miguelac](https://discourse.processing.org/u/Miguelac)\
**Replies:** 2\
**Last updated:** [May 18, 2020, 7:21am UTC](https://discourse.processing.org/t/strange-performance-issue/20976 "2020-05-18T07:21:18Z")

</div>

I’m writing a game (a clone of the game “untangle”) and I’m quite happy with how it turned out. However, while yesterday the game was running well on my phone, today after a few small additions for new features I notice…

---

## [Uncaught TypeError: Cannot read property 'collide' of undefined (sketch: line 19)](https://discourse.processing.org/t/uncaught-typeerror-cannot-read-property-collide-of-undefined-sketch-line-19/20914)

<div class="topic-metadata">

**Author:** [@cmoredock](https://discourse.processing.org/u/cmoredock)\
**Replies:** 5\
**Last updated:** [May 18, 2020, 6:45am UTC](https://discourse.processing.org/t/uncaught-typeerror-cannot-read-property-collide-of-undefined-sketch-line-19/20914 "2020-05-18T06:45:20Z")

</div>

Hello, I am trying to spend some time to figure out how to track and remove elements from an object array, and “thought” I had a pretty good understanding of what I needed to do. I am getting the above error on occasion…

---

## [Canvas size does not resize on click](https://discourse.processing.org/t/canvas-size-does-not-resize-on-click/20941)

<div class="topic-metadata">

**Author:** [@lerelolli](https://discourse.processing.org/u/lerelolli)\
**Replies:** 4\
**Last updated:** [May 17, 2020, 10:32am UTC](https://discourse.processing.org/t/canvas-size-does-not-resize-on-click/20941 "2020-05-17T10:32:18Z")

</div>

I have multiple different sketches defined and put them all in an array so I can iterate through them and show them one by one with an on click event. It does work fine except when I change the visual after a window resi…

---

## [Buttons to switch sketches in the browser?](https://discourse.processing.org/t/buttons-to-switch-sketches-in-the-browser/20607)

<div class="topic-metadata">

**Author:** [@ballinoates](https://discourse.processing.org/u/ballinoates)\
**Replies:** 6\
**Last updated:** [May 17, 2020, 2:42am UTC](https://discourse.processing.org/t/buttons-to-switch-sketches-in-the-browser/20607 "2020-05-17T02:42:15Z")

</div>

Hi all- Im new to p5js but decent in processing 3, so my apologies up front. I would like to have lets say 4 sketches in p5js available for users to swap between. Lets say for simplicity a 400x400 canvas and below the c…

---

## [noErase() is not working in WEBGL](https://discourse.processing.org/t/noerase-is-not-working-in-webgl/20920)

<div class="topic-metadata">

**Author:** [@vheun](https://discourse.processing.org/u/vheun)\
**Replies:** 4\
**Last updated:** [May 16, 2020, 1:50pm UTC](https://discourse.processing.org/t/noerase-is-not-working-in-webgl/20920 "2020-05-16T13:50:25Z")

</div>

The following example does not work the way it should. Once erase() is called it just erases everything. noErase() is not stopping the mode. https://p5js.org/reference/#/p5/erase

---

## [Position relative to shape](https://discourse.processing.org/t/position-relative-to-shape/20926)

<div class="topic-metadata">

**Author:** [@casperleerink](https://discourse.processing.org/u/casperleerink)\
**Replies:** 1\
**Last updated:** [May 16, 2020, 7:17am UTC](https://discourse.processing.org/t/position-relative-to-shape/20926 "2020-05-16T07:17:34Z")

</div>

Hi! Beginner question: is it possible to position elements relative to another shape. For example lets say I want to place 9 rectangles into another rectangle, it would be great if the size and position of the child rec…

---

## [Problem with my button](https://discourse.processing.org/t/problem-with-my-button/20868)

<div class="topic-metadata">

**Author:** [@Coco5](https://discourse.processing.org/u/Coco5)\
**Replies:** 11\
**Last updated:** [May 15, 2020, 10:21pm UTC](https://discourse.processing.org/t/problem-with-my-button/20868 "2020-05-15T22:21:09Z")

</div>

Hi, I have a little problem with p5js. My code was working very well until I added a button to save my canvas. I don’t understand why when I add the button in the function setup, it is making my code to crash. //QUELQU…

---

## [How to nicely generate a graph of a function of two variables with a restriction on the domain?](https://discourse.processing.org/t/how-to-nicely-generate-a-graph-of-a-function-of-two-variables-with-a-restriction-on-the-domain/20760)

<div class="topic-metadata">

**Author:** [@jancnahn](https://discourse.processing.org/u/jancnahn)\
**Replies:** 2\
**Last updated:** [May 15, 2020, 3:31pm UTC](https://discourse.processing.org/t/how-to-nicely-generate-a-graph-of-a-function-of-two-variables-with-a-restriction-on-the-domain/20760 "2020-05-15T15:31:14Z")

</div>

Hello, I recently got into p5 from watching The Coding Train, and I wish to generate two-dimensional surfaces in 3D (like using WEBGL) given by a function of two variables. If there is a function in Processing that doe…

---

## [defaultCanvas problem](https://discourse.processing.org/t/defaultcanvas-problem/20776)

<div class="topic-metadata">

**Author:** [@TDSV](https://discourse.processing.org/u/TDSV)\
**Replies:** 4\
**Last updated:** [May 14, 2020, 10:51am UTC](https://discourse.processing.org/t/defaultcanvas-problem/20776 "2020-05-14T10:51:26Z")

</div>

Hello I have a problem with p5js, I use video capture. The code works well and is displayed correctly. But by associating my P5Js with my HTML, I have two defaultCanvas that appear in my HTML when I inspect. one with my…

---

## [Loading an array of images on mouse position - going from processing to p5.js](https://discourse.processing.org/t/loading-an-array-of-images-on-mouse-position-going-from-processing-to-p5-js/20780)

<div class="topic-metadata">

**Author:** [@mixel](https://discourse.processing.org/u/mixel)\
**Replies:** 1\
**Last updated:** [May 12, 2020, 10:19pm UTC](https://discourse.processing.org/t/loading-an-array-of-images-on-mouse-position-going-from-processing-to-p5-js/20780 "2020-05-12T22:19:19Z")

</div>

Hi, I’ve created this working code in processing and would like to implement it on a website - I am completely new to this, so I am not sure whether or not it is possible to convert this to p5.js with just a few changes…

---

## [How do I enable/disable a selection box?](https://discourse.processing.org/t/how-do-i-enable-disable-a-selection-box/20656)

<div class="topic-metadata">

**Author:** [@Bassam](https://discourse.processing.org/u/Bassam)\
**Replies:** 4\
**Last updated:** [May 12, 2020, 5:34pm UTC](https://discourse.processing.org/t/how-do-i-enable-disable-a-selection-box/20656 "2020-05-12T17:34:46Z")

</div>

Is this possible? I know that I can disable options in a selection box via .disable(option) but I’d like to be able to enable/disable the box itself.

---

## [Multiple seed values for noise](https://discourse.processing.org/t/multiple-seed-values-for-noise/20695)

<div class="topic-metadata">

**Author:** [@shinyogre](https://discourse.processing.org/u/shinyogre)\
**Replies:** 3\
**Last updated:** [May 12, 2020, 8:02am UTC](https://discourse.processing.org/t/multiple-seed-values-for-noise/20695 "2020-05-12T08:02:03Z")

</div>

I have multiple layers of 1D perlin noise rendering with vertices via beginShape() and endShape(). I noticed however that because each layer uses the same noise seed, their shape is quite similar and the effect is a les…

---

## [Is it possible to get the index of the array object that called a function?](https://discourse.processing.org/t/is-it-possible-to-get-the-index-of-the-array-object-that-called-a-function/20769)

<div class="topic-metadata">

**Author:** [@Bassam](https://discourse.processing.org/u/Bassam)\
**Replies:** 2\
**Last updated:** [May 12, 2020, 6:09am UTC](https://discourse.processing.org/t/is-it-possible-to-get-the-index-of-the-array-object-that-called-a-function/20769 "2020-05-12T06:09:47Z")

</div>

So I learned some time ago on this forum that the same function can be called by a button press and it’s possible to determine which button did the pressing: function buttonPressListener(){ switch (this) { c…

---

## [Question concerning p5.js](https://discourse.processing.org/t/question-concerning-p5-js/20703)

<div class="topic-metadata">

**Author:** [@salisha](https://discourse.processing.org/u/salisha)\
**Replies:** 1\
**Last updated:** [May 10, 2020, 6:09am UTC](https://discourse.processing.org/t/question-concerning-p5-js/20703 "2020-05-10T06:09:52Z")

</div>

Hi all, I have a little problem using p5.js. I uploaded a personal jpeg image to p5.js web editor and I will now like to add butterflies to it. Just a few butterflies to be flying/moving about the image that I uploaded…

---

## [Change canvas rendering dynamically](https://discourse.processing.org/t/change-canvas-rendering-dynamically/20663)

<div class="topic-metadata">

**Author:** [@Golum](https://discourse.processing.org/u/Golum)\
**Replies:** 6\
**Last updated:** [May 9, 2020, 11:08pm UTC](https://discourse.processing.org/t/change-canvas-rendering-dynamically/20663 "2020-05-09T23:08:56Z")

</div>

Hello everybody ! I’m currently coding a small app which allows to create 2D shapes and display then in 3D. The html code creates 1 button for 2D rendering and another one for 3D rendering. In the p5.js file, I create…

---

## [Filling 1D noise optimally](https://discourse.processing.org/t/filling-1d-noise-optimally/20666)

<div class="topic-metadata">

**Author:** [@shinyogre](https://discourse.processing.org/u/shinyogre)\
**Replies:** 2\
**Last updated:** [May 9, 2020, 2:42pm UTC](https://discourse.processing.org/t/filling-1d-noise-optimally/20666 "2020-05-09T14:42:59Z")

</div>

I am generating vertices using perlin noise and making a shape out of them with beginShape() and endShape(). I am then scrolling to the left while generating more vertices on the right. https://editor.p5js.org/shinyogr…

---

## [Animating the loadImage function?](https://discourse.processing.org/t/animating-the-loadimage-function/20629)

<div class="topic-metadata">

**Author:** [@cuvner](https://discourse.processing.org/u/cuvner)\
**Replies:** 3\
**Last updated:** [May 9, 2020, 9:23am UTC](https://discourse.processing.org/t/animating-the-loadimage-function/20629 "2020-05-09T09:23:17Z")

</div>

Here is my code for a 3d spinning cube and using texture to lay images from an array, json file, to project on to the cube. The image update currently is at the sketch frame rate and I want to control the update speed b…

---

## [Performance. Is there any way to make work faster?](https://discourse.processing.org/t/performance-is-there-any-way-to-make-work-faster/20183)

<div class="topic-metadata">

**Author:** [@kmorozov](https://discourse.processing.org/u/kmorozov)\
**Replies:** 3\
**Last updated:** [May 8, 2020, 6:02am UTC](https://discourse.processing.org/t/performance-is-there-any-way-to-make-work-faster/20183 "2020-05-08T06:02:24Z")

</div>

Hi all. I’m trying to study p5js and desided to rewrite some sketch from processing to p5js. Here it is - https://www.openprocessing.org/sketch/882019. Original tutorial in processing is here - https://timrodenbroeker.…

---

## [How do I make an input box accept numbers only?](https://discourse.processing.org/t/how-do-i-make-an-input-box-accept-numbers-only/20572)

<div class="topic-metadata">

**Author:** [@Bassam](https://discourse.processing.org/u/Bassam)\
**Replies:** 9\
**Last updated:** [May 7, 2020, 10:26pm UTC](https://discourse.processing.org/t/how-do-i-make-an-input-box-accept-numbers-only/20572 "2020-05-07T22:26:43Z")

</div>

let x=createInput("", "number"); creates a textbox with tiny scrollbars to scroll through the numbers and can also have negative numbers. I want to create a textbox so that people can put in their age.

---

## [Seeking p5 data visualization help](https://discourse.processing.org/t/seeking-p5-data-visualization-help/20334)

<div class="topic-metadata">

**Author:** [@felixthefein](https://discourse.processing.org/u/felixthefein)\
**Replies:** 4\
**Last updated:** [May 7, 2020, 1:35am UTC](https://discourse.processing.org/t/seeking-p5-data-visualization-help/20334 "2020-05-07T01:35:29Z")

</div>

Hello, I am new to p5, and I am creating a simple data visualization about wind using data from an accelerometer (in a .csv file). My “x” values are represented by the variable sensorx, and my “y” values are represente…

---

## [On Chrome, createSlider with instance mode makes duplicated sliders](https://discourse.processing.org/t/on-chrome-createslider-with-instance-mode-makes-duplicated-sliders/20531)

<div class="topic-metadata">

**Author:** [@ahirose](https://discourse.processing.org/u/ahirose)\
**Replies:** 3\
**Last updated:** [May 6, 2020, 12:05pm UTC](https://discourse.processing.org/t/on-chrome-createslider-with-instance-mode-makes-duplicated-sliders/20531 "2020-05-06T12:05:07Z")

</div>

Hi all, Thank you for your effort to keep the quality of this great community. I just tried to port a createSlider example to the instance mode then hit a issue. How can I solve it? Following is my code, it’s working …

---

## [Looping a texture on 3D Shape that Reacts to Slider Adjustments](https://discourse.processing.org/t/looping-a-texture-on-3d-shape-that-reacts-to-slider-adjustments/20528)

<div class="topic-metadata">

**Author:** [@mzerby](https://discourse.processing.org/u/mzerby)\
**Replies:** 0\
**Last updated:** [May 6, 2020, 4:20am UTC](https://discourse.processing.org/t/looping-a-texture-on-3d-shape-that-reacts-to-slider-adjustments/20528 "2020-05-06T04:20:19Z")

</div>

Hello! I am trying to figure out how to create a looping texture on a 3D that will restart after it has filled the shape to reflect the adjustment made with the slider. I currently have a texture that is a spiral pattern…

---

## [Help parsing an array inside a String](https://discourse.processing.org/t/help-parsing-an-array-inside-a-string/19934)

<div class="topic-metadata">

**Author:** [@Yom](https://discourse.processing.org/u/Yom)\
**Replies:** 7\
**Last updated:** [May 5, 2020, 4:58pm UTC](https://discourse.processing.org/t/help-parsing-an-array-inside-a-string/19934 "2020-05-05T16:58:36Z")

</div>

Hello I need help with parsing a String to get the content of an array. I know nothing about regular expressions, patterns, it looks so complicated… I’ve tried a few things but nothing works :frowning: But I’m almost su…

---

## [How do I load a .txt file into a textbox and make the textbox readonly?](https://discourse.processing.org/t/how-do-i-load-a-txt-file-into-a-textbox-and-make-the-textbox-readonly/20407)

<div class="topic-metadata">

**Author:** [@Bassam](https://discourse.processing.org/u/Bassam)\
**Replies:** 3\
**Last updated:** [May 4, 2020, 2:09pm UTC](https://discourse.processing.org/t/how-do-i-load-a-txt-file-into-a-textbox-and-make-the-textbox-readonly/20407 "2020-05-04T14:09:33Z")

</div>

I’m trying to create essentially a EULA page. I want to load a preexisting text file into it a textbox and I want to make the textbox read only. Is this possible in p5.js? Thanks in advance. https://editor.p5js.org/B…

---

## [Drag and Drop random behaviour](https://discourse.processing.org/t/drag-and-drop-random-behaviour/20419)

<div class="topic-metadata">

**Author:** [@yurikleb](https://discourse.processing.org/u/yurikleb)\
**Replies:** 2\
**Last updated:** [May 4, 2020, 10:55am UTC](https://discourse.processing.org/t/drag-and-drop-random-behaviour/20419 "2020-05-04T10:55:52Z")

</div>

I’m following this example which seems to work very well. I’m trying to rewrite it using classes, as I need to have several draggable objects in my project (I’m creating an image tagging tool for a computer vision proje…

---

## [Image resize animation and duplication using squareroot size](https://discourse.processing.org/t/image-resize-animation-and-duplication-using-squareroot-size/20438)

<div class="topic-metadata">

**Author:** [@cuvner](https://discourse.processing.org/u/cuvner)\
**Replies:** 13\
**Last updated:** [May 3, 2020, 5:58pm UTC](https://discourse.processing.org/t/image-resize-animation-and-duplication-using-squareroot-size/20438 "2020-05-03T17:58:48Z")

</div>

Hi, I want to create an animation with images where the image divides by inverse square and more images loaded. Anyone done something like this? Any help much appreciated, even a starting point. Chris

---

## [How to make the hour and minute hands rotate according to the real time](https://discourse.processing.org/t/how-to-make-the-hour-and-minute-hands-rotate-according-to-the-real-time/19994)

<div class="topic-metadata">

**Author:** [@Gravic216](https://discourse.processing.org/u/Gravic216)\
**Replies:** 3\
**Last updated:** [May 3, 2020, 5:17pm UTC](https://discourse.processing.org/t/how-to-make-the-hour-and-minute-hands-rotate-according-to-the-real-time/19994 "2020-05-03T17:17:30Z")

</div>

How to make the hour and minute hands rotate according to the real time, I refer to the example of the clock provided on the website （ https://p5js.org/zh-Hans/examples/input-clock.html ） When I brought the code into it …

---

## [Game of life code error](https://discourse.processing.org/t/game-of-life-code-error/20238)

<div class="topic-metadata">

**Author:** [@pallavi24](https://discourse.processing.org/u/pallavi24)\
**Replies:** 4\
**Last updated:** [May 2, 2020, 2:40pm UTC](https://discourse.processing.org/t/game-of-life-code-error/20238 "2020-05-02T14:40:29Z")

</div>

I m trying to make the game of life on p5.js. I have used a 2d array of CA class object called ‘cell’ and saving every iteration in ‘new\_cell’ and finally copying back the values from ‘new \_cell’ to ‘cell’. The code work…

---

## [loadImage() fails to load image served on reverse proxy (Safari/iOS)](https://discourse.processing.org/t/loadimage-fails-to-load-image-served-on-reverse-proxy-safari-ios/20240)

<div class="topic-metadata">

**Author:** [@dfd0226](https://discourse.processing.org/u/dfd0226)\
**Replies:** 6\
**Last updated:** [May 1, 2020, 6:40pm UTC](https://discourse.processing.org/t/loadimage-fails-to-load-image-served-on-reverse-proxy-safari-ios/20240 "2020-05-01T18:40:57Z")

</div>

p5.js version: 0.10.2 Web browser and version: Safari: Version 13.1 (15609.1.20.111.8) Operating System: macOS 10.15.4 Steps to reproduce this: I’ve built an application that creates simulations of chemical systems inc…

---

## [I want a google spread sheets using p5!](https://discourse.processing.org/t/i-want-a-google-spread-sheets-using-p5/2632)

<div class="topic-metadata">

**Author:** [@fankimm](https://discourse.processing.org/u/fankimm)\
**Replies:** 6\
**Last updated:** [May 1, 2020, 5:42pm UTC](https://discourse.processing.org/t/i-want-a-google-spread-sheets-using-p5/2632 "2020-05-01T17:42:31Z")

</div>

I have a Google Spreadsheet with full access. And I want to add new content to the Google Spreadsheet using p5js. Can I…? What should I do?

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

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