# Coding Questions

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

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

**Page:** 39

---

## [Get() and images](https://discourse.processing.org/t/get-and-images/15092)

<div class="topic-metadata">

**Author:** [@SheCurvesMobius](https://discourse.processing.org/u/SheCurvesMobius)\
**Replies:** 2\
**Last updated:** [October 31, 2019, 11:13pm UTC](https://discourse.processing.org/t/get-and-images/15092 "2019-10-31T23:13:29Z")

</div>

Hi all, With the following sketch, the image is drawn at (140, 500). However, when I sample the image using the get() function, it acts as though the image is drawn at (0, 0). How do I correct this? Thanks! let colour…

---

## [Storing drawing data in array for P5 drawing application?](https://discourse.processing.org/t/storing-drawing-data-in-array-for-p5-drawing-application/14951)

<div class="topic-metadata">

**Author:** [@jaymesdec](https://discourse.processing.org/u/jaymesdec)\
**Replies:** 3\
**Last updated:** [October 28, 2019, 3:01pm UTC](https://discourse.processing.org/t/storing-drawing-data-in-array-for-p5-drawing-application/14951 "2019-10-28T15:01:24Z")

</div>

Hi I am trying to help out a few of my students with a question that they have about drawing programs that they are building in P5. Start by drawing to the canvas using: line(mouseX, mouseY, pmouseX, pmouseY Then if t…

---

## [Updating global variables inside draw() function](https://discourse.processing.org/t/updating-global-variables-inside-draw-function/14945)

<div class="topic-metadata">

**Author:** [@Ale2200](https://discourse.processing.org/u/Ale2200)\
**Replies:** 5\
**Last updated:** [October 27, 2019, 4:17pm UTC](https://discourse.processing.org/t/updating-global-variables-inside-draw-function/14945 "2019-10-27T16:17:14Z")

</div>

I cannot update global variables in the Draw() function and I think that is because it would be problematic to deal with a variable that gets updated x times per second (I suppose?), sorry but I’m totally new to p5js. Ho…

---

## [Accessing data from color picker array](https://discourse.processing.org/t/accessing-data-from-color-picker-array/14960)

<div class="topic-metadata">

**Author:** [@MackMurphy](https://discourse.processing.org/u/MackMurphy)\
**Replies:** 2\
**Last updated:** [October 27, 2019, 2:08pm UTC](https://discourse.processing.org/t/accessing-data-from-color-picker-array/14960 "2019-10-27T14:08:14Z")

</div>

Hi, I’m using createColorPicker in p5.js and was wondering if there was any way to individually access the r, g, and b values from it, rather than using the entire color with colorPickerName.color(), and if there is, wha…

---

## [Converting my Processing code to p5.js (ArrayList + others!)](https://discourse.processing.org/t/converting-my-processing-code-to-p5-js-arraylist-others/14936)

<div class="topic-metadata">

**Author:** [@Rod1C](https://discourse.processing.org/u/Rod1C)\
**Replies:** 2\
**Last updated:** [October 26, 2019, 2:31am UTC](https://discourse.processing.org/t/converting-my-processing-code-to-p5-js-arraylist-others/14936 "2019-10-26T02:31:18Z")

</div>

Hello there, I’m new to Processing and p5.js and am trying without success to translate this code from Processing to p5. The main thing I’m having an issue with is the ArrayList at line 21 & 26, and also the functions …

---

## [Why wont the train move?](https://discourse.processing.org/t/why-wont-the-train-move/14927)

<div class="topic-metadata">

**Author:** [@Mike](https://discourse.processing.org/u/Mike)\
**Replies:** 6\
**Last updated:** [October 25, 2019, 12:06am UTC](https://discourse.processing.org/t/why-wont-the-train-move/14927 "2019-10-25T00:06:02Z")

</div>

Hi everyone, Im back again with more issues haha. https://editor.p5js.org/mcfiorino624/sketches/xVaLKQ\_NF started writing a simple program I am putting together for my son. I have successfully written 2 separate prog…

---

## [Moving from processing with java to P5.js](https://discourse.processing.org/t/moving-from-processing-with-java-to-p5-js/14912)

<div class="topic-metadata">

**Author:** [@Velouria](https://discourse.processing.org/u/Velouria)\
**Replies:** 8\
**Last updated:** [October 24, 2019, 12:58pm UTC](https://discourse.processing.org/t/moving-from-processing-with-java-to-p5-js/14912 "2019-10-24T12:58:37Z")

</div>

Hi there! Been using the java platform and recentley i’ve started to use the p5 platform. Really cool! However, I have this function for a bouncing ball that works perfectly in Java but doesnt work on js and I cant fin…

---

## [Game issues for christmas](https://discourse.processing.org/t/game-issues-for-christmas/14780)

<div class="topic-metadata">

**Author:** [@Mike](https://discourse.processing.org/u/Mike)\
**Replies:** 60\
**Last updated:** [October 22, 2019, 1:27am UTC](https://discourse.processing.org/t/game-issues-for-christmas/14780 "2019-10-22T01:27:20Z")

</div>

Ok first off, Hello everyone. I am new here and very new to coding. If you don’t care about the long backstory of my problem just skip to the next paragraph. I am currently working on my first large project, or at least…

---

## [Persistent Shape with Mouse?](https://discourse.processing.org/t/persistent-shape-with-mouse/14739)

<div class="topic-metadata">

**Author:** [@yangs](https://discourse.processing.org/u/yangs)\
**Replies:** 8\
**Last updated:** [October 21, 2019, 3:04am UTC](https://discourse.processing.org/t/persistent-shape-with-mouse/14739 "2019-10-21T03:04:36Z")

</div>

Hi all! I suppose I’m not quite understanding the relationship between setup and draw and how to keep things persistent based on how the background is rendered. I was wondering how to keep something persistent with the …

---

## [How does the canvas mix with html?](https://discourse.processing.org/t/how-does-the-canvas-mix-with-html/14787)

<div class="topic-metadata">

**Author:** [@tylerowens](https://discourse.processing.org/u/tylerowens)\
**Replies:** 4\
**Last updated:** [October 19, 2019, 7:44am UTC](https://discourse.processing.org/t/how-does-the-canvas-mix-with-html/14787 "2019-10-19T07:44:20Z")

</div>

Hello all, I am planning on starting my first p5js project, this is my first time in p5js but i have practiced in processing previously. My question is how to make the html elements go ontop of the canvas. what i mean …

---

## [P5.js: How to use a function as an object parameter](https://discourse.processing.org/t/p5-js-how-to-use-a-function-as-an-object-parameter/14753)

<div class="topic-metadata">

**Author:** [@Pickle\_Butter](https://discourse.processing.org/u/Pickle_Butter)\
**Replies:** 4\
**Last updated:** [October 17, 2019, 4:04pm UTC](https://discourse.processing.org/t/p5-js-how-to-use-a-function-as-an-object-parameter/14753 "2019-10-17T16:04:44Z")

</div>

I want to make a button object in p5.js. To do this, I would need to use the button’s function as a parameter in the constructor. I tried using this as the constructor: constructor(ixp, iyp, iw, ih, itext, icolor1, icol…

---

## [Show folder content like Processing "File directory"](https://discourse.processing.org/t/show-folder-content-like-processing-file-directory/14583)

<div class="topic-metadata">

**Author:** [@hi.ke](https://discourse.processing.org/u/hi.ke)\
**Replies:** 7\
**Last updated:** [October 14, 2019, 7:10pm UTC](https://discourse.processing.org/t/show-folder-content-like-processing-file-directory/14583 "2019-10-14T19:10:22Z")

</div>

Hi peoples :smile: currently I’m working on an interactive slideshow in p5 which I previously built up in processing. It all works so far but I have some issues on making an easy way to load all the images. I have to sa…

---

## [404 image not found](https://discourse.processing.org/t/404-image-not-found/14649)

<div class="topic-metadata">

**Author:** [@sam](https://discourse.processing.org/u/sam)\
**Replies:** 1\
**Last updated:** [October 13, 2019, 3:47pm UTC](https://discourse.processing.org/t/404-image-not-found/14649 "2019-10-13T15:47:38Z")

</div>

Here is my code var canvas; let dirtImg; function preload() { dirtImg = loadImage('assets/blocks/dirt.png'); } function setup() { // put setup code here canvas = createCanvas(window.innerWidth, window.innerHeigh…

---

## [Problem with intersection algorithm](https://discourse.processing.org/t/problem-with-intersection-algorithm/14634)

<div class="topic-metadata">

**Author:** [@braintrance](https://discourse.processing.org/u/braintrance)\
**Replies:** 6\
**Last updated:** [October 13, 2019, 11:59am UTC](https://discourse.processing.org/t/problem-with-intersection-algorithm/14634 "2019-10-13T11:59:33Z")

</div>

This code is supposed to draw 20 circles that are not intersecting, but it doesn’t. Where is the error in this? var circles=\[\]; function setup() { createCanvas(600, 400); background(0); for(var i=0; i\<20; i++…

---

## [Spirograph with matrix transformations](https://discourse.processing.org/t/spirograph-with-matrix-transformations/14567)

<div class="topic-metadata">

**Author:** [@neotechnic](https://discourse.processing.org/u/neotechnic)\
**Replies:** 2\
**Last updated:** [October 11, 2019, 6:27am UTC](https://discourse.processing.org/t/spirograph-with-matrix-transformations/14567 "2019-10-11T06:27:06Z")

</div>

I am trying to create a simple spirograph project with matrix transformation technique. I took an algorithm based on sin math, but in the end driving paths do not match. Any idea why I get a different trajectory? trans…

---

## [Fireworks Question](https://discourse.processing.org/t/fireworks-question/14564)

<div class="topic-metadata">

**Author:** [@philspitler](https://discourse.processing.org/u/philspitler)\
**Replies:** 2\
**Last updated:** [October 10, 2019, 4:01am UTC](https://discourse.processing.org/t/fireworks-question/14564 "2019-10-10T04:01:04Z")

</div>

Hi, I have followed this great tutorial by @shiffman And am trying to weak one aspect of the animation without affecting other properties. Basically I want the tail (start of the firework) to shoot up fas…

---

## [3D Rotations: Rotating around the screen axes](https://discourse.processing.org/t/3d-rotations-rotating-around-the-screen-axes/14239)

<div class="topic-metadata">

**Author:** [@raetrakt](https://discourse.processing.org/u/raetrakt)\
**Replies:** 28\
**Last updated:** [October 8, 2019, 3:17pm UTC](https://discourse.processing.org/t/3d-rotations-rotating-around-the-screen-axes/14239 "2019-10-08T15:17:52Z")

</div>

I wanted a sphere to rotate in a way that the point closest to the viewer always rotates up when the cursor is moved upwards and always left and right when the cursor is moved left and right. I had problems because afte…

---

## [Instance mode creating two canvas](https://discourse.processing.org/t/instance-mode-creating-two-canvas/14121)

<div class="topic-metadata">

**Author:** [@marlus](https://discourse.processing.org/u/marlus)\
**Replies:** 8\
**Last updated:** [October 7, 2019, 8:37am UTC](https://discourse.processing.org/t/instance-mode-creating-two-canvas/14121 "2019-10-07T08:37:09Z")

</div>

Hello there, I’m trying to use p5js instance mode, but I don’t know why, invoking new p5(sketch) create two canvases… const p5 = require('p5') global.p5 = p5 const sketch = () =\> { setup = () =\> { …

---

## [Why there exists a kinda blinking at some current?](https://discourse.processing.org/t/why-there-exists-a-kinda-blinking-at-some-current/14420)

<div class="topic-metadata">

**Author:** [@codemonic](https://discourse.processing.org/u/codemonic)\
**Replies:** 9\
**Last updated:** [October 5, 2019, 11:11am UTC](https://discourse.processing.org/t/why-there-exists-a-kinda-blinking-at-some-current/14420 "2019-10-05T11:11:06Z")

</div>

Hey, every 1, I just wanna make a copy of what’s this site displays in android browswer after entering, but the imitation is not as exact as I expect. At some time, the frame elements, for ballons objects, they blink, wh…

---

## [Planets with shadows](https://discourse.processing.org/t/planets-with-shadows/14309)

<div class="topic-metadata">

**Author:** [@Dohanr](https://discourse.processing.org/u/Dohanr)\
**Replies:** 3\
**Last updated:** [October 4, 2019, 12:16pm UTC](https://discourse.processing.org/t/planets-with-shadows/14309 "2019-10-04T12:16:01Z")

</div>

hope someone can help me with this. I’m using the p5.js lib in webGL. I have a sphere as earth rotating around x,y,z coordinates (0,0,0 - where the sun would be) then a I have another smaller sphere rotating around earth…

---

## [Make an authenticated JSON request](https://discourse.processing.org/t/make-an-authenticated-json-request/14224)

<div class="topic-metadata">

**Author:** [@prismspecs](https://discourse.processing.org/u/prismspecs)\
**Replies:** 5\
**Last updated:** [October 1, 2019, 6:29pm UTC](https://discourse.processing.org/t/make-an-authenticated-json-request/14224 "2019-10-01T18:29:00Z")

</div>

I see this page https://p5js.org/reference/#/p5/httpDo But when I try to make an API request with my access token from https://littlesis.org/api it doesn’t work. I see that LittleSis wants the string “Littlesis-Api-To…

---

## [textWidth() issues](https://discourse.processing.org/t/textwidth-issues/14218)

<div class="topic-metadata">

**Author:** [@GildasP](https://discourse.processing.org/u/GildasP)\
**Replies:** 4\
**Last updated:** [October 1, 2019, 1:17pm UTC](https://discourse.processing.org/t/textwidth-issues/14218 "2019-10-01T13:17:18Z")

</div>

Hi there. I’m using textWidth() to fit texts horizontaly in a fixed width. Doing so works great, I check for the textWidth() of my text in size 100, then I calculate in which size it would perfectly fit my fixed width …

---

## [Inpainting, image processing, complex functions](https://discourse.processing.org/t/inpainting-image-processing-complex-functions/14223)

<div class="topic-metadata">

**Author:** [@nsegal](https://discourse.processing.org/u/nsegal)\
**Replies:** 3\
**Last updated:** [September 30, 2019, 11:20pm UTC](https://discourse.processing.org/t/inpainting-image-processing-complex-functions/14223 "2019-09-30T23:20:19Z")

</div>

I’m trying to code a program that will visualize the effect of various polynomial functions on the complex plane. For example, the first image below shows a segment of the complex plane, centered on (0, 0), colored accor…

---

## [Saving p5js canvas as image to a server/database](https://discourse.processing.org/t/saving-p5js-canvas-as-image-to-a-server-database/14199)

<div class="topic-metadata">

**Author:** [@AndreasRef](https://discourse.processing.org/u/AndreasRef)\
**Replies:** 3\
**Last updated:** [September 30, 2019, 1:56pm UTC](https://discourse.processing.org/t/saving-p5js-canvas-as-image-to-a-server-database/14199 "2019-09-30T13:56:46Z")

</div>

Hi Short question What is the simplest way to save the p5js canvas on a public website (that everybody can access) as an image file to a server (that only I can see)? Longer explantion: I have made an art project wit…

---

## [P5.js interfering with my normal js?](https://discourse.processing.org/t/p5-js-interfering-with-my-normal-js/14299)

<div class="topic-metadata">

**Author:** [@grant](https://discourse.processing.org/u/grant)\
**Replies:** 0\
**Last updated:** [September 30, 2019, 3:17am UTC](https://discourse.processing.org/t/p5-js-interfering-with-my-normal-js/14299 "2019-09-30T03:17:03Z")

</div>

Hello, I’m trying to figure out why my typewriter effect wont work with my existing p5.js sketch? gif to give some explanation (https://gyazo.com/0421c071bdb4a2b5ecd0dfdf3ec3e66d) Basically, I created a whole new html…

---

## [10 boxes with random colors in specific locations](https://discourse.processing.org/t/10-boxes-with-random-colors-in-specific-locations/14227)

<div class="topic-metadata">

**Author:** [@van326](https://discourse.processing.org/u/van326)\
**Replies:** 4\
**Last updated:** [September 30, 2019, 3:41am UTC](https://discourse.processing.org/t/10-boxes-with-random-colors-in-specific-locations/14227 "2019-09-30T03:41:00Z")

</div>

I have finally started to understand classes and arrays (somewhat)! In the link I provided, I was trying to make at least 10 boxes with random colors in specific locations. So far, I think they are all showing, but I am …

---

## [P5js: 3D Typography Problems/Bugs?](https://discourse.processing.org/t/p5js-3d-typography-problems-bugs/14271)

<div class="topic-metadata">

**Author:** [@raetrakt](https://discourse.processing.org/u/raetrakt)\
**Replies:** 0\
**Last updated:** [September 29, 2019, 11:24am UTC](https://discourse.processing.org/t/p5js-3d-typography-problems-bugs/14271 "2019-09-29T11:24:24Z")

</div>

Adding Typography to my Sphere sketch caused further problems: -Some of the glyphs appear to have a white background, whereas others appear to have a transparent background. (Potentially an issue caused by the font bein…

---

## [Merging Canvas With HTML Website](https://discourse.processing.org/t/merging-canvas-with-html-website/14250)

<div class="topic-metadata">

**Author:** [@grant](https://discourse.processing.org/u/grant)\
**Replies:** 3\
**Last updated:** [September 28, 2019, 10:56pm UTC](https://discourse.processing.org/t/merging-canvas-with-html-website/14250 "2019-09-28T22:56:38Z")

</div>

Hello, I’m relatively new to HTML, CSS, and recently JS. I was inspired from https://ertdfgcvb.xyz/ to create something like that website with the js animations and mouse tracking interactions/trail for my first project. …

---

## [Particles not deleting at the same time](https://discourse.processing.org/t/particles-not-deleting-at-the-same-time/14190)

<div class="topic-metadata">

**Author:** [@flengwin](https://discourse.processing.org/u/flengwin)\
**Replies:** 3\
**Last updated:** [September 28, 2019, 5:06am UTC](https://discourse.processing.org/t/particles-not-deleting-at-the-same-time/14190 "2019-09-28T05:06:30Z")

</div>

Hello, I am working on a fireworks project. It seems when I increase the amount of particles to spawn in setup they delete at different times. I have them all updating at the same time so I don’t understand why they are …

---

## [How to navigate to certain HTML-section?](https://discourse.processing.org/t/how-to-navigate-to-certain-html-section/14111)

<div class="topic-metadata">

**Author:** [@hut](https://discourse.processing.org/u/hut)\
**Replies:** 4\
**Last updated:** [September 26, 2019, 1:20pm UTC](https://discourse.processing.org/t/how-to-navigate-to-certain-html-section/14111 "2019-09-26T13:20:27Z")

</div>

Hi! I believe my problem is fairly simple, but I just couldn’t find any answers: My p5-sketch is embedded inside a single-page website. When I click on a certain element inside the sketch, I want to scroll down to a ce…

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

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