# Coding Questions

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

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

**Page:** 2

---

## [Can you help me to understand the code of this sketch?](https://discourse.processing.org/t/can-you-help-me-to-understand-the-code-of-this-sketch/46455)

<div class="topic-metadata">

**Author:** [@amaury](https://discourse.processing.org/u/amaury)\
**Replies:** 4\
**Last updated:** [June 27, 2025, 1:45pm UTC](https://discourse.processing.org/t/can-you-help-me-to-understand-the-code-of-this-sketch/46455 "2025-06-27T13:45:34Z")

</div>

Hi, Is there a way to predict where the square and rectangle will appear in the sketch below ? Is it linked to the nature of the “noise” function ? https://openprocessing.org/sketch/2026851 Thanks for your help.

---

## [P5.js movement logic — detective stops unexpectedly at corners in maze game](https://discourse.processing.org/t/p5-js-movement-logic-detective-stops-unexpectedly-at-corners-in-maze-game/46605)

<div class="topic-metadata">

**Author:** [@Andrew-James](https://discourse.processing.org/u/Andrew-James)\
**Replies:** 2\
**Last updated:** [June 25, 2025, 1:17pm UTC](https://discourse.processing.org/t/p5-js-movement-logic-detective-stops-unexpectedly-at-corners-in-maze-game/46605 "2025-06-25T13:17:45Z")

</div>

Hi everyone, I’m working on a p5.js project where a detective character follows a fixed path through a “Vice City”-style maze to catch a criminal named Fox. The movement is controlled by conditional statements that upda…

---

## [Browser Freeze + Massive Load Time. (When trying to compile shaders.)](https://discourse.processing.org/t/browser-freeze-massive-load-time-when-trying-to-compile-shaders/46509)

<div class="topic-metadata">

**Author:** [@winterchan](https://discourse.processing.org/u/winterchan)\
**Replies:** 7\
**Last updated:** [June 6, 2025, 3:12am UTC](https://discourse.processing.org/t/browser-freeze-massive-load-time-when-trying-to-compile-shaders/46509 "2025-06-06T03:12:00Z")

</div>

this is the code: https://openprocessing.org/sketch/2663057 The application is experiencing long freezes when switching fractal types for the first time in a session. The problem is spited into 2 questions: -Main P…

---

## [P5 point cloud with textures](https://discourse.processing.org/t/p5-point-cloud-with-textures/46393)

<div class="topic-metadata">

**Author:** [@hallohallo1234](https://discourse.processing.org/u/hallohallo1234)\
**Replies:** 12\
**Last updated:** [June 5, 2025, 10:37pm UTC](https://discourse.processing.org/t/p5-point-cloud-with-textures/46393 "2025-06-05T22:37:30Z")

</div>

is there a way to map a texture of a obj on points that i create in p5 with beginShape(POINTS). i would like that the user is able to load a texture alongside a .obj and it will map the colors of the texture accurately o…

---

## [Looking for a solution to make video autoplay work with p5.js on Firefox for Android, while it works in other browsers](https://discourse.processing.org/t/looking-for-a-solution-to-make-video-autoplay-work-with-p5-js-on-firefox-for-android-while-it-works-in-other-browsers/45850)

<div class="topic-metadata">

**Author:** [@v\_v.c](https://discourse.processing.org/u/v_v.c)\
**Replies:** 1\
**Last updated:** [March 2, 2025, 9:02am UTC](https://discourse.processing.org/t/looking-for-a-solution-to-make-video-autoplay-work-with-p5-js-on-firefox-for-android-while-it-works-in-other-browsers/45850 "2025-03-02T09:02:17Z")

</div>

Hey all I’m trying to get p5.js to autoplay video on Firefox Android, but I haven’t found a solution yet. Here’s a CodePen link demonstrating the issue: The page contains a video played with generic HTML and another …

---

## [Rotate arc in pacman animation](https://discourse.processing.org/t/rotate-arc-in-pacman-animation/45367)

<div class="topic-metadata">

**Author:** [@edufissure](https://discourse.processing.org/u/edufissure)\
**Replies:** 44\
**Last updated:** [February 20, 2025, 10:02pm UTC](https://discourse.processing.org/t/rotate-arc-in-pacman-animation/45367 "2025-02-20T22:02:15Z")

</div>

Hi ive been reading the tutorial or example were you make an animation of a pacman bit opening and closing the mouth The code: function draw() { background(0); // Style the arc. //noStroke(); fill(255, 255, 0)…

---

## [Creating 2D overlay with orbitControl](https://discourse.processing.org/t/creating-2d-overlay-with-orbitcontrol/45761)

<div class="topic-metadata">

**Author:** [@quark](https://discourse.processing.org/u/quark)\
**Replies:** 6\
**Last updated:** [February 15, 2025, 5:18pm UTC](https://discourse.processing.org/t/creating-2d-overlay-with-orbitcontrol/45761 "2025-02-15T17:18:40Z")

</div>

I have created a sketch to display the Utah Teapot and I am using orbitControl() to view it from any angle. My problem is that I am trying to create a static 2D overlay. As a demo I have simplified one of the p5js examp…

---

## [Mask function with external SVG shape](https://discourse.processing.org/t/mask-function-with-external-svg-shape/45746)

<div class="topic-metadata">

**Author:** [@Katsankat](https://discourse.processing.org/u/Katsankat)\
**Replies:** 1\
**Last updated:** [February 13, 2025, 2:47pm UTC](https://discourse.processing.org/t/mask-function-with-external-svg-shape/45746 "2025-02-13T14:47:30Z")

</div>

Hi, I’m using using P5.js with a node.js server. I’m trying to fill a SVG shape (external .svg file), with some drawing functions. To test it I’ve took some dots filling functions I’ve found, but it’s not the importan…

---

## [saveGif() delay doesn't work](https://discourse.processing.org/t/savegif-delay-doesnt-work/45706)

<div class="topic-metadata">

**Author:** [@Chloros](https://discourse.processing.org/u/Chloros)\
**Replies:** 4\
**Last updated:** [February 5, 2025, 9:44am UTC](https://discourse.processing.org/t/savegif-delay-doesnt-work/45706 "2025-02-05T09:44:33Z")

</div>

Hi, I’m trying to export some gifs with the function saveGif() ( https://p5js.org/reference/p5/saveGif/ ) but it seems taht the delay before recording the images doesn’t work. It records the gif but doesn’t apply any de…

---

## [How to set limits on zoom min/max in p5.js WEBGL mode?](https://discourse.processing.org/t/how-to-set-limits-on-zoom-min-max-in-p5-js-webgl-mode/45476)

<div class="topic-metadata">

**Author:** [@asdfasdf](https://discourse.processing.org/u/asdfasdf)\
**Replies:** 6\
**Last updated:** [December 27, 2024, 8:45pm UTC](https://discourse.processing.org/t/how-to-set-limits-on-zoom-min-max-in-p5-js-webgl-mode/45476 "2024-12-27T20:45:09Z")

</div>

I have a p5.js project in WEBGL mode, and I’ve been looking online to find a good way to constrain the minimum and maximum zoom levels, but I can’t find a solid solution. Ideally, I’d like to impose limits that work wit…

---

## [Zoom In boundries problem with Penrose Tilling App](https://discourse.processing.org/t/zoom-in-boundries-problem-with-penrose-tilling-app/45492)

<div class="topic-metadata">

**Author:** [@winterchan](https://discourse.processing.org/u/winterchan)\
**Replies:** 2\
**Last updated:** [December 21, 2024, 3:41pm UTC](https://discourse.processing.org/t/zoom-in-boundries-problem-with-penrose-tilling-app/45492 "2024-12-21T15:41:40Z")

</div>

with my latest code, it seems as if the boundaries of the space in which the art itself can be in, are smaller then the canvas itself, how do i know? Look at the first image: this is how the shape looks correctl…

---

## [A problem related to a "Live Feedback" \\ "Score System" system](https://discourse.processing.org/t/a-problem-related-to-a-live-feedback-score-system-system/45491)

<div class="topic-metadata">

**Author:** [@winterchan](https://discourse.processing.org/u/winterchan)\
**Replies:** 0\
**Last updated:** [December 19, 2024, 4:31pm UTC](https://discourse.processing.org/t/a-problem-related-to-a-live-feedback-score-system-system/45491 "2024-12-19T16:31:36Z")

</div>

Hi guys, requesting some help related to “live feedback mode” i implemented If activated you can give live feedback on your work every time you randomize to create a new output. The idea is the art should get more and…

---

## [Bug related to Export\\Import System](https://discourse.processing.org/t/bug-related-to-export-import-system/45460)

<div class="topic-metadata">

**Author:** [@winterchan](https://discourse.processing.org/u/winterchan)\
**Replies:** 8\
**Last updated:** [December 15, 2024, 3:25am UTC](https://discourse.processing.org/t/bug-related-to-export-import-system/45460 "2024-12-15T03:25:29Z")

</div>

The code is found here I found out that if i import the exact same export code on 2 pcs or even on the same pc but on a different tab or just reload the same tab and import it or hit the reload the code \\ randomiz…

---

## [More than one sketch in same HTML page](https://discourse.processing.org/t/more-than-one-sketch-in-same-html-page/45447)

<div class="topic-metadata">

**Author:** [@edufissure](https://discourse.processing.org/u/edufissure)\
**Replies:** 14\
**Last updated:** [December 14, 2024, 6:44pm UTC](https://discourse.processing.org/t/more-than-one-sketch-in-same-html-page/45447 "2024-12-14T18:44:36Z")

</div>

My index.html ( relevant code): \<!--Utilitzem la llibreria p5--\> \<script type="module" src="/js/libraries/p5.min.js"\>\</script\> \<!--Carreguem moduls--\> \<!--Carreguem sketch--\> \<script type="module" sr…

---

## [P5 text() and console.log treat multiline strings differently](https://discourse.processing.org/t/p5-text-and-console-log-treat-multiline-strings-differently/45452)

<div class="topic-metadata">

**Author:** [@ger](https://discourse.processing.org/u/ger)\
**Replies:** 9\
**Last updated:** [December 12, 2024, 2:50pm UTC](https://discourse.processing.org/t/p5-text-and-console-log-treat-multiline-strings-differently/45452 "2024-12-12T14:50:41Z")

</div>

Hello! I am trying to print some ASCII art to my p5 sketch and am having a lot of trouble. When it prints to the console, the padding on the art is correct and it looks good in the console. But when I use the text(art,0,…

---

## [Help with noise](https://discourse.processing.org/t/help-with-noise/45315)

<div class="topic-metadata">

**Author:** [@Stoli](https://discourse.processing.org/u/Stoli)\
**Replies:** 5\
**Last updated:** [November 13, 2024, 6:47pm UTC](https://discourse.processing.org/t/help-with-noise/45315 "2024-11-13T18:47:41Z")

</div>

I found this image and it looks like it was generated using noise. I’ve tried a bunch of different variations on the noise() function and have come up with some very interesting images but can’t seem to achieve anyth…

---

## [Convolution example doesn't work in p5 editor](https://discourse.processing.org/t/convolution-example-doesnt-work-in-p5-editor/45212)

<div class="topic-metadata">

**Author:** [@Chloros](https://discourse.processing.org/u/Chloros)\
**Replies:** 9\
**Last updated:** [November 8, 2024, 10:06pm UTC](https://discourse.processing.org/t/convolution-example-doesnt-work-in-p5-editor/45212 "2024-11-08T22:06:15Z")

</div>

Hi, I want to customize the image convolution example from the archive web site (https://archive.p5js.org/examples/image-convolution.html) but it doesn’t work outside the example page. When I paste it in the p5 editor w…

---

## [Help in P5.js (for fun program)](https://discourse.processing.org/t/help-in-p5-js-for-fun-program/45249)

<div class="topic-metadata">

**Author:** [@Epcrftr292](https://discourse.processing.org/u/Epcrftr292)\
**Replies:** 6\
**Last updated:** [November 6, 2024, 1:45am UTC](https://discourse.processing.org/t/help-in-p5-js-for-fun-program/45249 "2024-11-06T01:45:51Z")

</div>

Hello! I am having trouble with creating a stopwatch, timer, and decade clock in one program. I am currently having trouble with setting the years, months, etc. Down to milliseconds and have it count down on the timer pa…

---

## [Passing data to shader using texture](https://discourse.processing.org/t/passing-data-to-shader-using-texture/44446)

<div class="topic-metadata">

**Author:** [@ekez](https://discourse.processing.org/u/ekez)\
**Replies:** 2\
**Last updated:** [October 25, 2024, 12:13am UTC](https://discourse.processing.org/t/passing-data-to-shader-using-texture/44446 "2024-10-25T00:13:27Z")

</div>

Hi there, I want to pass timeseries data into a shader. Because the data is potentially quite long, I am trying to do so by writing the data to a texture, then passing the texture to my shader. I’m finding the texture d…

---

## [Boolean operation in polygons](https://discourse.processing.org/t/boolean-operation-in-polygons/23439)

<div class="topic-metadata">

**Author:** [@mmatty](https://discourse.processing.org/u/mmatty)\
**Replies:** 15\
**Last updated:** [October 6, 2024, 7:05pm UTC](https://discourse.processing.org/t/boolean-operation-in-polygons/23439 "2024-10-06T19:05:26Z")

</div>

Hi, wondering if anyone came across a solution to merge/union/intersect polygons? Not just drawing them with the same fill color, but actually creating a new shape which is a fusion of other arbitrary shapes. I can do …

---

## [How to detect if 2 instances of one function are the same (aka how to detect a twin)?](https://discourse.processing.org/t/how-to-detect-if-2-instances-of-one-function-are-the-same-aka-how-to-detect-a-twin/45128)

<div class="topic-metadata">

**Author:** [@willemr](https://discourse.processing.org/u/willemr)\
**Replies:** 10\
**Last updated:** [October 5, 2024, 5:24pm UTC](https://discourse.processing.org/t/how-to-detect-if-2-instances-of-one-function-are-the-same-aka-how-to-detect-a-twin/45128 "2024-10-05T17:24:20Z")

</div>

First of all, sorry for the confusing title. My sketch will make it clearer. I have written a function that makes faces that are composed of seperate but overlayed facial elements (which are png’s): -head shape -nose …

---

## [P5js - Why can't I apply this specific invert clip to a shape?](https://discourse.processing.org/t/p5js-why-cant-i-apply-this-specific-invert-clip-to-a-shape/45132)

<div class="topic-metadata">

**Author:** [@pedromgoncalves](https://discourse.processing.org/u/pedromgoncalves)\
**Replies:** 2\
**Last updated:** [October 4, 2024, 9:16am UTC](https://discourse.processing.org/t/p5js-why-cant-i-apply-this-specific-invert-clip-to-a-shape/45132 "2024-10-04T09:16:30Z")

</div>

Hi :slight\_smile: I’m trying to apply an invert clip to a shape, but, for this specific clip shape, the clip is not being applied to the shape. It works if the clip is not inverted, and it works with other clips, such a…

---

## [Anyone noticing that autosave sometimes goes inactive for more than 20 minutes. Is this expected behavior?](https://discourse.processing.org/t/anyone-noticing-that-autosave-sometimes-goes-inactive-for-more-than-20-minutes-is-this-expected-behavior/45072)

<div class="topic-metadata">

**Author:** [@chileed](https://discourse.processing.org/u/chileed)\
**Replies:** 1\
**Last updated:** [September 21, 2024, 4:11pm UTC](https://discourse.processing.org/t/anyone-noticing-that-autosave-sometimes-goes-inactive-for-more-than-20-minutes-is-this-expected-behavior/45072 "2024-09-21T16:11:46Z")

</div>

---

## [createCapture() captures video but can only draw first frame](https://discourse.processing.org/t/createcapture-captures-video-but-can-only-draw-first-frame/45015)

<div class="topic-metadata">

**Author:** [@weeklyd3](https://discourse.processing.org/u/weeklyd3)\
**Replies:** 3\
**Last updated:** [September 1, 2024, 12:58am UTC](https://discourse.processing.org/t/createcapture-captures-video-but-can-only-draw-first-frame/45015 "2024-09-01T00:58:24Z")

</div>

I’m trying to draw video from the webcam on a canvas: function update() { draw.clear(); draw.image(camera.get(), 0, 0); } var s = function(sketch) { sketch.setup = function() { sketch.createCanvas(640, 480); came…

---

## [Simple Perlin noise random walk behavior in C++](https://discourse.processing.org/t/simple-perlin-noise-random-walk-behavior-in-c/44975)

<div class="topic-metadata">

**Author:** [@Tilman](https://discourse.processing.org/u/Tilman)\
**Replies:** 1\
**Last updated:** [August 22, 2024, 4:27pm UTC](https://discourse.processing.org/t/simple-perlin-noise-random-walk-behavior-in-c/44975 "2024-08-22T16:27:14Z")

</div>

We are trying to get this same random walk behaviour from the simple perlin noise random walk as in the p5.js sketch below. But for us in C++ with openFrameworks Perlin Noise we get a behaviour where the dot is always dr…

---

## [Problem with a variable that doesn't work well between class definition and global variables](https://discourse.processing.org/t/problem-with-a-variable-that-doesnt-work-well-between-class-definition-and-global-variables/44905)

<div class="topic-metadata">

**Author:** [@rasabh](https://discourse.processing.org/u/rasabh)\
**Replies:** 1\
**Last updated:** [August 7, 2024, 11:52am UTC](https://discourse.processing.org/t/problem-with-a-variable-that-doesnt-work-well-between-class-definition-and-global-variables/44905 "2024-08-07T11:52:36Z")

</div>

i have a problem with the variable that i defined named ‘ballSpeed’ that i expected that it should become a greater number when mouse is pressed but it’s speed won’t change. on the other hand, other variables such as col…

---

## [HSL 210 hue should be in blue but rendering green](https://discourse.processing.org/t/hsl-210-hue-should-be-in-blue-but-rendering-green/44788)

<div class="topic-metadata">

**Author:** [@Leo\_Aguiar](https://discourse.processing.org/u/Leo_Aguiar)\
**Replies:** 1\
**Last updated:** [July 20, 2024, 11:49pm UTC](https://discourse.processing.org/t/hsl-210-hue-should-be-in-blue-but-rendering-green/44788 "2024-07-20T23:49:48Z")

</div>

Hi I’m making a plot of different colors on a 2d mapping of hsl color space. I think I have something wrong. The hue value of 210 should give a blue color but what is being drawn is green. let dim = 100; let mult = 5; …

---

## [Loading bar for loading image](https://discourse.processing.org/t/loading-bar-for-loading-image/44636)

<div class="topic-metadata">

**Author:** [@bulbx](https://discourse.processing.org/u/bulbx)\
**Replies:** 13\
**Last updated:** [July 16, 2024, 3:50pm UTC](https://discourse.processing.org/t/loading-bar-for-loading-image/44636 "2024-07-16T15:50:52Z")

</div>

Hello everyone (medium level in p5 / English is not my native language…) I am currently making my website in p5, it is almost finished. It’s quite simple, a sort of slideshow. I would like to have a loading bar for l…

---

## [How to do this programmatically (Combinatorics?)](https://discourse.processing.org/t/how-to-do-this-programmatically-combinatorics/38847)

<div class="topic-metadata">

**Author:** [@vkbr](https://discourse.processing.org/u/vkbr)\
**Replies:** 9\
**Last updated:** [June 17, 2024, 12:16pm UTC](https://discourse.processing.org/t/how-to-do-this-programmatically-combinatorics/38847 "2024-06-17T12:16:39Z")

</div>

A math question. Sorry if it’s a dumb one, but I couldn’t solve it. I wrote this with this for four points. All possibles lines, no repeating. pvline(p0, p1); pvline(p0, p2); pvline(p0, p3); …

---

## [I can't make my lorenz attractor balls opaque help pls](https://discourse.processing.org/t/i-cant-make-my-lorenz-attractor-balls-opaque-help-pls/44599)

<div class="topic-metadata">

**Author:** [@mayara](https://discourse.processing.org/u/mayara)\
**Replies:** 3\
**Last updated:** [June 15, 2024, 1:10am UTC](https://discourse.processing.org/t/i-cant-make-my-lorenz-attractor-balls-opaque-help-pls/44599 "2024-06-15T01:10:37Z")

</div>

I want to make the balls in this code opaque but whenever I try the balls stop appearing help plssssssssss im going crazyyyyy :anguished: :anguished: :sob: :sob: :cry: :confounded: :confounded: \<let o = 10; let p = 28…

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

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