# Coding Questions

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

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

**Page:** 47

---

## [Error with webacm](https://discourse.processing.org/t/error-with-webacm/9241)

<div class="topic-metadata">

**Author:** [@kcuf1623](https://discourse.processing.org/u/kcuf1623)\
**Replies:** 0\
**Last updated:** [March 12, 2019, 5:36pm UTC](https://discourse.processing.org/t/error-with-webacm/9241 "2019-03-12T17:36:00Z")

</div>

Hello everyone! I wanted to use webcam with p5.js But i don’t see video at all and got error message in chrome console like this. Uncaught TypeError: Failed to execute ‘createObjectURL’ on ‘URL’: No function was found…

---

## [New to P5 - basic object question](https://discourse.processing.org/t/new-to-p5-basic-object-question/9207)

<div class="topic-metadata">

**Author:** [@cryptogee](https://discourse.processing.org/u/cryptogee)\
**Replies:** 3\
**Last updated:** [March 12, 2019, 5:11pm UTC](https://discourse.processing.org/t/new-to-p5-basic-object-question/9207 "2019-03-12T17:11:55Z")

</div>

Hi, I’ve just discovered P5 today, I have some coding experience, however it is mainly theoretical/following along. Now I’m trying to make it on my own! Okay, so I have drawn a basic background with a couple of ellipses…

---

## [blendMode(NORMAL)](https://discourse.processing.org/t/blendmode-normal/9093)

<div class="topic-metadata">

**Author:** [@gregorfa](https://discourse.processing.org/u/gregorfa)\
**Replies:** 2\
**Last updated:** [March 10, 2019, 4:40pm UTC](https://discourse.processing.org/t/blendmode-normal/9093 "2019-03-10T16:40:38Z")

</div>

blendMode(NORMAL) doesn’t seem to work here. If you use another mode (DARKEST for example) it will change, but revert to normal does not seem to work. What am I missing? function setup() { createCanvas(400, 400); } fun…

---

## [Need some guidance to convert processing code to p5.js code](https://discourse.processing.org/t/need-some-guidance-to-convert-processing-code-to-p5-js-code/9164)

<div class="topic-metadata">

**Author:** [@keshavv\_123](https://discourse.processing.org/u/keshavv_123)\
**Replies:** 4\
**Last updated:** [March 10, 2019, 4:25pm UTC](https://discourse.processing.org/t/need-some-guidance-to-convert-processing-code-to-p5-js-code/9164 "2019-03-10T16:25:18Z")

</div>

Hi everyone, I’m trying to convert the processing code into the p5.js code but I didn’t understand how to convert the processing class and object into the p5.js code. can anyone please help me?

---

## [Can somebody help me understand this awesome code?](https://discourse.processing.org/t/can-somebody-help-me-understand-this-awesome-code/9153)

<div class="topic-metadata">

**Author:** [@sorenkirk](https://discourse.processing.org/u/sorenkirk)\
**Replies:** 4\
**Last updated:** [March 10, 2019, 4:04pm UTC](https://discourse.processing.org/t/can-somebody-help-me-understand-this-awesome-code/9153 "2019-03-10T16:04:29Z")

</div>

I came across a really cool sketch in Open Processing. But it’s uncommented, and I’d like to better understand what’s going on. (I am really new to p5.js, but have been using Processing for a few months). Anyway, I was …

---

## [Mouse coordinates not working in the area of the screen where there is a form](https://discourse.processing.org/t/mouse-coordinates-not-working-in-the-area-of-the-screen-where-there-is-a-form/9024)

<div class="topic-metadata">

**Author:** [@davide93](https://discourse.processing.org/u/davide93)\
**Replies:** 2\
**Last updated:** [March 8, 2019, 5:51pm UTC](https://discourse.processing.org/t/mouse-coordinates-not-working-in-the-area-of-the-screen-where-there-is-a-form/9024 "2019-03-08T17:51:52Z")

</div>

Hi there, I’m trying to use processing for an html5 page. I want to draw lines for all the page on mouse moving. When I move the mouse on the area of the page in which there is a form the lines are not drawn. I would…

---

## [pointLight not working with custom shapes or I'm doing it wrong](https://discourse.processing.org/t/pointlight-not-working-with-custom-shapes-or-im-doing-it-wrong/9101)

<div class="topic-metadata">

**Author:** [@fragdemented](https://discourse.processing.org/u/fragdemented)\
**Replies:** 2\
**Last updated:** [March 8, 2019, 5:05am UTC](https://discourse.processing.org/t/pointlight-not-working-with-custom-shapes-or-im-doing-it-wrong/9101 "2019-03-08T05:05:04Z")

</div>

Hello Everybody! I’m new here, but I am in love with p5js too! I’m trying to work with lighting in a 3D space. I can get it to work with a sphere, but it’s not working with any custom shapes that I make. Is this a bug o…

---

## [Is it possible to tile repeat a texture?](https://discourse.processing.org/t/is-it-possible-to-tile-repeat-a-texture/8044)

<div class="topic-metadata">

**Author:** [@Quilliam](https://discourse.processing.org/u/Quilliam)\
**Replies:** 3\
**Last updated:** [March 7, 2019, 8:20pm UTC](https://discourse.processing.org/t/is-it-possible-to-tile-repeat-a-texture/8044 "2019-03-07T20:20:05Z")

</div>

I’m trying to build a 3D model class using WebGL mode. I understand how create boxes with textures applied, but not sure how I would achieve essentially the effect of background-repeat: repeat-y;. I’d have control of the…

---

## [How to code this shape?](https://discourse.processing.org/t/how-to-code-this-shape/8882)

<div class="topic-metadata">

**Author:** [@Vennila](https://discourse.processing.org/u/Vennila)\
**Replies:** 1\
**Last updated:** [March 7, 2019, 5:07pm UTC](https://discourse.processing.org/t/how-to-code-this-shape/8882 "2019-03-07T17:07:23Z")

</div>

Hi, I’m practicing a sketch on p5.js. I have attached below a small cropped portion of the complete image. I want to draw the highlighted image. If I use ellipse function, it fills color on the inside portion of the ell…

---

## [I can't make the objects in an array track the mouse position while also moving towards a predefined spot on the canvas](https://discourse.processing.org/t/i-cant-make-the-objects-in-an-array-track-the-mouse-position-while-also-moving-towards-a-predefined-spot-on-the-canvas/8955)

<div class="topic-metadata">

**Author:** [@nielsKoel](https://discourse.processing.org/u/nielsKoel)\
**Replies:** 4\
**Last updated:** [March 5, 2019, 1:26pm UTC](https://discourse.processing.org/t/i-cant-make-the-objects-in-an-array-track-the-mouse-position-while-also-moving-towards-a-predefined-spot-on-the-canvas/8955 "2019-03-05T13:26:34Z")

</div>

Hi all, I’m trying to build a clock. The core idea is to have the actual time track the mouse behavior. As time passed, each past timestamp will get placed behind the current time, creating a visible trail of passed tim…

---

## [My code is "crashing" the editor. What is wrong?](https://discourse.processing.org/t/my-code-is-crashing-the-editor-what-is-wrong/8939)

<div class="topic-metadata">

**Author:** [@Lillbre](https://discourse.processing.org/u/Lillbre)\
**Replies:** 6\
**Last updated:** [March 5, 2019, 5:39am UTC](https://discourse.processing.org/t/my-code-is-crashing-the-editor-what-is-wrong/8939 "2019-03-05T05:39:23Z")

</div>

I made a code for a magnifier glass in p5.js. It works but the editor shuts down after a short time. Can someone please look at it and see what is wrong? The code in p5.js editor

---

## [“Robot 4: Translate, Rotate, Scale” (page 174) - added easing](https://discourse.processing.org/t/robot-4-translate-rotate-scale-page-174-added-easing/8703)

<div class="topic-metadata">

**Author:** [@dougouverson](https://discourse.processing.org/u/dougouverson)\
**Replies:** 2\
**Last updated:** [March 4, 2019, 1:10pm UTC](https://discourse.processing.org/t/robot-4-translate-rotate-scale-page-174-added-easing/8703 "2019-03-04T13:10:07Z")

</div>

I saw that easing variable was added, but no easing code was included so that easing happened. so, I modified the first few lines of function draw () to make easing happen: function draw() { var targetX = mouseX; x …

---

## [Where is the error in my code?](https://discourse.processing.org/t/where-is-the-error-in-my-code/8878)

<div class="topic-metadata">

**Author:** [@ximi](https://discourse.processing.org/u/ximi)\
**Replies:** 1\
**Last updated:** [March 3, 2019, 6:22am UTC](https://discourse.processing.org/t/where-is-the-error-in-my-code/8878 "2019-03-03T06:22:28Z")

</div>

https://editor.p5js.org/eternity95097@gmail.com/sketches/TvAwrnaMB

---

## [How to draw circles tangent to each other at random points](https://discourse.processing.org/t/how-to-draw-circles-tangent-to-each-other-at-random-points/8869)

<div class="topic-metadata">

**Author:** [@blkpanther](https://discourse.processing.org/u/blkpanther)\
**Replies:** 3\
**Last updated:** [March 3, 2019, 5:12am UTC](https://discourse.processing.org/t/how-to-draw-circles-tangent-to-each-other-at-random-points/8869 "2019-03-03T05:12:10Z")

</div>

I intend to draw circles tangent to each other at random points with no looping, but so far it doesn’t work as expected. let r = 20; function setup() { createCanvas(600, 600); } function draw() { background(…

---

## [P5js web editor - assets folder](https://discourse.processing.org/t/p5js-web-editor-assets-folder/8863)

<div class="topic-metadata">

**Author:** [@boneman](https://discourse.processing.org/u/boneman)\
**Replies:** 4\
**Last updated:** [March 2, 2019, 8:08pm UTC](https://discourse.processing.org/t/p5js-web-editor-assets-folder/8863 "2019-03-02T20:08:36Z")

</div>

SOLVED The assets in the sketch folder don’t seem to be loading. The sketch hasn’t been edited for weeks, and was working fine until a couple days ago. I wonder if there is some sort of expiration date on the images in …

---

## [How to make curves with slight variations](https://discourse.processing.org/t/how-to-make-curves-with-slight-variations/8745)

<div class="topic-metadata">

**Author:** [@blkpanther](https://discourse.processing.org/u/blkpanther)\
**Replies:** 2\
**Last updated:** [February 28, 2019, 6:28pm UTC](https://discourse.processing.org/t/how-to-make-curves-with-slight-variations/8745 "2019-02-28T18:28:29Z")

</div>

I intend to make arrays of curves that line up like this. So far my code can only draw straight lines like this or relatively regular curves I wonder how to use curve functions to create an array of curves that doesn…

---

## [Display a text over an hovered area](https://discourse.processing.org/t/display-a-text-over-an-hovered-area/8706)

<div class="topic-metadata">

**Author:** [@sevaus](https://discourse.processing.org/u/sevaus)\
**Replies:** 13\
**Last updated:** [February 28, 2019, 1:01pm UTC](https://discourse.processing.org/t/display-a-text-over-an-hovered-area/8706 "2019-02-28T13:01:43Z")

</div>

Hello, Say I have several automata: https://imgur.com/a/bga8qgE and I want to have a text displayed when the user hovers any arc. How could I do this? The automata was created using the usual functions arc, rect, line …

---

## [Closing a shape with curveVertex till the end](https://discourse.processing.org/t/closing-a-shape-with-curvevertex-till-the-end/6566)

<div class="topic-metadata">

**Author:** [@animofa](https://discourse.processing.org/u/animofa)\
**Replies:** 15\
**Last updated:** [February 27, 2019, 4:12pm UTC](https://discourse.processing.org/t/closing-a-shape-with-curvevertex-till-the-end/6566 "2019-02-27T16:12:57Z")

</div>

Hello, I am currently working on a circular wave generator, that can be modified by users. To achieve it I am using curveVertex. beginShape(); let i =0; for(let a = 0; a \< TWO\_PI; a += ang){ i++; let sx = x + …

---

## [Using texture() with vertex()](https://discourse.processing.org/t/using-texture-with-vertex/8714)

<div class="topic-metadata">

**Author:** [@anthonygalea](https://discourse.processing.org/u/anthonygalea)\
**Replies:** 8\
**Last updated:** [February 27, 2019, 7:52am UTC](https://discourse.processing.org/t/using-texture-with-vertex/8714 "2019-02-27T07:52:31Z")

</div>

I can use texture() successfully with plane() but I can’t seem to figure out how to use it with vertex(). Does p5.js support using texture() with a shape built using vertex() calls like this: let pg; function setup() {…

---

## [Why stroke can effect text's display?](https://discourse.processing.org/t/why-stroke-can-effect-texts-display/8728)

<div class="topic-metadata">

**Author:** [@sheeeeep](https://discourse.processing.org/u/sheeeeep)\
**Replies:** 7\
**Last updated:** [February 27, 2019, 2:33am UTC](https://discourse.processing.org/t/why-stroke-can-effect-texts-display/8728 "2019-02-27T02:33:48Z")

</div>

Here is my example: function setup() { createCanvas(640, 480); } function draw() { background(200) textSize(20) text("Welcome", 0, 20) stroke(255, 0, 0) } This is code’s preview:

---

## [Get RGB values of a pixel on the canvas](https://discourse.processing.org/t/get-rgb-values-of-a-pixel-on-the-canvas/8719)

<div class="topic-metadata">

**Author:** [@Milky](https://discourse.processing.org/u/Milky)\
**Replies:** 12\
**Last updated:** [February 26, 2019, 6:49pm UTC](https://discourse.processing.org/t/get-rgb-values-of-a-pixel-on-the-canvas/8719 "2019-02-26T18:49:51Z")

</div>

I tried get() and pixels array, but they both didnt work cause get() is for when you load an image as I understand and pixels array for some reason just is full of the background color and no colors of lines I drew. How …

---

## [Getting GIFs to Play in a Random Order](https://discourse.processing.org/t/getting-gifs-to-play-in-a-random-order/8716)

<div class="topic-metadata">

**Author:** [@ratilomend](https://discourse.processing.org/u/ratilomend)\
**Replies:** 2\
**Last updated:** [February 26, 2019, 6:41pm UTC](https://discourse.processing.org/t/getting-gifs-to-play-in-a-random-order/8716 "2019-02-26T18:41:14Z")

</div>

Hi all, I’m relatively new to p5 and coding generally. I’m currently working on a project which requires several GIFs to play one after another in a random order. I understand that arrays might be the way to go but I’m …

---

## [Creating multiple class instances in p5?](https://discourse.processing.org/t/creating-multiple-class-instances-in-p5/8665)

<div class="topic-metadata">

**Author:** [@Maximos118](https://discourse.processing.org/u/Maximos118)\
**Replies:** 6\
**Last updated:** [February 24, 2019, 2:22am UTC](https://discourse.processing.org/t/creating-multiple-class-instances-in-p5/8665 "2019-02-24T02:22:03Z")

</div>

I’d like to create a potentially unlimited amount of instances of a certain class within my javascript document: let trees; const treespawn = () =\> { let x = random(50, windowWidth - 50); let y = random(windowHeight…

---

## [Homework Help for p5](https://discourse.processing.org/t/homework-help-for-p5/8650)

<div class="topic-metadata">

**Author:** [@ixd](https://discourse.processing.org/u/ixd)\
**Replies:** 1\
**Last updated:** [February 23, 2019, 10:37am UTC](https://discourse.processing.org/t/homework-help-for-p5/8650 "2019-02-23T10:37:35Z")

</div>

I need to answer these questions about the code below, and am having trouble understanding them… How many times does the loop body run each frame, once the x and y arrays are full? What are two ways of increasing t…

---

## [Class function looping/setInterval issues](https://discourse.processing.org/t/class-function-looping-setinterval-issues/8644)

<div class="topic-metadata">

**Author:** [@Maximos118](https://discourse.processing.org/u/Maximos118)\
**Replies:** 6\
**Last updated:** [February 22, 2019, 7:57pm UTC](https://discourse.processing.org/t/class-function-looping-setinterval-issues/8644 "2019-02-22T19:57:20Z")

</div>

Ok, I’m trying to do something rather tricky here in p5. Take a look at my shudder class inside my Trees class: function draw() { background(0, 111, 10); trees.trunk(); trees.leaves(); trees.shudder(); } class Tr…

---

## [Calling classes that won't loop](https://discourse.processing.org/t/calling-classes-that-wont-loop/8623)

<div class="topic-metadata">

**Author:** [@Maximos118](https://discourse.processing.org/u/Maximos118)\
**Replies:** 3\
**Last updated:** [February 22, 2019, 11:32am UTC](https://discourse.processing.org/t/calling-classes-that-wont-loop/8623 "2019-02-22T11:32:23Z")

</div>

Hi there! I’m currently working on a game with p5 which will include some pretty complicated stuff… at least for me anyway. Hopefully you good looking people will help me to finish it in the future! Anyway my first of m…

---

## [Load csv file with createfileinput](https://discourse.processing.org/t/load-csv-file-with-createfileinput/8488)

<div class="topic-metadata">

**Author:** [@tatecaarson](https://discourse.processing.org/u/tatecaarson)\
**Replies:** 9\
**Last updated:** [February 21, 2019, 4:27am UTC](https://discourse.processing.org/t/load-csv-file-with-createfileinput/8488 "2019-02-21T04:27:52Z")

</div>

I am trying to load a csv file with loadTable after a user uploads it with createFileInput. I can get createFileInput to work if i’m using an image but not with loadTable. Here’s the important bit of code: input = creat…

---

## [Feedback for rollover buttons](https://discourse.processing.org/t/feedback-for-rollover-buttons/8484)

<div class="topic-metadata">

**Author:** [@mmartinez2187](https://discourse.processing.org/u/mmartinez2187)\
**Replies:** 1\
**Last updated:** [February 21, 2019, 12:33am UTC](https://discourse.processing.org/t/feedback-for-rollover-buttons/8484 "2019-02-21T00:33:34Z")

</div>

HI! I am not sure if i am doing this right but I wanted to create multiple rollover buttons using overRect() and overCircle() When I move my mouse over to the other shapes on the canvas, they don’t change colors; howev…

---

## [Why does my code not work](https://discourse.processing.org/t/why-does-my-code-not-work/8394)

<div class="topic-metadata">

**Author:** [@babaramdev](https://discourse.processing.org/u/babaramdev)\
**Replies:** 2\
**Last updated:** [February 16, 2019, 8:49pm UTC](https://discourse.processing.org/t/why-does-my-code-not-work/8394 "2019-02-16T20:49:41Z")

</div>

let x\_vals = \[\]; //List of x-values let y\_vals = \[\]; let shapeDone = 0; //When shapeDone = 0, the shape has not been completed. When shapeDone = 1, the shape is completed. let numberOfSides = 0; let area=0; var listOfAll…

---

## [JavaScript Basic Question](https://discourse.processing.org/t/javascript-basic-question/8434)

<div class="topic-metadata">

**Author:** [@ixd](https://discourse.processing.org/u/ixd)\
**Replies:** 1\
**Last updated:** [February 16, 2019, 2:29am UTC](https://discourse.processing.org/t/javascript-basic-question/8434 "2019-02-16T02:29:18Z")

</div>

How can I make it so that the grass is “cut” at a certain height? I think I should be changing something in line 21, but not sure… also, when the grass is cut, all that happens is a white rectangle is being placed over …

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

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