# Coding Questions

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

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

**Page:** 46

---

## [Get returning incorrect pixel color](https://discourse.processing.org/t/get-returning-incorrect-pixel-color/9826)

<div class="topic-metadata">

**Author:** [@Nokuro](https://discourse.processing.org/u/Nokuro)\
**Replies:** 7\
**Last updated:** [April 3, 2019, 12:12pm UTC](https://discourse.processing.org/t/get-returning-incorrect-pixel-color/9826 "2019-04-03T12:12:49Z")

</div>

get returning incorrect pixel color. See the image, There is a big green rectangle behind those circles. when I use get(x,y) in one of those circles, in the picture you can see the black dot, it is the location wher…

---

## [Snake: Will not ad cells to array with push. Why not?](https://discourse.processing.org/t/snake-will-not-ad-cells-to-array-with-push-why-not/9890)

<div class="topic-metadata">

**Author:** [@steinlav](https://discourse.processing.org/u/steinlav)\
**Replies:** 3\
**Last updated:** [April 3, 2019, 5:42am UTC](https://discourse.processing.org/t/snake-will-not-ad-cells-to-array-with-push-why-not/9890 "2019-04-03T05:42:28Z")

</div>

I am translating from Processing: http://vestera.as/processing/?id=23 to p5.js: https://editor.p5js.org/steinlav/sketches/1rkgu\_AGI Problem in p5.js line 57 Why is it not possible to ad object “head” to the array “b…

---

## [First time working with beginShape and endShape](https://discourse.processing.org/t/first-time-working-with-beginshape-and-endshape/9810)

<div class="topic-metadata">

**Author:** [@ZachMcMkay](https://discourse.processing.org/u/ZachMcMkay)\
**Replies:** 1\
**Last updated:** [April 2, 2019, 1:23am UTC](https://discourse.processing.org/t/first-time-working-with-beginshape-and-endshape/9810 "2019-04-02T01:23:12Z")

</div>

So basically this is code for a project. I have the circles rotating how I’d like them to, I also have a point on the inner circle rotating how i’d like it to. The point’s x and y positions are being saved in an array …

---

## [How to check if 4 lines make a rectangle?](https://discourse.processing.org/t/how-to-check-if-4-lines-make-a-rectangle/9639)

<div class="topic-metadata">

**Author:** [@misho\_0501](https://discourse.processing.org/u/misho_0501)\
**Replies:** 6\
**Last updated:** [April 1, 2019, 7:33pm UTC](https://discourse.processing.org/t/how-to-check-if-4-lines-make-a-rectangle/9639 "2019-04-01T19:33:04Z")

</div>

I’ve been tring to make the game Connect the dots and now I have a question. What is the easiest or the right way to check when four dots are connected and are making a rectangle. Here is a link to my implementation so …

---

## [Make different objects appear at different timing](https://discourse.processing.org/t/make-different-objects-appear-at-different-timing/9806)

<div class="topic-metadata">

**Author:** [@blkpanther](https://discourse.processing.org/u/blkpanther)\
**Replies:** 6\
**Last updated:** [April 1, 2019, 1:58am UTC](https://discourse.processing.org/t/make-different-objects-appear-at-different-timing/9806 "2019-04-01T01:58:27Z")

</div>

Hi, I have a code where I intend circles to appear on the canvas at different timing, then enlarge and disappear. Despite my attempts, they all seem to appear simultaneously. Anything wrong with setTimeout here? Thanks. …

---

## [Using p5 without sketch.js, setup() and draw()](https://discourse.processing.org/t/using-p5-without-sketch-js-setup-and-draw/9766)

<div class="topic-metadata">

**Author:** [@Milky](https://discourse.processing.org/u/Milky)\
**Replies:** 3\
**Last updated:** [March 31, 2019, 5:09pm UTC](https://discourse.processing.org/t/using-p5-without-sketch-js-setup-and-draw/9766 "2019-03-31T17:09:35Z")

</div>

Hello again, So, I want to add a new JS file to my project that I would like to run instead of the sketch.js file as the “main” JS file. Not always but sometimes. This is because I would like to separate my games “core”…

---

## [CreateCapture(VIDEO)](https://discourse.processing.org/t/createcapture-video/9812)

<div class="topic-metadata">

**Author:** [@vidasdemo](https://discourse.processing.org/u/vidasdemo)\
**Replies:** 0\
**Last updated:** [March 31, 2019, 4:59pm UTC](https://discourse.processing.org/t/createcapture-video/9812 "2019-03-31T16:59:55Z")

</div>

irrespective of what webcam I use CreateCapture always returns a video of size 300 by 150 when using p5.js web editor. Although I can use the size function to change the display size it seems that image function still ex…

---

## [Adjust pixels array but don't render on screen p5 js](https://discourse.processing.org/t/adjust-pixels-array-but-dont-render-on-screen-p5-js/9643)

<div class="topic-metadata">

**Author:** [@Milky](https://discourse.processing.org/u/Milky)\
**Replies:** 5\
**Last updated:** [March 31, 2019, 3:23pm UTC](https://discourse.processing.org/t/adjust-pixels-array-but-dont-render-on-screen-p5-js/9643 "2019-03-31T15:23:23Z")

</div>

Hello, I want to train a neural network, which will use the pixels array as input but I don’t want it to constantly render it while I am training it. Is it possible to not render any of the lines and vertices I drew but…

---

## [Disintegration/perish effect in p5.js](https://discourse.processing.org/t/disintegration-perish-effect-in-p5-js/9744)

<div class="topic-metadata">

**Author:** [@blkpanther](https://discourse.processing.org/u/blkpanther)\
**Replies:** 2\
**Last updated:** [March 31, 2019, 12:36pm UTC](https://discourse.processing.org/t/disintegration-perish-effect-in-p5-js/9744 "2019-03-31T12:36:09Z")

</div>

Is there any way to make any shape in p5.js disintegrate into particles or turn into ashes? Or is there any sample code that shows a similar effect where the original object or image perish? Alternatively any libraries t…

---

## [\[SOLVED\] P5js check if tiles are the same color](https://discourse.processing.org/t/solved-p5js-check-if-tiles-are-the-same-color/8832)

<div class="topic-metadata">

**Author:** [@ZachMcMkay](https://discourse.processing.org/u/ZachMcMkay)\
**Replies:** 15\
**Last updated:** [March 31, 2019, 11:32am UTC](https://discourse.processing.org/t/solved-p5js-check-if-tiles-are-the-same-color/8832 "2019-03-31T11:32:41Z")

</div>

I’m creating a short program that can randomize tiles to alternate white, then a random color from a set of 8 specific colors. However what i want to add to this is a way to check if the tiles around it are the same col…

---

## [Print object names in red or blue](https://discourse.processing.org/t/print-object-names-in-red-or-blue/9778)

<div class="topic-metadata">

**Author:** [@pawlisko](https://discourse.processing.org/u/pawlisko)\
**Replies:** 3\
**Last updated:** [March 30, 2019, 3:20pm UTC](https://discourse.processing.org/t/print-object-names-in-red-or-blue/9778 "2019-03-30T15:20:14Z")

</div>

My professor assigned this assignment and I just can’t figure out how to do it. Can anyone help me out or at least give me a head start. I’ve been trying to figure it out all day today and I get more and more confused. T…

---

## [GL\_INVALID\_OPERATION when reusing shader](https://discourse.processing.org/t/gl-invalid-operation-when-reusing-shader/9659)

<div class="topic-metadata">

**Author:** [@ahihi](https://discourse.processing.org/u/ahihi)\
**Replies:** 3\
**Last updated:** [March 27, 2019, 10:33am UTC](https://discourse.processing.org/t/gl-invalid-operation-when-reusing-shader/9659 "2019-03-27T10:33:53Z")

</div>

hello, i’m trying to implement a separable gaussian blur using fragment shaders, as described in https://github.com/Jam3/glsl-fast-gaussian-blur my code is at https://owo.uwu.fi/p5blur/ basically, the idea is to perfo…

---

## [Placement of sliders outside canvas](https://discourse.processing.org/t/placement-of-sliders-outside-canvas/9631)

<div class="topic-metadata">

**Author:** [@mpsteenstrup](https://discourse.processing.org/u/mpsteenstrup)\
**Replies:** 8\
**Last updated:** [March 27, 2019, 9:04am UTC](https://discourse.processing.org/t/placement-of-sliders-outside-canvas/9631 "2019-03-27T09:04:53Z")

</div>

Hi i am trying to place sliders directly under the canvas, but other text added to html keep getting in between. Does anyone have a solution to keep the sliders and buttons next to the canvas? the problem is visible her…

---

## [Create input accept numbers only](https://discourse.processing.org/t/create-input-accept-numbers-only/9624)

<div class="topic-metadata">

**Author:** [@d0nk](https://discourse.processing.org/u/d0nk)\
**Replies:** 2\
**Last updated:** [March 26, 2019, 10:52am UTC](https://discourse.processing.org/t/create-input-accept-numbers-only/9624 "2019-03-26T10:52:08Z")

</div>

Hello! I am new to P5js, trying to work with DOM library to accept number as user input. Is there a way to restrict the input box to accept numbers only as input?

---

## [@types/p5 not find like class in typeScript](https://discourse.processing.org/t/types-p5-not-find-like-class-in-typescript/9475)

<div class="topic-metadata">

**Author:** [@Stanlepunk](https://discourse.processing.org/u/Stanlepunk)\
**Replies:** 5\
**Last updated:** [March 24, 2019, 9:29am UTC](https://discourse.processing.org/t/types-p5-not-find-like-class-in-typescript/9475 "2019-03-24T09:29:09Z")

</div>

I download the last version of P5 types for TypeScript. I place it in the node folder, when I use importation the folder is detected but after when I try to implement p5 in the class, Sublim Text say the class is not fo…

---

## [Using right mouse -- without context menu?](https://discourse.processing.org/t/using-right-mouse-without-context-menu/9379)

<div class="topic-metadata">

**Author:** [@Convict999](https://discourse.processing.org/u/Convict999)\
**Replies:** 4\
**Last updated:** [March 22, 2019, 10:56pm UTC](https://discourse.processing.org/t/using-right-mouse-without-context-menu/9379 "2019-03-22T22:56:38Z")

</div>

Has anyone got an example of how to override the browser right click function in the preview window? It looks possible, but the thread i found isnt clear enough for my knowledge level. My code to check the rmb press se…

---

## [Uploading a text file to a server/URL](https://discourse.processing.org/t/uploading-a-text-file-to-a-server-url/9350)

<div class="topic-metadata">

**Author:** [@Schred](https://discourse.processing.org/u/Schred)\
**Replies:** 16\
**Last updated:** [March 22, 2019, 7:22pm UTC](https://discourse.processing.org/t/uploading-a-text-file-to-a-server-url/9350 "2019-03-22T19:22:20Z")

</div>

Hi! Before we start this: I have zero knowledge of webprogramming whatsoever. Sounds like this is going to be fun? Great! :stuck\_out\_tongue: Ok but honestly: I don’t know how complicated my question really is and whethe…

---

## [How to draw 3d spiral in p5.js in 2d without webgl or any 3D engine](https://discourse.processing.org/t/how-to-draw-3d-spiral-in-p5-js-in-2d-without-webgl-or-any-3d-engine/9339)

<div class="topic-metadata">

**Author:** [@blkpanther](https://discourse.processing.org/u/blkpanther)\
**Replies:** 9\
**Last updated:** [March 22, 2019, 12:15am UTC](https://discourse.processing.org/t/how-to-draw-3d-spiral-in-p5-js-in-2d-without-webgl-or-any-3d-engine/9339 "2019-03-22T00:15:29Z")

</div>

I intend to draw spirals in the shape of a 3d spring, as in the doodle below. How can I do that through trigonometry without 3d engines like webgl? Thanks!

---

## [Have a text follow a Bezier curve](https://discourse.processing.org/t/have-a-text-follow-a-bezier-curve/9399)

<div class="topic-metadata">

**Author:** [@sevaus](https://discourse.processing.org/u/sevaus)\
**Replies:** 5\
**Last updated:** [March 21, 2019, 11:59pm UTC](https://discourse.processing.org/t/have-a-text-follow-a-bezier-curve/9399 "2019-03-21T23:59:54Z")

</div>

Hello, I have some Bezier curves that represent the transitions of automata: https://imgur.com/a/aOsZvtZ These Bezier curves are draggable: https://imgur.com/DycuyKP I want to have the text follow the Bezier curve whe…

---

## [Mouse precision and smooth drawing](https://discourse.processing.org/t/mouse-precision-and-smooth-drawing/9444)

<div class="topic-metadata">

**Author:** [@slowking](https://discourse.processing.org/u/slowking)\
**Replies:** 2\
**Last updated:** [March 21, 2019, 10:10pm UTC](https://discourse.processing.org/t/mouse-precision-and-smooth-drawing/9444 "2019-03-21T22:10:27Z")

</div>

Helllo! In p5.js you have access to two sets of variables related to mouse position - mouseX/mouseY and pmouseX/pmouseY. I try to make an app where an user can draw some thing on the screen using mouse or drawing tablet…

---

## [touchEnded() clicks twice](https://discourse.processing.org/t/touchended-clicks-twice/9263)

<div class="topic-metadata">

**Author:** [@antocreo](https://discourse.processing.org/u/antocreo)\
**Replies:** 2\
**Last updated:** [March 19, 2019, 12:14pm UTC](https://discourse.processing.org/t/touchended-clicks-twice/9263 "2019-03-19T12:14:09Z")

</div>

Hi everyone, I am having some problem with touchEnded() function. I am using it to switch from a case to another and it works fine with the mouse on laptop. However, if I use a tablet it seems that the touch lasts lon…

---

## [Storing PGraphics to List of Images?](https://discourse.processing.org/t/storing-pgraphics-to-list-of-images/9391)

<div class="topic-metadata">

**Author:** [@FSXAC](https://discourse.processing.org/u/FSXAC)\
**Replies:** 2\
**Last updated:** [March 18, 2019, 12:38am UTC](https://discourse.processing.org/t/storing-pgraphics-to-list-of-images/9391 "2019-03-18T00:38:18Z")

</div>

Hi all, I want to “pre-render” some PGraphics to a list of images, what is the function to copy the PImage as an image (similar to how image() treats PGraphics as parameter as an image). Here is what I want to do in co…

---

## [Project Question](https://discourse.processing.org/t/project-question/9352)

<div class="topic-metadata">

**Author:** [@ixd](https://discourse.processing.org/u/ixd)\
**Replies:** 16\
**Last updated:** [March 17, 2019, 1:01am UTC](https://discourse.processing.org/t/project-question/9352 "2019-03-17T01:01:56Z")

</div>

Hi, I’m trying to make it so that the the numbers 1-36 (from the array up top) are listed inside each ellipse (so ellipse 1 would have the number 1, the ellipse next to it would have the number 2, etc. all the way up to…

---

## [Project Help Adding Sound](https://discourse.processing.org/t/project-help-adding-sound/9368)

<div class="topic-metadata">

**Author:** [@ixd](https://discourse.processing.org/u/ixd)\
**Replies:** 1\
**Last updated:** [March 17, 2019, 4:36am UTC](https://discourse.processing.org/t/project-help-adding-sound/9368 "2019-03-17T04:36:22Z")

</div>

Trying to make it so that when I press on number 1, the first sound (rollingsuitcase) is played. If you click again on the number 1, the sound should stop. Number 2 will make second sound (airportambiance) play. What’s t…

---

## [Web Editor : not defined width](https://discourse.processing.org/t/web-editor-not-defined-width/8240)

<div class="topic-metadata">

**Author:** [@Pilou](https://discourse.processing.org/u/Pilou)\
**Replies:** 12\
**Last updated:** [March 16, 2019, 2:15am UTC](https://discourse.processing.org/t/web-editor-not-defined-width/8240 "2019-03-16T02:15:56Z")

</div>

When I drop an image to the screen the width is not defined…in the function “draw” part ! https://editor.p5js.org/Pilou/sketches/qEPc9d1YD I have not this problem when an image is preloaded! https://editor.p5js.org/Pi…

---

## [Convert Processing to p5.js](https://discourse.processing.org/t/convert-processing-to-p5-js/9291)

<div class="topic-metadata">

**Author:** [@julia\_v](https://discourse.processing.org/u/julia_v)\
**Replies:** 5\
**Last updated:** [March 15, 2019, 6:02am UTC](https://discourse.processing.org/t/convert-processing-to-p5-js/9291 "2019-03-15T06:02:17Z")

</div>

Can’t figure out why some code doesn’t work… I highlighted what exactly doesn’t work in the code below… Please please help me to make the code working\* /\* @pjs preload="emma.jpg", "obama.jpg", "clint.jpg"; \*/ var maxT…

---

## [How to circle pack ellipses of pre-defined sizes in p5.js](https://discourse.processing.org/t/how-to-circle-pack-ellipses-of-pre-defined-sizes-in-p5-js/8891)

<div class="topic-metadata">

**Author:** [@blkpanther](https://discourse.processing.org/u/blkpanther)\
**Replies:** 5\
**Last updated:** [March 13, 2019, 8:39pm UTC](https://discourse.processing.org/t/how-to-circle-pack-ellipses-of-pre-defined-sizes-in-p5-js/8891 "2019-03-13T20:39:05Z")

</div>

I saw the coding train tutorials on how to grow circles until they touch each other in circle packing, but if I already have some circles of specific sizes, say 10 circles of the sizes in the range of random(5,10), how c…

---

## [Bouncing ball hang up (The Nature of Code)](https://discourse.processing.org/t/bouncing-ball-hang-up-the-nature-of-code/8733)

<div class="topic-metadata">

**Author:** [@steinlav](https://discourse.processing.org/u/steinlav)\
**Replies:** 9\
**Last updated:** [March 13, 2019, 5:35pm UTC](https://discourse.processing.org/t/bouncing-ball-hang-up-the-nature-of-code/8733 "2019-03-13T17:35:53Z")

</div>

Example 2.3 The Nature of Code The code: \[https://editor.p5js.org/steinlav/sketches/Y8qlyS9I6\] In the method checkEdges(), line 84 this.pos.y = height; () Problem: Why do the ball not loose bouncer over time when li…

---

## [Dynamic image masking, I made it! But how can I improve it?](https://discourse.processing.org/t/dynamic-image-masking-i-made-it-but-how-can-i-improve-it/9040)

<div class="topic-metadata">

**Author:** [@sundftig](https://discourse.processing.org/u/sundftig)\
**Replies:** 11\
**Last updated:** [March 13, 2019, 6:17am UTC](https://discourse.processing.org/t/dynamic-image-masking-i-made-it-but-how-can-i-improve-it/9040 "2019-03-13T06:17:18Z")

</div>

Hi everyone, this is my first post in this forum and I hope I will get some good help from you here! I´ve been looking for a way to mask images with a custom made shape in both Processing and p5.js but I couldn’t find a…

---

## [Need help with saveCanvas](https://discourse.processing.org/t/need-help-with-savecanvas/9221)

<div class="topic-metadata">

**Author:** [@grebjack](https://discourse.processing.org/u/grebjack)\
**Replies:** 2\
**Last updated:** [March 12, 2019, 11:45pm UTC](https://discourse.processing.org/t/need-help-with-savecanvas/9221 "2019-03-12T23:45:46Z")

</div>

I’m trying to generate a series of 12 related images and save each of them. At first I had the 12 generated in a for loop, but that routinely only got me 10 images saved and I had seen something in the saveFrames docume…

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

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