# Coding Questions

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

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

**Page:** 15

---

## [Reset orbitControl()](https://discourse.processing.org/t/reset-orbitcontrol/33576)

<div class="topic-metadata">

**Author:** [@thesandrobrito](https://discourse.processing.org/u/thesandrobrito)\
**Replies:** 2\
**Last updated:** [November 18, 2021, 9:18am UTC](https://discourse.processing.org/t/reset-orbitcontrol/33576 "2021-11-18T09:18:23Z")

</div>

Hello everyone, I am working on an application where if I press a button I enable orbitControl, if I press another one it should reset to a automatic rotation. Is there anyway to reset orbitControl to 0 so the environm…

---

## [textureWrap() doesn't work?](https://discourse.processing.org/t/texturewrap-doesnt-work/33563)

<div class="topic-metadata">

**Author:** [@hinken](https://discourse.processing.org/u/hinken)\
**Replies:** 1\
**Last updated:** [November 17, 2021, 8:01am UTC](https://discourse.processing.org/t/texturewrap-doesnt-work/33563 "2021-11-17T08:01:36Z")

</div>

Hi, I’ve been trying to use textureWrap(MIRROR) to tile a texture and no matter what I do it doesn’t seem to do anything - the texture just resizes to the full size of the surface. I’ve put textureWrap() in both draw and…

---

## [Text is added twice](https://discourse.processing.org/t/text-is-added-twice/33527)

<div class="topic-metadata">

**Author:** [@MoonAlien822](https://discourse.processing.org/u/MoonAlien822)\
**Replies:** 1\
**Last updated:** [November 15, 2021, 10:29am UTC](https://discourse.processing.org/t/text-is-added-twice/33527 "2021-11-15T10:29:25Z")

</div>

in the kill screen, there is a textbox. when you click on it you can type, but the letters you type show up twice. how do i fix this?

---

## [Anti-aliased edges in WEBGL mode in p5js](https://discourse.processing.org/t/anti-aliased-edges-in-webgl-mode-in-p5js/33524)

<div class="topic-metadata">

**Author:** [@ippsketch](https://discourse.processing.org/u/ippsketch)\
**Replies:** 0\
**Last updated:** [November 15, 2021, 5:19am UTC](https://discourse.processing.org/t/anti-aliased-edges-in-webgl-mode-in-p5js/33524 "2021-11-15T05:19:35Z")

</div>

Shape edges are jagged in p5js WEBGL mode compared to the default 2D mode. smooth() and setAttributes(‘antialias’,true) did not work or improve this. Does anyone know how to achieve clean anti-aliased edges for p5js WE…

---

## [Is the pixels offset calculation correct in the p5.js reference?](https://discourse.processing.org/t/is-the-pixels-offset-calculation-correct-in-the-p5-js-reference/33460)

<div class="topic-metadata">

**Author:** [@hamoid](https://discourse.processing.org/u/hamoid)\
**Replies:** 2\
**Last updated:** [November 12, 2021, 8:24am UTC](https://discourse.processing.org/t/is-the-pixels-offset-calculation-correct-in-the-p5-js-reference/33460 "2021-11-12T08:24:55Z")

</div>

Hi hi, I’m using the webcam on a high dpi tablet, showing the webcam image and overlaying a few rectangles matching the webcam pixel color below. I based my code on the reference: // From https://p5js.org/reference/#/p…

---

## [Help translating p3 to p5js](https://discourse.processing.org/t/help-translating-p3-to-p5js/33199)

<div class="topic-metadata">

**Author:** [@MoonAlien822](https://discourse.processing.org/u/MoonAlien822)\
**Replies:** 10\
**Last updated:** [November 10, 2021, 4:16pm UTC](https://discourse.processing.org/t/help-translating-p3-to-p5js/33199 "2021-11-10T16:16:26Z")

</div>

i tried translating my processing 3 code into p5js code but it doesn’t work. what did i do wrong? p5js code: var trashX; var trashY; var boatX; var boatY; var ropelenght = 0; var movingspeed = 10; var time; var sc…

---

## [Setting random image texture on randomized number of torus from image array](https://discourse.processing.org/t/setting-random-image-texture-on-randomized-number-of-torus-from-image-array/33031)

<div class="topic-metadata">

**Author:** [@repeaterblues](https://discourse.processing.org/u/repeaterblues)\
**Replies:** 5\
**Last updated:** [November 9, 2021, 4:46am UTC](https://discourse.processing.org/t/setting-random-image-texture-on-randomized-number-of-torus-from-image-array/33031 "2021-11-09T04:46:52Z")

</div>

Hello, I am working on a code in webgl in the p5js web editor that calls in a random number of spinning torus, spinning at different speeds and angles, which are all defined. I have set the texture to pull from an array …

---

## [Ping-pong buffer in p5js shader](https://discourse.processing.org/t/ping-pong-buffer-in-p5js-shader/33367)

<div class="topic-metadata">

**Author:** [@altitudinem](https://discourse.processing.org/u/altitudinem)\
**Replies:** 0\
**Last updated:** [November 6, 2021, 8:41pm UTC](https://discourse.processing.org/t/ping-pong-buffer-in-p5js-shader/33367 "2021-11-06T20:41:24Z")

</div>

Hello everyone, I need help to figure out how to use multiple buffers in shader. (within p5js) First, this is the code that I’ve wrote so far. https://editor.p5js.org/exusquam/sketches/ELEBXQ174 Below is the same cod…

---

## [New rotated ellipse function help and suggestions](https://discourse.processing.org/t/new-rotated-ellipse-function-help-and-suggestions/33281)

<div class="topic-metadata">

**Author:** [@maggie](https://discourse.processing.org/u/maggie)\
**Replies:** 4\
**Last updated:** [November 6, 2021, 2:31pm UTC](https://discourse.processing.org/t/new-rotated-ellipse-function-help-and-suggestions/33281 "2021-11-06T14:31:45Z")

</div>

Hello! I finally figured out how to make an ellipse that will rotate without having to use the rotate function on it. I had had no luck getting solutions using rotate() and push()/pop() to generalize to making multiple …

---

## [How do I setUniform for an array of a custom struct?](https://discourse.processing.org/t/how-do-i-setuniform-for-an-array-of-a-custom-struct/33267)

<div class="topic-metadata">

**Author:** [@modusponens](https://discourse.processing.org/u/modusponens)\
**Replies:** 2\
**Last updated:** [November 2, 2021, 7:51pm UTC](https://discourse.processing.org/t/how-do-i-setuniform-for-an-array-of-a-custom-struct/33267 "2021-11-02T19:51:54Z")

</div>

I have a shader with this struct defined in it: struct LightInputData { vec3 worldPos; vec3 color; vec3 falloff; }; and it has this uniform variable: uniform LightInputData uPointLights\[8\]; How can I set this u…

---

## [How do I reverse the animation of a drawing in P5JS (more details in post)](https://discourse.processing.org/t/how-do-i-reverse-the-animation-of-a-drawing-in-p5js-more-details-in-post/33245)

<div class="topic-metadata">

**Author:** [@mrloosid](https://discourse.processing.org/u/mrloosid)\
**Replies:** 1\
**Last updated:** [November 2, 2021, 9:24am UTC](https://discourse.processing.org/t/how-do-i-reverse-the-animation-of-a-drawing-in-p5js-more-details-in-post/33245 "2021-11-02T09:24:31Z")

</div>

Source Code: p5.js Web Editor Basically I’m trying to do a pseudo generative poster that swaps between 3 artworks that I have predesigned. The idea is to make load one artpiece, wait a few seconds then reverse (essentia…

---

## [Scaling down & rotating a pattern causes rendering issues and flickering](https://discourse.processing.org/t/scaling-down-rotating-a-pattern-causes-rendering-issues-and-flickering/33227)

<div class="topic-metadata">

**Author:** [@miracle2k](https://discourse.processing.org/u/miracle2k)\
**Replies:** 1\
**Last updated:** [November 1, 2021, 8:49pm UTC](https://discourse.processing.org/t/scaling-down-rotating-a-pattern-causes-rendering-issues-and-flickering/33227 "2021-11-01T20:49:58Z")

</div>

Take this sketch as an example, which I created to reproduce the problem in isolation: https://editor.p5js.org/elsdoerfer/sketches/NrPcyu-mG It’s supposed to be a striped line pattern. I want it to be very fine, 1px li…

---

## [When p5js slider value is released function?](https://discourse.processing.org/t/when-p5js-slider-value-is-released-function/30581)

<div class="topic-metadata">

**Author:** [@olaf000olaf](https://discourse.processing.org/u/olaf000olaf)\
**Replies:** 5\
**Last updated:** [October 30, 2021, 10:52pm UTC](https://discourse.processing.org/t/when-p5js-slider-value-is-released-function/30581 "2021-10-30T22:52:57Z")

</div>

I want to re-draw the canvas when the user is done changing the slider values, how could I do that?

---

## [Sketch is stuck on loading](https://discourse.processing.org/t/sketch-is-stuck-on-loading/33126)

<div class="topic-metadata">

**Author:** [@gm314](https://discourse.processing.org/u/gm314)\
**Replies:** 3\
**Last updated:** [October 29, 2021, 9:43am UTC](https://discourse.processing.org/t/sketch-is-stuck-on-loading/33126 "2021-10-29T09:43:23Z")

</div>

I created a sketch that contains a pre-load function and uploaded it to my website’s ftp on dreamhost. The preload references a csv file via a url. The sketch runs fine in the p5js web editor. But it won’t run on my site…

---

## [Radio buttons positioning](https://discourse.processing.org/t/radio-buttons-positioning/33123)

<div class="topic-metadata">

**Author:** [@Clark](https://discourse.processing.org/u/Clark)\
**Replies:** 2\
**Last updated:** [October 28, 2021, 12:36am UTC](https://discourse.processing.org/t/radio-buttons-positioning/33123 "2021-10-28T00:36:22Z")

</div>

Hi. I am trying to find a method to position radio buttons closer to each other vertically. When I write : radio = createRadio(); radio.option('option-1'); radio.option('option-2'); radio.option('option-3')…

---

## [WebGL Background Image](https://discourse.processing.org/t/webgl-background-image/33121)

<div class="topic-metadata">

**Author:** [@Rubin](https://discourse.processing.org/u/Rubin)\
**Replies:** 2\
**Last updated:** [October 27, 2021, 8:10pm UTC](https://discourse.processing.org/t/webgl-background-image/33121 "2021-10-27T20:10:16Z")

</div>

I want to make a background image for my WebGL project. Does someone know how to do it?

---

## [How transform a value into a html element in p5?](https://discourse.processing.org/t/how-transform-a-value-into-a-html-element-in-p5/33050)

<div class="topic-metadata">

**Author:** [@letlet](https://discourse.processing.org/u/letlet)\
**Replies:** 4\
**Last updated:** [October 25, 2021, 7:11pm UTC](https://discourse.processing.org/t/how-transform-a-value-into-a-html-element-in-p5/33050 "2021-10-25T19:11:45Z")

</div>

Hi! I’m trying to make a single web page with p5.js, but at some moment I create an input and the value of the input I want to transform into a html tag (more specifically ‘h3’). I already tried the “.html()” as this exa…

---

## [Canvas & Save Image output sizes](https://discourse.processing.org/t/canvas-save-image-output-sizes/32934)

<div class="topic-metadata">

**Author:** [@newreality](https://discourse.processing.org/u/newreality)\
**Replies:** 2\
**Last updated:** [October 21, 2021, 11:53am UTC](https://discourse.processing.org/t/canvas-save-image-output-sizes/32934 "2021-10-21T11:53:27Z")

</div>

Hi All, please be easy on me as this is my first post and I’m quite new to coding, in general. However I have made some amazing progress these past few weeks. I do have a question and I may be using the wrong terminolog…

---

## [Canvas with semi-transparent backgrounds gets tranprenty removed in draw](https://discourse.processing.org/t/canvas-with-semi-transparent-backgrounds-gets-tranprenty-removed-in-draw/32974)

<div class="topic-metadata">

**Author:** [@Errorbot1122](https://discourse.processing.org/u/Errorbot1122)\
**Replies:** 3\
**Last updated:** [October 21, 2021, 10:14am UTC](https://discourse.processing.org/t/canvas-with-semi-transparent-backgrounds-gets-tranprenty-removed-in-draw/32974 "2021-10-21T10:14:46Z")

</div>

When I put my semi-transparent background, into the draw loop the transparency disappears after a few frames function draw() { background(100, 100); } Minimal Reproducible Result

---

## [Resizing the canvas using canvas.size freezes my code](https://discourse.processing.org/t/resizing-the-canvas-using-canvas-size-freezes-my-code/32942)

<div class="topic-metadata">

**Author:** [@Errorbot1122](https://discourse.processing.org/u/Errorbot1122)\
**Replies:** 3\
**Last updated:** [October 20, 2021, 6:23pm UTC](https://discourse.processing.org/t/resizing-the-canvas-using-canvas-size-freezes-my-code/32942 "2021-10-20T18:23:52Z")

</div>

I want to resize a canvas using canvas.size(w, h) but it keeps freezing my code!!! What I’ve tried Converting the canvas (I think is p5.Renderer) into an element by doing this: new p5.Element(canvas.elt, p5), but it st…

---

## [3D canvas clipping/Rotated Y lines not making it to or beyond the edge of z -axis?](https://discourse.processing.org/t/3d-canvas-clipping-rotated-y-lines-not-making-it-to-or-beyond-the-edge-of-z-axis/32954)

<div class="topic-metadata">

**Author:** [@hifilorau](https://discourse.processing.org/u/hifilorau)\
**Replies:** 1\
**Last updated:** [October 20, 2021, 2:46pm UTC](https://discourse.processing.org/t/3d-canvas-clipping-rotated-y-lines-not-making-it-to-or-beyond-the-edge-of-z-axis/32954 "2021-10-20T14:46:41Z")

</div>

Long time lurker, first time poster. I am working on a generative sketch with WEBGL This is an example. I’m having a huge issue getting my grid lines to extend to the edge of the canvas. And I suspect it’s because i e…

---

## [Is there a way to use an external canvas as the canvas p5 uses](https://discourse.processing.org/t/is-there-a-way-to-use-an-external-canvas-as-the-canvas-p5-uses/32910)

<div class="topic-metadata">

**Author:** [@Errorbot1122](https://discourse.processing.org/u/Errorbot1122)\
**Replies:** 4\
**Last updated:** [October 18, 2021, 9:18pm UTC](https://discourse.processing.org/t/is-there-a-way-to-use-an-external-canvas-as-the-canvas-p5-uses/32910 "2021-10-18T21:18:12Z")

</div>

Is there a way to use the \<canvas\> tag as the p5 canvas? Background Non really, I just want to create a premade canvas in my HTML What I’ve tried I try looking at the doc and searching on google, I could not find anyth…

---

## [Can I load 3dmodels from local?](https://discourse.processing.org/t/can-i-load-3dmodels-from-local/32350)

<div class="topic-metadata">

**Author:** [@yang](https://discourse.processing.org/u/yang)\
**Replies:** 7\
**Last updated:** [October 18, 2021, 4:25am UTC](https://discourse.processing.org/t/can-i-load-3dmodels-from-local/32350 "2021-10-18T04:25:52Z")

</div>

I’ve loaded a model using loadModel(), but it requires a path from the website. And because I can’t upload a file larger than 5M，I wonder if there is a way to load a model just from local (maybe createFileInput)? Thank …

---

## [Chrome performance issues](https://discourse.processing.org/t/chrome-performance-issues/32892)

<div class="topic-metadata">

**Author:** [@mortimr](https://discourse.processing.org/u/mortimr)\
**Replies:** 1\
**Last updated:** [October 17, 2021, 7:30pm UTC](https://discourse.processing.org/t/chrome-performance-issues/32892 "2021-10-17T19:30:01Z")

</div>

Hi ! I’ve got an animation with not that much entities drawn on the screen. Each entity is a set of vertices that draw some shapes with beginShape and endShape (tesseract mode). For some reason, on chrome the animation …

---

## [Constraining Image and Shape](https://discourse.processing.org/t/constraining-image-and-shape/32773)

<div class="topic-metadata">

**Author:** [@cartopher](https://discourse.processing.org/u/cartopher)\
**Replies:** 2\
**Last updated:** [October 13, 2021, 12:45am UTC](https://discourse.processing.org/t/constraining-image-and-shape/32773 "2021-10-13T00:45:09Z")

</div>

I need help with my JavaScript code in p5.js. I am struggling to figure out how to constrain the large image, so when you pan the screen at the max zoomed-out position (starting point), the image does not move off the s…

---

## [Fill text color with the same color of preload image](https://discourse.processing.org/t/fill-text-color-with-the-same-color-of-preload-image/32716)

<div class="topic-metadata">

**Author:** [@tropicalpoison](https://discourse.processing.org/u/tropicalpoison)\
**Replies:** 3\
**Last updated:** [October 10, 2021, 10:46am UTC](https://discourse.processing.org/t/fill-text-color-with-the-same-color-of-preload-image/32716 "2021-10-10T10:46:41Z")

</div>

Hello all, I want to fill a text’s (avg 450 words or more) color with the same color of preload image on canvas in P5js. Actually, I am trying to recreate this image with the same colors as the text I wrote. Is anybod…

---

## [Beginner needs help: unclear behaviour of a self written function (Minimax)](https://discourse.processing.org/t/beginner-needs-help-unclear-behaviour-of-a-self-written-function-minimax/32511)

<div class="topic-metadata">

**Author:** [@arathorn76](https://discourse.processing.org/u/arathorn76)\
**Replies:** 9\
**Last updated:** [October 10, 2021, 9:48am UTC](https://discourse.processing.org/t/beginner-needs-help-unclear-behaviour-of-a-self-written-function-minimax/32511 "2021-10-10T09:48:34Z")

</div>

Hi all, I´m just beginning to try out Javascript and after watching some Coding Train videos decided to give p5js and its online editor a try. Now I made a mistake and can´t figure it out. Detailed questions at the en…

---

## [Image Object Array not displaying correctly](https://discourse.processing.org/t/image-object-array-not-displaying-correctly/32704)

<div class="topic-metadata">

**Author:** [@Alexander\_Kessler](https://discourse.processing.org/u/Alexander_Kessler)\
**Replies:** 5\
**Last updated:** [October 9, 2021, 5:51pm UTC](https://discourse.processing.org/t/image-object-array-not-displaying-correctly/32704 "2021-10-09T17:51:55Z")

</div>

Need some help trying to make an object image array based on Daniel Shiffman tut, but having this console error while displaying . " image() was expecting p5.Image|p5.Element for the first parameter, received an empty v…

---

## [How to create angled SVG file from an image?](https://discourse.processing.org/t/how-to-create-angled-svg-file-from-an-image/32618)

<div class="topic-metadata">

**Author:** [@Ajones](https://discourse.processing.org/u/Ajones)\
**Replies:** 9\
**Last updated:** [October 7, 2021, 5:42pm UTC](https://discourse.processing.org/t/how-to-create-angled-svg-file-from-an-image/32618 "2021-10-07T17:42:13Z")

</div>

Hello, I am using \[sine waves portrait\] by \[iamrobin\] and I would like to change the angle on the lines also I would like to save the result as an SVG file instead of a PNG. I have been reading for 2 days now but I am …

---

## [I can't seem to use a uniform shader variable if I name it "uAmbientColor"](https://discourse.processing.org/t/i-cant-seem-to-use-a-uniform-shader-variable-if-i-name-it-uambientcolor/32593)

<div class="topic-metadata">

**Author:** [@modusponens](https://discourse.processing.org/u/modusponens)\
**Replies:** 3\
**Last updated:** [October 4, 2021, 8:25pm UTC](https://discourse.processing.org/t/i-cant-seem-to-use-a-uniform-shader-variable-if-i-name-it-uambientcolor/32593 "2021-10-04T20:25:44Z")

</div>

Just as the title says, if I make a p5 sketch with WEBGL enabled and all that, and I make a shader and try to give it a uniform variable called uAmbientColor, I am unable to use it correctly. Regard this humble sketch: …

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

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