# Coding Questions

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

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

**Page:** 22

---

## [Maximum call stack size exceeded error with merge sort function](https://discourse.processing.org/t/maximum-call-stack-size-exceeded-error-with-merge-sort-function/28913)

<div class="topic-metadata">

**Author:** [@michaelberge](https://discourse.processing.org/u/michaelberge)\
**Replies:** 5\
**Last updated:** [March 29, 2021, 5:13am UTC](https://discourse.processing.org/t/maximum-call-stack-size-exceeded-error-with-merge-sort-function/28913 "2021-03-29T05:13:34Z")

</div>

Here is the function, it calls ‘Uncaught RangeError: Maximum call stack size exceeded’ when run, I’m not sure why this is happening. I’m thinking somewhere it’s getting caught in an infinite loop: function mergeSort(val…

---

## [Show video in each element with a specific css class](https://discourse.processing.org/t/show-video-in-each-element-with-a-specific-css-class/28702)

<div class="topic-metadata">

**Author:** [@hilkeros](https://discourse.processing.org/u/hilkeros)\
**Replies:** 5\
**Last updated:** [March 27, 2021, 1:40pm UTC](https://discourse.processing.org/t/show-video-in-each-element-with-a-specific-css-class/28702 "2021-03-27T13:40:24Z")

</div>

I am looking for a way to show the same video in each div with a specific class and looked at different approaches, but I didn’t find a solution. It is not possible to pass a p5.Image as the content of a createDiv functi…

---

## [Performance improvement on a halftone grid particle system](https://discourse.processing.org/t/performance-improvement-on-a-halftone-grid-particle-system/28892)

<div class="topic-metadata">

**Author:** [@dehyde](https://discourse.processing.org/u/dehyde)\
**Replies:** 0\
**Last updated:** [March 26, 2021, 10:32pm UTC](https://discourse.processing.org/t/performance-improvement-on-a-halftone-grid-particle-system/28892 "2021-03-26T22:32:37Z")

</div>

Hi there I’m trying to create an isometric grid of dots that serves both as a halftone effect (which I have reached) and a particle system that reacts to mouse location (gravity / repel). I want the dots to react smoot…

---

## [Is there a way to draw rectangles in WebGL mode without it being affected by the camera?](https://discourse.processing.org/t/is-there-a-way-to-draw-rectangles-in-webgl-mode-without-it-being-affected-by-the-camera/28814)

<div class="topic-metadata">

**Author:** [@graph100](https://discourse.processing.org/u/graph100)\
**Replies:** 2\
**Last updated:** [March 25, 2021, 4:19pm UTC](https://discourse.processing.org/t/is-there-a-way-to-draw-rectangles-in-webgl-mode-without-it-being-affected-by-the-camera/28814 "2021-03-25T16:19:22Z")

</div>

Hi, I’ve been wondering for some time if there is a way to draw rectangles (or any 2d shape for that matter) in WebGL mode without it being affected by the camera angle. I’d like to make some kind of GUI system where the…

---

## [Checkbox switch Question Updated](https://discourse.processing.org/t/checkbox-switch-question-updated/28826)

<div class="topic-metadata">

**Author:** [@Mem](https://discourse.processing.org/u/Mem)\
**Replies:** 0\
**Last updated:** [March 25, 2021, 9:31am UTC](https://discourse.processing.org/t/checkbox-switch-question-updated/28826 "2021-03-25T09:31:56Z")

</div>

Hi, I would like to be able to select different circle A and B with a createCheckbox() What I want is when the A is selected then we select the B, the circle A should disappear and the checkbox A must be unchecked Rig…

---

## [Checkbox background color](https://discourse.processing.org/t/checkbox-background-color/28527)

<div class="topic-metadata">

**Author:** [@xbix](https://discourse.processing.org/u/xbix)\
**Replies:** 2\
**Last updated:** [March 25, 2021, 9:26am UTC](https://discourse.processing.org/t/checkbox-background-color/28527 "2021-03-25T09:26:36Z")

</div>

I’m trying to change the background color of a checkbox. in css I have tried: input\[type="checkbox"\] { position: relative; appearance: none; background-color: #2ecc71; color: #49400c; } this does not work. And…

---

## [deviceId constraint ignored?](https://discourse.processing.org/t/deviceid-constraint-ignored/28791)

<div class="topic-metadata">

**Author:** [@\_RicH\_1](https://discourse.processing.org/u/_RicH_1)\
**Replies:** 4\
**Last updated:** [March 25, 2021, 8:24am UTC](https://discourse.processing.org/t/deviceid-constraint-ignored/28791 "2021-03-25T08:24:38Z")

</div>

Hi, I’m wanting to use mutliple camera inputs so I’m using the deviceId constraint on createCapture, but it doesnt seem to matter what I enter it will always just uses the first availalbe video source If device ID isn’…

---

## [Just a little help](https://discourse.processing.org/t/just-a-little-help/28768)

<div class="topic-metadata">

**Author:** [@cjswinter](https://discourse.processing.org/u/cjswinter)\
**Replies:** 5\
**Last updated:** [March 25, 2021, 12:07am UTC](https://discourse.processing.org/t/just-a-little-help/28768 "2021-03-25T00:07:54Z")

</div>

Hi, sorry but would someone be able to explain why this code runs fine 7 times in a row and then fails on the 8th. Nothing changes. This is almost certainly not the correct way to code this, but I am still learning. Th…

---

## [How can I limit the player's movement?](https://discourse.processing.org/t/how-can-i-limit-the-players-movement/28760)

<div class="topic-metadata">

**Author:** [@ValkerieZ](https://discourse.processing.org/u/ValkerieZ)\
**Replies:** 1\
**Last updated:** [March 24, 2021, 9:46pm UTC](https://discourse.processing.org/t/how-can-i-limit-the-players-movement/28760 "2021-03-24T21:46:24Z")

</div>

I am not sure why my code is not working. Specifically the section where i am trying to limit the players movements so he does not go out of bounds. This is an incomplete project that I’m trying to nail but i just can’t…

---

## [Display square image as circle image](https://discourse.processing.org/t/display-square-image-as-circle-image/28735)

<div class="topic-metadata">

**Author:** [@Bas950](https://discourse.processing.org/u/Bas950)\
**Replies:** 1\
**Last updated:** [March 22, 2021, 5:49pm UTC](https://discourse.processing.org/t/display-square-image-as-circle-image/28735 "2021-03-22T17:49:41Z")

</div>

So I load a square image, but I want it displayed as a circle image, how could I do this easily? (like just cut of the corners with transparency, width stay the same but just rounded)

---

## [Issues with overwriting](https://discourse.processing.org/t/issues-with-overwriting/28650)

<div class="topic-metadata">

**Author:** [@quargsgreene](https://discourse.processing.org/u/quargsgreene)\
**Replies:** 2\
**Last updated:** [March 19, 2021, 9:08pm UTC](https://discourse.processing.org/t/issues-with-overwriting/28650 "2021-03-19T21:08:58Z")

</div>

I am trying to have multiple same-size rectangular panels of differing colors appear on the canvas. However, each panel is appearing the same color. Each color is stored in an array declared globally and each element the…

---

## [createShader() not working on p5.Graphics](https://discourse.processing.org/t/createshader-not-working-on-p5-graphics/28617)

<div class="topic-metadata">

**Author:** [@duskvirkus](https://discourse.processing.org/u/duskvirkus)\
**Replies:** 4\
**Last updated:** [March 17, 2021, 11:19pm UTC](https://discourse.processing.org/t/createshader-not-working-on-p5-graphics/28617 "2021-03-17T23:19:07Z")

</div>

Not sure if this is a bug but when I try to use createShader() instead of loadShader() it doesn’t work on a p5.Graphics object. Figured I’d post here before creating an issue in case I’m doing something wrong. Below is…

---

## [How to align an ellipse to an arc that is mapped to time/hours? (Creating a sundial clock)](https://discourse.processing.org/t/how-to-align-an-ellipse-to-an-arc-that-is-mapped-to-time-hours-creating-a-sundial-clock/28596)

<div class="topic-metadata">

**Author:** [@keira](https://discourse.processing.org/u/keira)\
**Replies:** 2\
**Last updated:** [March 17, 2021, 9:43am UTC](https://discourse.processing.org/t/how-to-align-an-ellipse-to-an-arc-that-is-mapped-to-time-hours-creating-a-sundial-clock/28596 "2021-03-17T09:43:26Z")

</div>

Hello! I’m trying to create a clock inspired by sundials. I have created an arc that is mapped to the current hour and an ellipse. I want the ellipse to line up with the end of the arc so that when the hour changes it mo…

---

## [P5.js to Processing - How did I do? Are there better/more efficient methods?](https://discourse.processing.org/t/p5-js-to-processing-how-did-i-do-are-there-better-more-efficient-methods/28594)

<div class="topic-metadata">

**Author:** [@leatherbird](https://discourse.processing.org/u/leatherbird)\
**Replies:** 2\
**Last updated:** [March 17, 2021, 2:50am UTC](https://discourse.processing.org/t/p5-js-to-processing-how-did-i-do-are-there-better-more-efficient-methods/28594 "2021-03-17T02:50:28Z")

</div>

Hello! I found this tutorial video online for creating Sine wave structures in p5.js I don’t really know p5 very well, but I thought I would follow along, and try to do everything in the video with Processing instead. …

---

## [Model Rotation: Automatic & Mouse Mapped Issue](https://discourse.processing.org/t/model-rotation-automatic-mouse-mapped-issue/28561)

<div class="topic-metadata">

**Author:** [@cob](https://discourse.processing.org/u/cob)\
**Replies:** 1\
**Last updated:** [March 16, 2021, 11:09pm UTC](https://discourse.processing.org/t/model-rotation-automatic-mouse-mapped-issue/28561 "2021-03-16T23:09:38Z")

</div>

Hello, I’m creating an interactive animation for a friend which moves a model with mouseX & mouseY as well as has automatic movement if the cursor is off the canvas. However when off the canvas, there is no continuity be…

---

## [Moving the circle in the direction of another circle revolving around it in canvas](https://discourse.processing.org/t/moving-the-circle-in-the-direction-of-another-circle-revolving-around-it-in-canvas/28569)

<div class="topic-metadata">

**Author:** [@harsha](https://discourse.processing.org/u/harsha)\
**Replies:** 2\
**Last updated:** [March 16, 2021, 1:38pm UTC](https://discourse.processing.org/t/moving-the-circle-in-the-direction-of-another-circle-revolving-around-it-in-canvas/28569 "2021-03-16T13:38:07Z")

</div>

I have a problem of moving the big circle in the direction of small circle when a button is pressed. can anyone help? Goals: Make a circle on canvas \[Done\] Draw a small circle that rotates around the big circle \[Done\] …

---

## [How to control saved image resolution? // get() and save()](https://discourse.processing.org/t/how-to-control-saved-image-resolution-get-and-save/28550)

<div class="topic-metadata">

**Author:** [@tobo](https://discourse.processing.org/u/tobo)\
**Replies:** 4\
**Last updated:** [March 15, 2021, 8:37pm UTC](https://discourse.processing.org/t/how-to-control-saved-image-resolution-get-and-save/28550 "2021-03-15T20:37:45Z")

</div>

I’m trying to save a single image frame from a p5 webgl canvas to a variable. I used the second line of code below just to see the image for myself, as a reference. I noticed that the image it produces is exactly my defi…

---

## [Checkbox listener index](https://discourse.processing.org/t/checkbox-listener-index/28529)

<div class="topic-metadata">

**Author:** [@xbix](https://discourse.processing.org/u/xbix)\
**Replies:** 6\
**Last updated:** [March 15, 2021, 5:12pm UTC](https://discourse.processing.org/t/checkbox-listener-index/28529 "2021-03-15T17:12:14Z")

</div>

I have an array of checkboxes and I need to know which checkbox was pressed. My code looks like this: uiToogles() { var y = 0; checkbox = \[8\]; for (var x = 0; x \< 8; x++) { y = x \* 20; checkbox\[x…

---

## [Open a new tab by clicking on img with mousePressed?](https://discourse.processing.org/t/open-a-new-tab-by-clicking-on-img-with-mousepressed/27106)

<div class="topic-metadata">

**Author:** [@moedigs](https://discourse.processing.org/u/moedigs)\
**Replies:** 6\
**Last updated:** [March 10, 2021, 5:11pm UTC](https://discourse.processing.org/t/open-a-new-tab-by-clicking-on-img-with-mousepressed/27106 "2021-03-10T17:11:37Z")

</div>

I’m attempting to load an img, and open a new tab/website with mousePressed when someone clicks on the img or within the space of the Canvas. It’s on a page with multiple sketches So I want to restrict the activated a…

---

## [Customise Checkbox](https://discourse.processing.org/t/customise-checkbox/28384)

<div class="topic-metadata">

**Author:** [@xbix](https://discourse.processing.org/u/xbix)\
**Replies:** 1\
**Last updated:** [March 10, 2021, 12:32pm UTC](https://discourse.processing.org/t/customise-checkbox/28384 "2021-03-10T12:32:05Z")

</div>

I need a slightly different checkbox like the one from the standard library. Instead of a check, I need a smooth background and custom background colors. What options do I have here? Can I extend the class or are ther…

---

## [Full Screen with Hidings sliders](https://discourse.processing.org/t/full-screen-with-hidings-sliders/28249)

<div class="topic-metadata">

**Author:** [@Mem](https://discourse.processing.org/u/Mem)\
**Replies:** 2\
**Last updated:** [March 8, 2021, 6:08pm UTC](https://discourse.processing.org/t/full-screen-with-hidings-sliders/28249 "2021-03-08T18:08:16Z")

</div>

Hello, I would like to use the function full screen fullscreen(); Using sliders, checkboxs, inputs and buttons that will disappear when we are in a full screen mode. So basically I can work with sliders and then go f…

---

## [Checkbox switch](https://discourse.processing.org/t/checkbox-switch/28334)

<div class="topic-metadata">

**Author:** [@Mem](https://discourse.processing.org/u/Mem)\
**Replies:** 0\
**Last updated:** [March 8, 2021, 10:47am UTC](https://discourse.processing.org/t/checkbox-switch/28334 "2021-03-08T10:47:50Z")

</div>

Hi, I would like to be able to select different circle A,B When the A is selected and we select the B, the circle A should disappear and the checkbox A must be unchecked Here is the exemple : Thank you var checkbox\_…

---

## [P5.js onCanvasCreated?](https://discourse.processing.org/t/p5-js-oncanvascreated/28316)

<div class="topic-metadata">

**Author:** [@yy23432](https://discourse.processing.org/u/yy23432)\
**Replies:** 1\
**Last updated:** [March 7, 2021, 5:59pm UTC](https://discourse.processing.org/t/p5-js-oncanvascreated/28316 "2021-03-07T17:59:26Z")

</div>

Hi, I’m trying to use p5.js as a GUI part. Trying to do like… function createP5GUI() { let f = function(p) { p.setup = function() { let c = p.createCanvas(500, 50); } } return new p5(f); } and use it in DOM …

---

## [Pan and zoom large panorama image](https://discourse.processing.org/t/pan-and-zoom-large-panorama-image/28076)

<div class="topic-metadata">

**Author:** [@petemanzel](https://discourse.processing.org/u/petemanzel)\
**Replies:** 9\
**Last updated:** [March 5, 2021, 9:20am UTC](https://discourse.processing.org/t/pan-and-zoom-large-panorama-image/28076 "2021-03-05T09:20:59Z")

</div>

Hi, i have an panorama-image with the size of 2048x179121px. I would like to pan through the image using a rotary encoder and zoom in using a touchscreen. The encoder/arduino part is working fine but if i try to load th…

---

## [How to get the position of the point directly in front of the camera？](https://discourse.processing.org/t/how-to-get-the-position-of-the-point-directly-in-front-of-the-camera/28042)

<div class="topic-metadata">

**Author:** [@AbleYudada](https://discourse.processing.org/u/AbleYudada)\
**Replies:** 5\
**Last updated:** [March 5, 2021, 4:44am UTC](https://discourse.processing.org/t/how-to-get-the-position-of-the-point-directly-in-front-of-the-camera/28042 "2021-03-05T04:44:08Z")

</div>

Hello everyone! I want to put a box in front of a mobile camera, but no matter how I try, I can’t get it

---

## [Neural Network genetic algorithm game](https://discourse.processing.org/t/neural-network-genetic-algorithm-game/28146)

<div class="topic-metadata">

**Author:** [@Farbod](https://discourse.processing.org/u/Farbod)\
**Replies:** 6\
**Last updated:** [March 3, 2021, 4:01pm UTC](https://discourse.processing.org/t/neural-network-genetic-algorithm-game/28146 "2021-03-03T16:01:50Z")

</div>

I am trying to train a neural network to be able to shoot a bubble accurately. My solution is to have a brain inside the “arrow” and make it determine the shooting “angle” based on the scores it receives. I have followed…

---

## [Shader question!](https://discourse.processing.org/t/shader-question/28164)

<div class="topic-metadata">

**Author:** [@carfreesun](https://discourse.processing.org/u/carfreesun)\
**Replies:** 1\
**Last updated:** [March 1, 2021, 4:43pm UTC](https://discourse.processing.org/t/shader-question/28164 "2021-03-01T16:43:55Z")

</div>

hello everyone, i’m curious about shader language. so i write this question! When I want to use the ‘ease’ function, why do I have to use another function instead of just putting a variable in parameter t? for example, …

---

## [Create p5.js Instances Sequentially in For Loop But Only After the Previous One Finishes](https://discourse.processing.org/t/create-p5-js-instances-sequentially-in-for-loop-but-only-after-the-previous-one-finishes/28050)

<div class="topic-metadata">

**Author:** [@nguzman](https://discourse.processing.org/u/nguzman)\
**Replies:** 3\
**Last updated:** [February 25, 2021, 10:07pm UTC](https://discourse.processing.org/t/create-p5-js-instances-sequentially-in-for-loop-but-only-after-the-previous-one-finishes/28050 "2021-02-25T22:07:31Z")

</div>

The basic question is in the title. I use a function to define a p5.js instance with a particular set of parameters. The sketch itself runs an in-browser video game. When any one out of a set of events occurs in the game…

---

## [For loop driven by event crashes](https://discourse.processing.org/t/for-loop-driven-by-event-crashes/28065)

<div class="topic-metadata">

**Author:** [@cmoredock](https://discourse.processing.org/u/cmoredock)\
**Replies:** 4\
**Last updated:** [February 25, 2021, 7:56pm UTC](https://discourse.processing.org/t/for-loop-driven-by-event-crashes/28065 "2021-02-25T19:56:11Z")

</div>

https://editor.p5js.org/cmoredock@rdschool.org/sketches/obDjqJJfM let lt = input1.value(); let st = input2.value(); let tt = input3.value(); // why does this infinite loop? for (let i = st; i \< lt; i = i + tt) …

---

## [Print CSV not working](https://discourse.processing.org/t/print-csv-not-working/28045)

<div class="topic-metadata">

**Author:** [@xbix](https://discourse.processing.org/u/xbix)\
**Replies:** 2\
**Last updated:** [February 24, 2021, 3:57pm UTC](https://discourse.processing.org/t/print-csv-not-working/28045 "2021-02-24T15:57:11Z")

</div>

I am trying to load a CSV file and print the contents. The file loads and I get the filename, but the rows and columns are not passed. Here is my code: "use strict"; let i, k, trows, tcols; let table, loadButton; fun…

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

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