# Coding Questions

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

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

**Page:** 44

---

## [Mandelbrot set coding challenge](https://discourse.processing.org/t/mandelbrot-set-coding-challenge/11162)

<div class="topic-metadata">

**Author:** [@FractalGenieGod](https://discourse.processing.org/u/FractalGenieGod)\
**Replies:** 13\
**Last updated:** [May 12, 2019, 12:04pm UTC](https://discourse.processing.org/t/mandelbrot-set-coding-challenge/11162 "2019-05-12T12:04:46Z")

</div>

Coding Challenge #21: Mandelbrot Set. Youtube. @\[14:29\] (https://www.youtube.com/watch?v=6z7GQewK-Ks&t=869s) Can someone help me please @\[14:29\] when we are going to test to see if it’s all working I keep getting this s…

---

## [Making a Class; web editor vs local](https://discourse.processing.org/t/making-a-class-web-editor-vs-local/11014)

<div class="topic-metadata">

**Author:** [@Rolembeek](https://discourse.processing.org/u/Rolembeek)\
**Replies:** 6\
**Last updated:** [May 9, 2019, 10:38pm UTC](https://discourse.processing.org/t/making-a-class-web-editor-vs-local/11014 "2019-05-09T22:38:46Z")

</div>

As an exercise in making classes in p5.js, I used a piece of code from Dan Shiffman (2D Ray Casting …). Something strange happens : when I use the code -\> class Boundary{ constructor(x1, y1, x2, y2) { this.a =cre…

---

## [Making a Spheroid](https://discourse.processing.org/t/making-a-spheroid/11069)

<div class="topic-metadata">

**Author:** [@Avatrin](https://discourse.processing.org/u/Avatrin)\
**Replies:** 2\
**Last updated:** [May 9, 2019, 4:25pm UTC](https://discourse.processing.org/t/making-a-spheroid/11069 "2019-05-09T16:25:52Z")

</div>

Hi How can I go about creating a spheroid in Processing? I need it to be a solid color.

---

## [Variable font in processing](https://discourse.processing.org/t/variable-font-in-processing/11060)

<div class="topic-metadata">

**Author:** [@smekis](https://discourse.processing.org/u/smekis)\
**Replies:** 0\
**Last updated:** [May 9, 2019, 11:12am UTC](https://discourse.processing.org/t/variable-font-in-processing/11060 "2019-05-09T11:12:27Z")

</div>

I have created a variable font that I want to be able to present via processing. Is there a function where I can do this in processing? Found this forum post: Controlling CSS values with mouse in p5.js With this type o…

---

## [Flappy Bird pipe generate](https://discourse.processing.org/t/flappy-bird-pipe-generate/11059)

<div class="topic-metadata">

**Author:** [@totolepeco](https://discourse.processing.org/u/totolepeco)\
**Replies:** 1\
**Last updated:** [May 9, 2019, 10:12am UTC](https://discourse.processing.org/t/flappy-bird-pipe-generate/11059 "2019-05-09T10:12:07Z")

</div>

Hello, I’m young French student, and for my scientific secondary school diploma, I must making a little game. I have choosen so to make a Flappy Bird. I successfully to make the random pipe, but I would like to generat …

---

## [How to put data in a table after extraxting it from a JSON file on the runtime in p5.js](https://discourse.processing.org/t/how-to-put-data-in-a-table-after-extraxting-it-from-a-json-file-on-the-runtime-in-p5-js/11054)

<div class="topic-metadata">

**Author:** [@Procoder](https://discourse.processing.org/u/Procoder)\
**Replies:** 1\
**Last updated:** [May 9, 2019, 8:05am UTC](https://discourse.processing.org/t/how-to-put-data-in-a-table-after-extraxting-it-from-a-json-file-on-the-runtime-in-p5-js/11054 "2019-05-09T08:05:41Z")

</div>

If i have a DOM table element how can I insert data in it dynamically during the runtime as its extracted from a JSON file

---

## [Translating sketch from P5 to Java](https://discourse.processing.org/t/translating-sketch-from-p5-to-java/10052)

<div class="topic-metadata">

**Author:** [@PixelMx](https://discourse.processing.org/u/PixelMx)\
**Replies:** 2\
**Last updated:** [May 9, 2019, 4:32am UTC](https://discourse.processing.org/t/translating-sketch-from-p5-to-java/10052 "2019-05-09T04:32:17Z")

</div>

I was beginning to start programming with Processing (Java) but now I see most sketches created in P5. I like Java better because it allows me to export frames to png files and create animations from there. I’m not fam…

---

## [Adding array to array list](https://discourse.processing.org/t/adding-array-to-array-list/11006)

<div class="topic-metadata">

**Author:** [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Replies:** 8\
**Last updated:** [May 8, 2019, 3:52pm UTC](https://discourse.processing.org/t/adding-array-to-array-list/11006 "2019-05-08T15:52:35Z")

</div>

So Im new to processing and I’m trying to port p5 code. This is the original p5 code this.init = function(){ var theta = 360/sides; for (var i=0;i\<sides;i++){ var thetab = theta \* i; …

---

## [Assign a variable from draw function to setup function](https://discourse.processing.org/t/assign-a-variable-from-draw-function-to-setup-function/11022)

<div class="topic-metadata">

**Author:** [@l3ehfar](https://discourse.processing.org/u/l3ehfar)\
**Replies:** 2\
**Last updated:** [May 8, 2019, 8:53am UTC](https://discourse.processing.org/t/assign-a-variable-from-draw-function-to-setup-function/11022 "2019-05-08T08:53:04Z")

</div>

I just wanted to assign mouseX value to one of my parameters value in setup function. how should I assign something that needs to run continuously in setup function? morphDo(){ for (let a = startA; a \< 360; a += spa…

---

## [Mutual attraction of objects](https://discourse.processing.org/t/mutual-attraction-of-objects/10985)

<div class="topic-metadata">

**Author:** [@Capt.Sloth](https://discourse.processing.org/u/Capt.Sloth)\
**Replies:** 4\
**Last updated:** [May 7, 2019, 5:13am UTC](https://discourse.processing.org/t/mutual-attraction-of-objects/10985 "2019-05-07T05:13:04Z")

</div>

Hello, I am trying to take a different approach and use functions instead of classes to recreate the mutual attraction sketch from Nature of code (ch2.08 to be specific).I have taken a different approach,I am confident …

---

## [Different filters to one image](https://discourse.processing.org/t/different-filters-to-one-image/10981)

<div class="topic-metadata">

**Author:** [@arixha](https://discourse.processing.org/u/arixha)\
**Replies:** 1\
**Last updated:** [May 6, 2019, 9:40pm UTC](https://discourse.processing.org/t/different-filters-to-one-image/10981 "2019-05-06T21:40:32Z")

</div>

Hi, I’m preloading an image and I’m loading it every 10 seconds in a different position of the canvas. I want to apply to my image a new different filter every time I load it (to the image only, not to all the canvas). …

---

## [2d raycast porting issue (P5\>P3)](https://discourse.processing.org/t/2d-raycast-porting-issue-p5-p3/10940)

<div class="topic-metadata">

**Author:** [@TTG](https://discourse.processing.org/u/TTG)\
**Replies:** 4\
**Last updated:** [May 6, 2019, 2:15pm UTC](https://discourse.processing.org/t/2d-raycast-porting-issue-p5-p3/10940 "2019-05-06T14:15:02Z")

</div>

Hi team. I could use some help regarding an issue I experience. Daniel S. did a raycast tutorial in P5 ( https://www.youtube.com/watch?v=-6iIc6-Y-kk ) I am doing the same though in P3. it goes correct until at in P…

---

## [Need help with fill() on Bezier](https://discourse.processing.org/t/need-help-with-fill-on-bezier/10603)

<div class="topic-metadata">

**Author:** [@Sudev](https://discourse.processing.org/u/Sudev)\
**Replies:** 14\
**Last updated:** [May 5, 2019, 12:14pm UTC](https://discourse.processing.org/t/need-help-with-fill-on-bezier/10603 "2019-05-05T12:14:43Z")

</div>

For some reason/s, am unable to set fill to my Bezier (3D). Here’s my code : let p0 = createVector(0, 20, 0); let p1 = createVector(0, 0, 40); let p2 = createVector(0, -60, 0); let p3 = createVector(0, 0, -40); …

---

## [Mapping every value of an array to a color spectrum](https://discourse.processing.org/t/mapping-every-value-of-an-array-to-a-color-spectrum/10868)

<div class="topic-metadata">

**Author:** [@lavina](https://discourse.processing.org/u/lavina)\
**Replies:** 5\
**Last updated:** [May 4, 2019, 9:32pm UTC](https://discourse.processing.org/t/mapping-every-value-of-an-array-to-a-color-spectrum/10868 "2019-05-04T21:32:03Z")

</div>

I have an array called numbers of incrementing values from 0 to n. I want to create an array of colors so that each value in numbers has its own color, and then later draw a line for each element in numbers, with the cor…

---

## [Find multiple arc edge?](https://discourse.processing.org/t/find-multiple-arc-edge/10847)

<div class="topic-metadata">

**Author:** [@pastuh](https://discourse.processing.org/u/pastuh)\
**Replies:** 9\
**Last updated:** [May 4, 2019, 6:07pm UTC](https://discourse.processing.org/t/find-multiple-arc-edge/10847 "2019-05-04T18:07:37Z")

</div>

Hello. I can’t understand how i can find arc() edge. Currently i control White line with mouse. And goal is to change that line to Red, if mouse is outside Yellow zone. I draw multiple arcs (on top of each) and real s…

---

## [2D perlin with smooth transition](https://discourse.processing.org/t/2d-perlin-with-smooth-transition/10897)

<div class="topic-metadata">

**Author:** [@Capt.Sloth](https://discourse.processing.org/u/Capt.Sloth)\
**Replies:** 8\
**Last updated:** [May 4, 2019, 9:43am UTC](https://discourse.processing.org/t/2d-perlin-with-smooth-transition/10897 "2019-05-04T09:43:21Z")

</div>

Simple project to understand Perlin noise better, I plan to have each cell have a certain grey-scale value with the help of perlin noise which I managed to attain in 2D. Now i would also like to add the z offset to the n…

---

## [Rotated polygons with collision detection](https://discourse.processing.org/t/rotated-polygons-with-collision-detection/10755)

<div class="topic-metadata">

**Author:** [@JoeM](https://discourse.processing.org/u/JoeM)\
**Replies:** 9\
**Last updated:** [May 3, 2019, 1:36pm UTC](https://discourse.processing.org/t/rotated-polygons-with-collision-detection/10755 "2019-05-03T13:36:59Z")

</div>

How can i detect the collision between two polygons with different rotations? i use the p5.collide2d Lib, but it don´t know how to apply rotation to it.

---

## [Creating a shape using vertices of different color](https://discourse.processing.org/t/creating-a-shape-using-vertices-of-different-color/10842)

<div class="topic-metadata">

**Author:** [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Replies:** 2\
**Last updated:** [May 3, 2019, 4:17am UTC](https://discourse.processing.org/t/creating-a-shape-using-vertices-of-different-color/10842 "2019-05-03T04:17:59Z")

</div>

Hi, so a little while ago I attempted Dan Shiffman’s code to make my own maze. It was a really nice maze, where lines where drawn top right bottom left to make a square grid of squares, and you could call one of the line…

---

## [Sharing a p5 sketch that has an array of images](https://discourse.processing.org/t/sharing-a-p5-sketch-that-has-an-array-of-images/10821)

<div class="topic-metadata">

**Author:** [@am\_i\_functional](https://discourse.processing.org/u/am_i_functional)\
**Replies:** 12\
**Last updated:** [May 2, 2019, 6:56pm UTC](https://discourse.processing.org/t/sharing-a-p5-sketch-that-has-an-array-of-images/10821 "2019-05-02T18:56:44Z")

</div>

My sketch which is just basically coding challenge 5 works great in the web editor. I used some of my own art in it and it works fine with my art. When i try to share online it has a problem. i saw in inspect element a …

---

## [Click event on two shape](https://discourse.processing.org/t/click-event-on-two-shape/10613)

<div class="topic-metadata">

**Author:** [@clingonboy](https://discourse.processing.org/u/clingonboy)\
**Replies:** 6\
**Last updated:** [May 2, 2019, 1:36pm UTC](https://discourse.processing.org/t/click-event-on-two-shape/10613 "2019-05-02T13:36:56Z")

</div>

If I have two rect one over enother, partially, if a click in the common area, how can I select the last above rectangle? like in this example: https://editor.p5js.org/Clingonboy/sketches/ja\_VJNrg4 Have I do andle mys…

---

## [How to project/map from cartesian space to circular space](https://discourse.processing.org/t/how-to-project-map-from-cartesian-space-to-circular-space/10640)

<div class="topic-metadata">

**Author:** [@blkpanther](https://discourse.processing.org/u/blkpanther)\
**Replies:** 2\
**Last updated:** [April 29, 2019, 9:02pm UTC](https://discourse.processing.org/t/how-to-project-map-from-cartesian-space-to-circular-space/10640 "2019-04-29T21:02:47Z")

</div>

Hi, I want to project or map points of specific locations to be within the confine of a circular space (not removing points). Considering map() function does mapping on 1 dimension, how can I do so to take into accounts …

---

## [Genetic Algorithm Is Not Learning](https://discourse.processing.org/t/genetic-algorithm-is-not-learning/10674)

<div class="topic-metadata">

**Author:** [@OrangeC7](https://discourse.processing.org/u/OrangeC7)\
**Replies:** 6\
**Last updated:** [April 29, 2019, 6:36pm UTC](https://discourse.processing.org/t/genetic-algorithm-is-not-learning/10674 "2019-04-29T18:36:26Z")

</div>

I’m trying to get a “player”/circle to avoid getting hit by “obstacles”/other circles, based on Daniel Shiffman’s Neuroevolution Flappy Bird/with tensorflow.js. (https://youtu.be/c6y21FkaUqw) The algorithm has the follo…

---

## [Randomly arrange imported shapes on canvas](https://discourse.processing.org/t/randomly-arrange-imported-shapes-on-canvas/10667)

<div class="topic-metadata">

**Author:** [@annab](https://discourse.processing.org/u/annab)\
**Replies:** 7\
**Last updated:** [April 29, 2019, 8:04am UTC](https://discourse.processing.org/t/randomly-arrange-imported-shapes-on-canvas/10667 "2019-04-29T08:04:36Z")

</div>

Hi, I am completely new to processing and need to solve a problem. I am trying to write a simple code to allow me to arrange imported shapes randomly scattered on the canvas. I have found the tutorial for circle packing…

---

## [Call Backs in Preload();](https://discourse.processing.org/t/call-backs-in-preload/10711)

<div class="topic-metadata">

**Author:** [@peachman](https://discourse.processing.org/u/peachman)\
**Replies:** 5\
**Last updated:** [April 29, 2019, 2:28am UTC](https://discourse.processing.org/t/call-backs-in-preload/10711 "2019-04-29T02:28:08Z")

</div>

Hi Again, Something I might be miss understanding here, but here goes. The code below doesn’t run how my mind thinks it should. The call back function is being called twice (proved by the print statement) however it is…

---

## [Possible to stop webcam after using createCapture?](https://discourse.processing.org/t/possible-to-stop-webcam-after-using-createcapture/10557)

<div class="topic-metadata">

**Author:** [@computershawn](https://discourse.processing.org/u/computershawn)\
**Replies:** 4\
**Last updated:** [April 28, 2019, 7:08am UTC](https://discourse.processing.org/t/possible-to-stop-webcam-after-using-createcapture/10557 "2019-04-28T07:08:09Z")

</div>

Is there a way to stop my webcam from recording after I’ve started it using capture = createCapture?

---

## [Accessing Json object](https://discourse.processing.org/t/accessing-json-object/10659)

<div class="topic-metadata">

**Author:** [@Honkitonkie](https://discourse.processing.org/u/Honkitonkie)\
**Replies:** 4\
**Last updated:** [April 26, 2019, 1:40pm UTC](https://discourse.processing.org/t/accessing-json-object/10659 "2019-04-26T13:40:44Z")

</div>

Hi all, I recently started a project where i want to do some aninmations with weather data. However i got stuck rather quickly and can’t seem to acces my JSON. I looked everywhere and tried a lot but the answer still e…

---

## [Code organization](https://discourse.processing.org/t/code-organization/10643)

<div class="topic-metadata">

**Author:** [@jarlook](https://discourse.processing.org/u/jarlook)\
**Replies:** 11\
**Last updated:** [April 26, 2019, 4:30am UTC](https://discourse.processing.org/t/code-organization/10643 "2019-04-26T04:30:46Z")

</div>

I am about to convert a lengthy Processing sketch to p5.js. Currently the code is defined in several files (a common driver, some objects/classes, etc) and I’d like to keep them separate. This was doable with the Proce…

---

## [Can I have multiple independent random number generators with different seeds?](https://discourse.processing.org/t/can-i-have-multiple-independent-random-number-generators-with-different-seeds/10125)

<div class="topic-metadata">

**Author:** [@neel](https://discourse.processing.org/u/neel)\
**Replies:** 10\
**Last updated:** [April 25, 2019, 8:44pm UTC](https://discourse.processing.org/t/can-i-have-multiple-independent-random-number-generators-with-different-seeds/10125 "2019-04-25T20:44:49Z")

</div>

I’m hoping to use multiple random number generators so that I can have different random processes that don’t interfere with each other and can be seeded for some amount of consistency. Is this possible with p5.js?

---

## [Converting code from processing to p5.js (bouncing balls)](https://discourse.processing.org/t/converting-code-from-processing-to-p5-js-bouncing-balls/10612)

<div class="topic-metadata">

**Author:** [@keshavv\_123](https://discourse.processing.org/u/keshavv_123)\
**Replies:** 11\
**Last updated:** [April 25, 2019, 7:43am UTC](https://discourse.processing.org/t/converting-code-from-processing-to-p5-js-bouncing-balls/10612 "2019-04-25T07:43:22Z")

</div>

I changed a example from processing to p5.js but some part of it did’nt change from me. I’m need your help to convert them. This is the part of the code that I want to convert them in to p5.js. for (let i = balls.le…

---

## [How to control 3D using 2D input elements?](https://discourse.processing.org/t/how-to-control-3d-using-2d-input-elements/10573)

<div class="topic-metadata">

**Author:** [@Oliver](https://discourse.processing.org/u/Oliver)\
**Replies:** 1\
**Last updated:** [April 23, 2019, 6:17pm UTC](https://discourse.processing.org/t/how-to-control-3d-using-2d-input-elements/10573 "2019-04-23T18:17:27Z")

</div>

Hello all! I’m writing a program for visualising data in 3D (using WEBGL) and I would like to control some parameters in the scene with 2D elements like sliders, buttons and text fields. Is there any way one can combine …

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

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