# Coding Questions

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

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

**Page:** 5

---

## [Is multi-canvas production possible? (In Processing p5 Mode)](https://discourse.processing.org/t/is-multi-canvas-production-possible-in-processing-p5-mode/41642)

<div class="topic-metadata">

**Author:** [@GWAK](https://discourse.processing.org/u/GWAK)\
**Replies:** 10\
**Last updated:** [July 27, 2023, 1:58am UTC](https://discourse.processing.org/t/is-multi-canvas-production-possible-in-processing-p5-mode/41642 "2023-07-27T01:58:40Z")

</div>

hello. nice to meet you. Is multi-canvas production possible? (In Processing p5 Mode) As you can see from the picture, the position of the canvas is also determined, and the size (size) is determined and placed. Is…

---

## [How to store a web font into variable? How to reference to the web font imported as css @font-face?](https://discourse.processing.org/t/how-to-store-a-web-font-into-variable-how-to-reference-to-the-web-font-imported-as-css-font-face/42444)

<div class="topic-metadata">

**Author:** [@WaningJupiter](https://discourse.processing.org/u/WaningJupiter)\
**Replies:** 2\
**Last updated:** [July 18, 2023, 4:39pm UTC](https://discourse.processing.org/t/how-to-store-a-web-font-into-variable-how-to-reference-to-the-web-font-imported-as-css-font-face/42444 "2023-07-18T16:39:41Z")

</div>

Hello, for some reason I want to import a font from Google Fonts as webfont to avoid using loadFont(); I insert the font link into index.html and in my style.css : @font-face {font-family : "myFont" } In sketch.js, …

---

## [Slow Drawing, trail left behind when updating rect x and y](https://discourse.processing.org/t/slow-drawing-trail-left-behind-when-updating-rect-x-and-y/42409)

<div class="topic-metadata">

**Author:** [@fools](https://discourse.processing.org/u/fools)\
**Replies:** 2\
**Last updated:** [July 13, 2023, 2:14pm UTC](https://discourse.processing.org/t/slow-drawing-trail-left-behind-when-updating-rect-x-and-y/42409 "2023-07-13T14:14:16Z")

</div>

I have just started learning javascript so my knowledge of the language isnt great. i tried to make a pacman clone in p5.js as i thought that would be a good starting project. i just implemented movement and if you can s…

---

## [Preloading Many Images in Preload](https://discourse.processing.org/t/preloading-many-images-in-preload/42372)

<div class="topic-metadata">

**Author:** [@DonaldZhu](https://discourse.processing.org/u/DonaldZhu)\
**Replies:** 1\
**Last updated:** [July 8, 2023, 5:25pm UTC](https://discourse.processing.org/t/preloading-many-images-in-preload/42372 "2023-07-08T17:25:17Z")

</div>

I was trying to preload around 200 1MB images in my local sketch with loadImage() but found p5 to be stuck in preload(). I have replicated the issue here. To note, it will stall initially in the web editor due to fetchi…

---

## [Adjusting pixel brightness value of an image](https://discourse.processing.org/t/adjusting-pixel-brightness-value-of-an-image/42343)

<div class="topic-metadata">

**Author:** [@glosoli3](https://discourse.processing.org/u/glosoli3)\
**Replies:** 6\
**Last updated:** [July 8, 2023, 10:06pm UTC](https://discourse.processing.org/t/adjusting-pixel-brightness-value-of-an-image/42343 "2023-07-08T22:06:28Z")

</div>

Ok, I’ve exhausted myself trying to adjust the brightness of pixels from a loaded image using p5.js.I’ve looked online and multiple forums with no solution. It seems like color and colorMode work very differently in p5.j…

---

## [3D model does not respond to light in instance mode](https://discourse.processing.org/t/3d-model-does-not-respond-to-light-in-instance-mode/42206)

<div class="topic-metadata">

**Author:** [@tanzor](https://discourse.processing.org/u/tanzor)\
**Replies:** 1\
**Last updated:** [June 26, 2023, 9:04am UTC](https://discourse.processing.org/t/3d-model-does-not-respond-to-light-in-instance-mode/42206 "2023-06-26T09:04:59Z")

</div>

Hi all, When I load my blender-made object into a p5.js sketch in instance mode it does not interact with the light source, but appears as a silhouette. Is this a known limitation? Is there a workaround, assuming I nee…

---

## [Moving a object with the createGraphics function without leaving a trail](https://discourse.processing.org/t/moving-a-object-with-the-creategraphics-function-without-leaving-a-trail/42230)

<div class="topic-metadata">

**Author:** [@Delain](https://discourse.processing.org/u/Delain)\
**Replies:** 4\
**Last updated:** [June 17, 2023, 12:18pm UTC](https://discourse.processing.org/t/moving-a-object-with-the-creategraphics-function-without-leaving-a-trail/42230 "2023-06-17T12:18:27Z")

</div>

My idea is making a background with the watercolor effect used by steve maker’s space on youtube. I succeeded making it into a function and put it in the setup function. Now I have a background with a nice texture I woul…

---

## [Why does my code splice to many rectangles from the array?](https://discourse.processing.org/t/why-does-my-code-splice-to-many-rectangles-from-the-array/42202)

<div class="topic-metadata">

**Author:** [@Delain](https://discourse.processing.org/u/Delain)\
**Replies:** 2\
**Last updated:** [June 13, 2023, 6:27am UTC](https://discourse.processing.org/t/why-does-my-code-splice-to-many-rectangles-from-the-array/42202 "2023-06-13T06:27:48Z")

</div>

I am trying to make the piet mondrian in p5js, kinda following this site https://generativeartistry.com/tutorials/piet-mondrian/ I keep on running into same problem over and over again and have tried different ways to …

---

## [Can someone help to check why the circles are not random color?](https://discourse.processing.org/t/can-someone-help-to-check-why-the-circles-are-not-random-color/42176)

<div class="topic-metadata">

**Author:** [@Jiuyi91](https://discourse.processing.org/u/Jiuyi91)\
**Replies:** 2\
**Last updated:** [June 10, 2023, 3:21pm UTC](https://discourse.processing.org/t/can-someone-help-to-check-why-the-circles-are-not-random-color/42176 "2023-06-10T15:21:56Z")

</div>

let r,g,b,colorFill,R; let col,canvas2; function setup() { createCanvas(windowWidth, windowHeight); canvas2=createGraphics(windowWidth, windowHeight); canvas2.clear(); } function draw() { background(col,0,160); …

---

## [Recursive function for generating permutations of \[0, ..., n\]](https://discourse.processing.org/t/recursive-function-for-generating-permutations-of-0-n/42163)

<div class="topic-metadata">

**Author:** [@jackeddielove](https://discourse.processing.org/u/jackeddielove)\
**Replies:** 9\
**Last updated:** [June 10, 2023, 1:55am UTC](https://discourse.processing.org/t/recursive-function-for-generating-permutations-of-0-n/42163 "2023-06-10T01:55:57Z")

</div>

// trying to write a recursive function that returns all the permutations of \[0, ..., n\], for example: // perms(0) = \[\[0\]\] // perms(1) = \[\[0, 1\], \[1, 0\]\] // perms(2) = \[\[0, 1, 2\], \[0, 2, 1\], \[2, 0, 1\], \[1, 0, 2\], \[1, 2, …

---

## [Save to local storage, canvas and image should always remain](https://discourse.processing.org/t/save-to-local-storage-canvas-and-image-should-always-remain/42162)

<div class="topic-metadata">

**Author:** [@Chigoz](https://discourse.processing.org/u/Chigoz)\
**Replies:** 4\
**Last updated:** [June 7, 2023, 5:41pm UTC](https://discourse.processing.org/t/save-to-local-storage-canvas-and-image-should-always-remain/42162 "2023-06-07T17:41:17Z")

</div>

Hi friends, How do I save the variable mybytes holding the data to local storage so that the circles(images created after you drag and drop the Midi file) will always remain on the browser even if web page is reloaded? …

---

## [SDF outline - draw](https://discourse.processing.org/t/sdf-outline-draw/42130)

<div class="topic-metadata">

**Author:** [@v360](https://discourse.processing.org/u/v360)\
**Replies:** 2\
**Last updated:** [June 3, 2023, 4:08am UTC](https://discourse.processing.org/t/sdf-outline-draw/42130 "2023-06-03T04:08:42Z")

</div>

Hello Folks! I was studying SDF from some resources like this: youtube.com/watch?v=KRB57wyo8\_4 openprocessing.org/sketch/1898567 What I want is to try to understand a little more how SDFs work. What I want to do it to…

---

## [Move around the perimeter of a rectangle (using maths)](https://discourse.processing.org/t/move-around-the-perimeter-of-a-rectangle-using-maths/41905)

<div class="topic-metadata">

**Author:** [@vjjv](https://discourse.processing.org/u/vjjv)\
**Replies:** 1\
**Last updated:** [May 4, 2023, 5:37am UTC](https://discourse.processing.org/t/move-around-the-perimeter-of-a-rectangle-using-maths/41905 "2023-05-04T05:37:33Z")

</div>

Hello, im here, learning maths, or trying… so, i want to move around the perimeter of a rectangle using trigonometrics function like sin or cos, it is possible? In the example i using the regular if else stament. I know…

---

## [Homework help with loops](https://discourse.processing.org/t/homework-help-with-loops/41903)

<div class="topic-metadata">

**Author:** [@Computerscience](https://discourse.processing.org/u/Computerscience)\
**Replies:** 6\
**Last updated:** [May 3, 2023, 7:13pm UTC](https://discourse.processing.org/t/homework-help-with-loops/41903 "2023-05-03T19:13:56Z")

</div>

Question: Draw a character that would fit within a 40×40 pixel box. Once you have this working, use for loops to “tile” the image 100 times on a 400×400 pixel canvas. Hint: can you do this using only 2 for loops? proble…

---

## [Most efficient way of incrementing the entire sketches pixels saturation values?](https://discourse.processing.org/t/most-efficient-way-of-incrementing-the-entire-sketches-pixels-saturation-values/41886)

<div class="topic-metadata">

**Author:** [@jgl](https://discourse.processing.org/u/jgl)\
**Replies:** 4\
**Last updated:** [May 3, 2023, 2:41pm UTC](https://discourse.processing.org/t/most-efficient-way-of-incrementing-the-entire-sketches-pixels-saturation-values/41886 "2023-05-03T14:41:11Z")

</div>

Hi All, I’m currently trying to develop a sketch where you can rub out a colour from the screen, but it keeps fading back from black to the colour. You can see an index of experiments here: Sketches here The sketch i…

---

## [Need help with applying proportional stroke to randomly sized text](https://discourse.processing.org/t/need-help-with-applying-proportional-stroke-to-randomly-sized-text/41497)

<div class="topic-metadata">

**Author:** [@optimystery](https://discourse.processing.org/u/optimystery)\
**Replies:** 4\
**Last updated:** [May 2, 2023, 10:41am UTC](https://discourse.processing.org/t/need-help-with-applying-proportional-stroke-to-randomly-sized-text/41497 "2023-05-02T10:41:21Z")

</div>

I have a sketch at: testing outline width - OpenProcessing A phrase is output with random size and color. Some proportion of the time, an outline is added, but rather than hardcoding a value, I want stroke to be propor…

---

## [Multiple polygons loaded, user selects polygon of interest, user edits selected polygon nodes, user saves polygon](https://discourse.processing.org/t/multiple-polygons-loaded-user-selects-polygon-of-interest-user-edits-selected-polygon-nodes-user-saves-polygon/41774)

<div class="topic-metadata">

**Author:** [@andyhill](https://discourse.processing.org/u/andyhill)\
**Replies:** 18\
**Last updated:** [April 26, 2023, 10:17pm UTC](https://discourse.processing.org/t/multiple-polygons-loaded-user-selects-polygon-of-interest-user-edits-selected-polygon-nodes-user-saves-polygon/41774 "2023-04-26T22:17:56Z")

</div>

I want to load several polygons, user selects a polygon of interest, selected polygon nodes are visually drawn, user optionally drags polygon node to a new position, adjusted polygon is then saved. I would appreciate a …

---

## [Odd behavior from directional lights with webgl](https://discourse.processing.org/t/odd-behavior-from-directional-lights-with-webgl/41791)

<div class="topic-metadata">

**Author:** [@bluemoon](https://discourse.processing.org/u/bluemoon)\
**Replies:** 3\
**Last updated:** [April 22, 2023, 3:51pm UTC](https://discourse.processing.org/t/odd-behavior-from-directional-lights-with-webgl/41791 "2023-04-22T15:51:40Z")

</div>

Hi Folks, I’m getting what I think is some really weird behavior from directional lights when using webgl. Here’s the example sketch. What I can’t figure out is: Quads appear to reflect light opposite to boxes and o…

---

## [How to make an drawing sketch of the Godzilla heat beam, without leaving a trace of the beam line?](https://discourse.processing.org/t/how-to-make-an-drawing-sketch-of-the-godzilla-heat-beam-without-leaving-a-trace-of-the-beam-line/41681)

<div class="topic-metadata">

**Author:** [@Gittoo](https://discourse.processing.org/u/Gittoo)\
**Replies:** 5\
**Last updated:** [April 14, 2023, 10:26am UTC](https://discourse.processing.org/t/how-to-make-an-drawing-sketch-of-the-godzilla-heat-beam-without-leaving-a-trace-of-the-beam-line/41681 "2023-04-14T10:26:02Z")

</div>

let drawing = \[\]; let city; function preload() { city = loadImage("city.jpg"); } function setup() { createCanvas(city.width, city.height); } function mouseDragged() { drawing.push({ mouseX: mouseX, mouse…

---

## [How to implement adobe font into p5.js canvas by using textFont()](https://discourse.processing.org/t/how-to-implement-adobe-font-into-p5-js-canvas-by-using-textfont/41710)

<div class="topic-metadata">

**Author:** [@WaningJupiter](https://discourse.processing.org/u/WaningJupiter)\
**Replies:** 1\
**Last updated:** [April 13, 2023, 6:59pm UTC](https://discourse.processing.org/t/how-to-implement-adobe-font-into-p5-js-canvas-by-using-textfont/41710 "2023-04-13T18:59:38Z")

</div>

Hello, friends, I searched the forum, while there were several discussions around the topic, I was unable to find the answer I was looking for. Is it possible to use Typekit or Adobe fonts at the canvas level inside of…

---

## [How to add a text input for a TextToPoints project](https://discourse.processing.org/t/how-to-add-a-text-input-for-a-texttopoints-project/41686)

<div class="topic-metadata">

**Author:** [@qmartial](https://discourse.processing.org/u/qmartial)\
**Replies:** 2\
**Last updated:** [April 13, 2023, 2:22pm UTC](https://discourse.processing.org/t/how-to-add-a-text-input-for-a-texttopoints-project/41686 "2023-04-13T14:22:29Z")

</div>

Hello everyone ! I am still very new to P5js, and i’m trying to experiment generative/interactive typography for an art school project ; i followed a tutorial by Jeff Thompson about experimenting the TextToPoints effect…

---

## [Random walker on certain part of the canvas](https://discourse.processing.org/t/random-walker-on-certain-part-of-the-canvas/41696)

<div class="topic-metadata">

**Author:** [@Alesk1969](https://discourse.processing.org/u/Alesk1969)\
**Replies:** 9\
**Last updated:** [April 12, 2023, 9:26pm UTC](https://discourse.processing.org/t/random-walker-on-certain-part-of-the-canvas/41696 "2023-04-12T21:26:56Z")

</div>

Hi! I’m playing around with a Random Walker code. How can I make the Walker to be displayed only at the bottom half of the screen with the following code? And also not disapearing from the canvas ? Thanks in advance fo…

---

## [How to make an image tint while displaying another image, when I release the mouse? {P5js}](https://discourse.processing.org/t/how-to-make-an-image-tint-while-displaying-another-image-when-i-release-the-mouse-p5js/41677)

<div class="topic-metadata">

**Author:** [@Gittoo](https://discourse.processing.org/u/Gittoo)\
**Replies:** 2\
**Last updated:** [April 11, 2023, 11:12am UTC](https://discourse.processing.org/t/how-to-make-an-image-tint-while-displaying-another-image-when-i-release-the-mouse-p5js/41677 "2023-04-11T11:12:22Z")

</div>

let house; let ghost; let tinted = false; function preload() { house = loadImage('Haunted House.jpg'); } function setup() { createCanvas(house.width, house.height); ghost= loadImage('ghost.png'); tint(255, 3…

---

## [Access single object in an array](https://discourse.processing.org/t/access-single-object-in-an-array/41514)

<div class="topic-metadata">

**Author:** [@Alesk1969](https://discourse.processing.org/u/Alesk1969)\
**Replies:** 9\
**Last updated:** [April 5, 2023, 10:11pm UTC](https://discourse.processing.org/t/access-single-object-in-an-array/41514 "2023-04-05T22:11:27Z")

</div>

Hi! I’m struggling with something I guess is pretty simple. I’m building a sketch with an array of objects made of boxes. I’m looping through the array to display the boxes on the screen & to make the boxes spin. But I…

---

## [Brightness Range](https://discourse.processing.org/t/brightness-range/41483)

<div class="topic-metadata">

**Author:** [@linz](https://discourse.processing.org/u/linz)\
**Replies:** 2\
**Last updated:** [March 28, 2023, 7:25pm UTC](https://discourse.processing.org/t/brightness-range/41483 "2023-03-28T19:25:47Z")

</div>

Hi, I’m doing a homework on recreating an artwork using p5.js. For some reason, the brightness is going from 0-100 instead of 0-255, not sure why. let fontArray = ; let Obama; function preload() { fontArray\[0\] = load…

---

## ['p5 WEB' sometimes does not show](https://discourse.processing.org/t/p5-web-sometimes-does-not-show/41373)

<div class="topic-metadata">

**Author:** [@GWAK](https://discourse.processing.org/u/GWAK)\
**Replies:** 0\
**Last updated:** [March 21, 2023, 1:28am UTC](https://discourse.processing.org/t/p5-web-sometimes-does-not-show/41373 "2023-03-21T01:28:54Z")

</div>

‘p5 WEB’ sometimes does not show. //-\> setup var cbox; cbox = select('#map\_div'); cbox.position(10,160); cbox.hide(); //-\> button event cbox.show(); When the ‘cbox.show()’ operation is performed, the map should be v…

---

## [How to distinguish 'p5 WEB' smartphone computer?](https://discourse.processing.org/t/how-to-distinguish-p5-web-smartphone-computer/41334)

<div class="topic-metadata">

**Author:** [@GWAK](https://discourse.processing.org/u/GWAK)\
**Replies:** 4\
**Last updated:** [March 18, 2023, 11:49am UTC](https://discourse.processing.org/t/how-to-distinguish-p5-web-smartphone-computer/41334 "2023-03-18T11:49:45Z")

</div>

How to distinguish ‘p5 WEB’ smartphone computer? What you are currently using is a computer or mobile. Can I get device information? If it’s mobile, I want it to be fixed in portrait.

---

## [Problem with 3D and fill](https://discourse.processing.org/t/problem-with-3d-and-fill/41317)

<div class="topic-metadata">

**Author:** [@haapjou](https://discourse.processing.org/u/haapjou)\
**Replies:** 4\
**Last updated:** [March 17, 2023, 8:20am UTC](https://discourse.processing.org/t/problem-with-3d-and-fill/41317 "2023-03-17T08:20:44Z")

</div>

Hi, I’ve been trying to do boxes inside boxes, but for some reason can’t get the fill to work the way I want. (transparent fill with the stroke color). What am I missing??

---

## [Find the correct order of drawing a box in perspective](https://discourse.processing.org/t/find-the-correct-order-of-drawing-a-box-in-perspective/41271)

<div class="topic-metadata">

**Author:** [@vjjv](https://discourse.processing.org/u/vjjv)\
**Replies:** 5\
**Last updated:** [March 16, 2023, 6:32pm UTC](https://discourse.processing.org/t/find-the-correct-order-of-drawing-a-box-in-perspective/41271 "2023-03-16T18:32:13Z")

</div>

Hello! Im trying to learn about perspective using code and create my own drawing system. I have this piece of code and my problem is that i dont know how to sort the sides of the cube to draw them correctly according to…

---

## [Physics engine looks like not working but dunno how to test](https://discourse.processing.org/t/physics-engine-looks-like-not-working-but-dunno-how-to-test/41229)

<div class="topic-metadata">

**Author:** [@jounce](https://discourse.processing.org/u/jounce)\
**Replies:** 14\
**Last updated:** [March 13, 2023, 10:01pm UTC](https://discourse.processing.org/t/physics-engine-looks-like-not-working-but-dunno-how-to-test/41229 "2023-03-13T22:01:37Z")

</div>

https://replit.com/@imcute-aaaa/physics-lib#script.js (im not asking about p5,but i used p5,so i can ask,right?)

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

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