# Coding Questions

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

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

**Page:** 36

---

## [P5.js tables saveTable](https://discourse.processing.org/t/p5-js-tables-savetable/18341)

<div class="topic-metadata">

**Author:** [@ctrembla](https://discourse.processing.org/u/ctrembla)\
**Replies:** 16\
**Last updated:** [March 3, 2020, 6:14pm UTC](https://discourse.processing.org/t/p5-js-tables-savetable/18341 "2020-03-03T18:14:47Z")

</div>

I’m trying to save my highscore when my player dies but instead of saving it to the file it got the info from. It creates a new file and send it download. Why is it doing that? & how can I get it to save the file to the …

---

## [Give randomly generated objects a destination rather than a velocity?](https://discourse.processing.org/t/give-randomly-generated-objects-a-destination-rather-than-a-velocity/18260)

<div class="topic-metadata">

**Author:** [@wavyboneee](https://discourse.processing.org/u/wavyboneee)\
**Replies:** 5\
**Last updated:** [March 2, 2020, 12:51pm UTC](https://discourse.processing.org/t/give-randomly-generated-objects-a-destination-rather-than-a-velocity/18260 "2020-03-02T12:51:58Z")

</div>

I’m new to coding so this might sound very stupid but any help would be great. I know how to increment x and y values to create object movement, and am in the process of learning how to do this using vectors, however I …

---

## [Rotating an object need to know the position of the points globally](https://discourse.processing.org/t/rotating-an-object-need-to-know-the-position-of-the-points-globally/18270)

<div class="topic-metadata">

**Author:** [@Pixelfixation](https://discourse.processing.org/u/Pixelfixation)\
**Replies:** 4\
**Last updated:** [March 1, 2020, 8:51pm UTC](https://discourse.processing.org/t/rotating-an-object-need-to-know-the-position-of-the-points-globally/18270 "2020-03-01T20:51:54Z")

</div>

Hey! I am making a simulation for my calc 1 professor. He wants a simulation of a ferris wheel where I can check the positions of the passengers on the Y axis at different points in time during the rotations. What I need…

---

## [Making a circle disappear when clicked on](https://discourse.processing.org/t/making-a-circle-disappear-when-clicked-on/18239)

<div class="topic-metadata">

**Author:** [@meh](https://discourse.processing.org/u/meh)\
**Replies:** 6\
**Last updated:** [March 1, 2020, 5:03pm UTC](https://discourse.processing.org/t/making-a-circle-disappear-when-clicked-on/18239 "2020-03-01T17:03:16Z")

</div>

I have some experience with java but I am new to p5js. I created a game with circles falling down and you gain 1 point every time you click on a circle, also when a circle reaches the bottom of the screen you lose a life…

---

## [Manually calculate "p5.vector.fromAngle?"](https://discourse.processing.org/t/manually-calculate-p5-vector-fromangle/18252)

<div class="topic-metadata">

**Author:** [@commie630](https://discourse.processing.org/u/commie630)\
**Replies:** 1\
**Last updated:** [March 1, 2020, 10:03am UTC](https://discourse.processing.org/t/manually-calculate-p5-vector-fromangle/18252 "2020-03-01T10:03:23Z")

</div>

Broad question, but how can I manually calculate a vector from an angle/radian as opposed to using p5.vector.fromAngle? (platform agonistic)

---

## [How do i change the circle's color when the mouse hovers over it?](https://discourse.processing.org/t/how-do-i-change-the-circles-color-when-the-mouse-hovers-over-it/18226)

<div class="topic-metadata">

**Author:** [@cesca](https://discourse.processing.org/u/cesca)\
**Replies:** 6\
**Last updated:** [February 29, 2020, 8:30pm UTC](https://discourse.processing.org/t/how-do-i-change-the-circles-color-when-the-mouse-hovers-over-it/18226 "2020-02-29T20:30:46Z")

</div>

I am super, super new to this so pls assume i know nothing: I adapted this code from a Daniel Shiffman tutorial. I know i have to use the dist function to compare mouseY, mouseX and the circle’s radius but idk how to wri…

---

## [Translate all pixels of a canvas?](https://discourse.processing.org/t/translate-all-pixels-of-a-canvas/18224)

<div class="topic-metadata">

**Author:** [@Coton](https://discourse.processing.org/u/Coton)\
**Replies:** 1\
**Last updated:** [February 29, 2020, 12:28pm UTC](https://discourse.processing.org/t/translate-all-pixels-of-a-canvas/18224 "2020-02-29T12:28:22Z")

</div>

Hi! I’m really new to P5.js and as I’m experimenting, I was wondering how to modify a pre existing file. I was looking at Daniel Shiffman’s Slit Scan here: The code is pretty simple and goes like this: // Daniel Shi…

---

## [How do I target a specific circle in a random circle packing?](https://discourse.processing.org/t/how-do-i-target-a-specific-circle-in-a-random-circle-packing/18227)

<div class="topic-metadata">

**Author:** [@cesca](https://discourse.processing.org/u/cesca)\
**Replies:** 4\
**Last updated:** [February 29, 2020, 1:06am UTC](https://discourse.processing.org/t/how-do-i-target-a-specific-circle-in-a-random-circle-packing/18227 "2020-02-29T01:06:56Z")

</div>

I want to change the circles’ colours when the mouse hovers them (but not all at once, just that specific circle the mouse is on)? I copied this code from a tutorial so I don’t know how to code at all. var circles = \[\];…

---

## [How to change a circle's colour when the mouse hovers it?](https://discourse.processing.org/t/how-to-change-a-circles-colour-when-the-mouse-hovers-it/18192)

<div class="topic-metadata">

**Author:** [@cesca](https://discourse.processing.org/u/cesca)\
**Replies:** 3\
**Last updated:** [February 28, 2020, 10:59am UTC](https://discourse.processing.org/t/how-to-change-a-circles-colour-when-the-mouse-hovers-it/18192 "2020-02-28T10:59:40Z")

</div>

New to Processing. I know I’m supposed to check if the distance from the mouse to the circle is less than the radius, but I don’t know how to write the code for that or where to place it. This code below is just an adapt…

---

## [How to make text output curve in a circle range?](https://discourse.processing.org/t/how-to-make-text-output-curve-in-a-circle-range/18135)

<div class="topic-metadata">

**Author:** [@linebrinkmann](https://discourse.processing.org/u/linebrinkmann)\
**Replies:** 9\
**Last updated:** [February 27, 2020, 2:51pm UTC](https://discourse.processing.org/t/how-to-make-text-output-curve-in-a-circle-range/18135 "2020-02-27T14:51:18Z")

</div>

I have problem with making text lines output in my canvas curve in a circle move? Have anyone or can anyone do that? :smile:

---

## [Table javascript p5.js](https://discourse.processing.org/t/table-javascript-p5-js/18168)

<div class="topic-metadata">

**Author:** [@ctrembla](https://discourse.processing.org/u/ctrembla)\
**Replies:** 0\
**Last updated:** [February 27, 2020, 2:09am UTC](https://discourse.processing.org/t/table-javascript-p5-js/18168 "2020-02-27T02:09:40Z")

</div>

Am I doing this correct? I read the tutoral on making Tables in p5.js, but when I try to make one it won’t run. ATM i’m trying to get a table to hold all the positions of the walls. here main var wall = \[35\]; var bs = …

---

## [Need help with buttons and array](https://discourse.processing.org/t/need-help-with-buttons-and-array/17117)

<div class="topic-metadata">

**Author:** [@TjarkTV](https://discourse.processing.org/u/TjarkTV)\
**Replies:** 5\
**Last updated:** [February 26, 2020, 8:14pm UTC](https://discourse.processing.org/t/need-help-with-buttons-and-array/17117 "2020-02-26T20:14:22Z")

</div>

hey guys I have a problem. I want to make a programm where i can press buttons to add something to an array which i can read, so like an numpad. the layout and all is great but when i want to add the function that when i…

---

## [Line problem with rotatingY axis](https://discourse.processing.org/t/line-problem-with-rotatingy-axis/18131)

<div class="topic-metadata">

**Author:** [@iriquois](https://discourse.processing.org/u/iriquois)\
**Replies:** 2\
**Last updated:** [February 26, 2020, 4:36pm UTC](https://discourse.processing.org/t/line-problem-with-rotatingy-axis/18131 "2020-02-26T16:36:52Z")

</div>

the line becomes distorted when rotating in the Y axis, but if I make the same thing in processing it works fine! any ideas? let btn, btn2; let y = 0; let x = 0; function setup() { createCanvas(600, 400, WEBGL); …

---

## [Minimum Spanning Tree - Minimum distance problem](https://discourse.processing.org/t/minimum-spanning-tree-minimum-distance-problem/18038)

<div class="topic-metadata">

**Author:** [@Giyomu](https://discourse.processing.org/u/Giyomu)\
**Replies:** 2\
**Last updated:** [February 26, 2020, 3:46pm UTC](https://discourse.processing.org/t/minimum-spanning-tree-minimum-distance-problem/18038 "2020-02-26T15:46:14Z")

</div>

Hey there, I am having some issue with the minimum distance method. In this test, I am trying to reproduce; 9.9: Minimum Spanning Tree from the coding train in Processing.js (https://www.youtube.com/watch?v=BxabnKrOjT0&t…

---

## [Task repeat every 10 seconds](https://discourse.processing.org/t/task-repeat-every-10-seconds/18028)

<div class="topic-metadata">

**Author:** [@nathan1](https://discourse.processing.org/u/nathan1)\
**Replies:** 6\
**Last updated:** [February 23, 2020, 7:24pm UTC](https://discourse.processing.org/t/task-repeat-every-10-seconds/18028 "2020-02-23T19:24:31Z")

</div>

Hi, I am using p5 js and I am trying to have some code execute every 10 seconds. I am having trouble finding the solution. Thanks.

---

## [Beginner needs help](https://discourse.processing.org/t/beginner-needs-help/11589)

<div class="topic-metadata">

**Author:** [@d\_vibe](https://discourse.processing.org/u/d_vibe)\
**Replies:** 9\
**Last updated:** [February 21, 2020, 2:23am UTC](https://discourse.processing.org/t/beginner-needs-help/11589 "2020-02-21T02:23:50Z")

</div>

Hi! I’m fairly new to programming graphical effects, and I thought, as a starter, it would be a fun thing to try to imitate some of the early demoscene effects that was seen on computers, such as the Commodore Amiga, bac…

---

## [Issue with windowResize(windowWidth, windowHeight)](https://discourse.processing.org/t/issue-with-windowresize-windowwidth-windowheight/17858)

<div class="topic-metadata">

**Author:** [@jctitan](https://discourse.processing.org/u/jctitan)\
**Replies:** 8\
**Last updated:** [February 18, 2020, 8:54pm UTC](https://discourse.processing.org/t/issue-with-windowresize-windowwidth-windowheight/17858 "2020-02-18T20:54:07Z")

</div>

Hi, recently I was making my reactjs app and decided to use p5 canvas as background. Since I didn’t use p5 before, I found some code on internet and copy it to my app. Canvas (background) looks good on page first load, b…

---

## [FrameRate gets slow over time](https://discourse.processing.org/t/framerate-gets-slow-over-time/3149)

<div class="topic-metadata">

**Author:** [@willianxz](https://discourse.processing.org/u/willianxz)\
**Replies:** 6\
**Last updated:** [February 16, 2020, 3:28pm UTC](https://discourse.processing.org/t/framerate-gets-slow-over-time/3149 "2020-02-16T15:28:38Z")

</div>

Hello my friends, I’m having trouble with the speed of my program. I set the default speed to 60 fps, but over time the increment of my variable “time” is slowly increasing. I wonder how I could solve this “bug”. I al…

---

## [Cant write to 2D-Array? Wanna set specific pixel](https://discourse.processing.org/t/cant-write-to-2d-array-wanna-set-specific-pixel/17801)

<div class="topic-metadata">

**Author:** [@aeh](https://discourse.processing.org/u/aeh)\
**Replies:** 2\
**Last updated:** [February 14, 2020, 10:14pm UTC](https://discourse.processing.org/t/cant-write-to-2d-array-wanna-set-specific-pixel/17801 "2020-02-14T22:14:33Z")

</div>

Hello, I wanna try to set specific pixels, but only when the 2d-array position has an “x”. What do I wrong? I cant find the mistake I do :frowning: //this will store the crap-mountain var data = {}; function preload()…

---

## [Create path from image shape outline](https://discourse.processing.org/t/create-path-from-image-shape-outline/17786)

<div class="topic-metadata">

**Author:** [@Napalm1432](https://discourse.processing.org/u/Napalm1432)\
**Replies:** 0\
**Last updated:** [February 13, 2020, 8:48am UTC](https://discourse.processing.org/t/create-path-from-image-shape-outline/17786 "2020-02-13T08:48:03Z")

</div>

Hi there, I’m working on a project to create toolpaths for a “zen” coffeetable. The goal is to create a pattern, and to be able to follow shapes in an image (black on white image, e.g. logo’s). So far i’m able to crea…

---

## [Two-Dimensional Elastic Collision what am I missing?](https://discourse.processing.org/t/two-dimensional-elastic-collision-what-am-i-missing/17759)

<div class="topic-metadata">

**Author:** [@fragdemented](https://discourse.processing.org/u/fragdemented)\
**Replies:** 3\
**Last updated:** [February 12, 2020, 6:18pm UTC](https://discourse.processing.org/t/two-dimensional-elastic-collision-what-am-i-missing/17759 "2020-02-12T18:18:29Z")

</div>

Hello World! I’m on a long personal journey to recreate classic games from scratch with my own flair to improve my programming skills. My next project is Asteroids, and I would like the asteroids to bounce off each othe…

---

## [Erro : Untaught SyntaxError: unexpected token 'var'](https://discourse.processing.org/t/erro-untaught-syntaxerror-unexpected-token-var/17733)

<div class="topic-metadata">

**Author:** [@Leonhard](https://discourse.processing.org/u/Leonhard)\
**Replies:** 6\
**Last updated:** [February 11, 2020, 6:11pm UTC](https://discourse.processing.org/t/erro-untaught-syntaxerror-unexpected-token-var/17733 "2020-02-11T18:11:55Z")

</div>

Hi, I’m trying to convert this code to JavaScript, but this error appears: “Untaught SyntaxError: unexpected token ‘var’”. Converted code: https://www.openprocessing.org/sketch/839422/embed/ Original code: https://www.…

---

## [Clickable dropdown menu](https://discourse.processing.org/t/clickable-dropdown-menu/17668)

<div class="topic-metadata">

**Author:** [@rihab](https://discourse.processing.org/u/rihab)\
**Replies:** 2\
**Last updated:** [February 11, 2020, 3:04pm UTC](https://discourse.processing.org/t/clickable-dropdown-menu/17668 "2020-02-11T15:04:27Z")

</div>

Hi I want to make a clickable dropdown menu but I find some problems function setup() { textAlign(CENTER); //background(200); sel = createSelect(); sel.position(11.5, 12 ); sel.size(39, 39) sel.option('A'…

---

## [Multiple Canvases preload()](https://discourse.processing.org/t/multiple-canvases-preload/17702)

<div class="topic-metadata">

**Author:** [@dc527x](https://discourse.processing.org/u/dc527x)\
**Replies:** 3\
**Last updated:** [February 11, 2020, 3:02pm UTC](https://discourse.processing.org/t/multiple-canvases-preload/17702 "2020-02-11T15:02:47Z")

</div>

If I have multiple sketches in my HTML page, what is the best way to ensure that they all load after the preload function? As of now I have three sketches. In sketch3 I have a preload function. The issue is I need to re…

---

## [How to turn off one object and turn on another with one click in an array?](https://discourse.processing.org/t/how-to-turn-off-one-object-and-turn-on-another-with-one-click-in-an-array/17574)

<div class="topic-metadata">

**Author:** [@RynWillDsgn](https://discourse.processing.org/u/RynWillDsgn)\
**Replies:** 4\
**Last updated:** [February 7, 2020, 5:08pm UTC](https://discourse.processing.org/t/how-to-turn-off-one-object-and-turn-on-another-with-one-click-in-an-array/17574 "2020-02-07T17:08:21Z")

</div>

Honestly, the title probably doesn’t make much sense (I’m new to this), but I’m in a tough spot. I’m a student and one of our modules is processing, a quick 2-week stint. I literally had two classes on processing and we …

---

## [P5js instance mode running sketches after removing them from DOM](https://discourse.processing.org/t/p5js-instance-mode-running-sketches-after-removing-them-from-dom/17551)

<div class="topic-metadata">

**Author:** [@eli7vh](https://discourse.processing.org/u/eli7vh)\
**Replies:** 1\
**Last updated:** [February 4, 2020, 6:44pm UTC](https://discourse.processing.org/t/p5js-instance-mode-running-sketches-after-removing-them-from-dom/17551 "2020-02-04T18:44:24Z")

</div>

Hello, I am making a sketch browser for myself using p5 instance mode. The sketches seem to continue running after removing them from the DOM. which results in my CPU getting pinned… relevant code is here: const loadS…

---

## [P5js sketch as background of 1 div](https://discourse.processing.org/t/p5js-sketch-as-background-of-1-div/17487)

<div class="topic-metadata">

**Author:** [@teddysphotos](https://discourse.processing.org/u/teddysphotos)\
**Replies:** 0\
**Last updated:** [January 31, 2020, 9:01pm UTC](https://discourse.processing.org/t/p5js-sketch-as-background-of-1-div/17487 "2020-01-31T21:01:01Z")

</div>

I have multiple tags in my project, I want to set one of my p5js sketches as the background of a particular . How do I do that? I have set the z-index of the canvas in sketch.js as -1. I just want to know how to set t…

---

## [Perhaps I do not know fill/random works after all](https://discourse.processing.org/t/perhaps-i-do-not-know-fill-random-works-after-all/17424)

<div class="topic-metadata">

**Author:** [@yangs](https://discourse.processing.org/u/yangs)\
**Replies:** 3\
**Last updated:** [January 30, 2020, 10:10pm UTC](https://discourse.processing.org/t/perhaps-i-do-not-know-fill-random-works-after-all/17424 "2020-01-30T22:10:46Z")

</div>

Creating a very rough sketch of a generative rothko – three or two rectangles of random size within a range on a muted background – and I’ve come to the conclusion I don’t understand how fill() and/or random() works. Ho…

---

## [Why won't my json url work?](https://discourse.processing.org/t/why-wont-my-json-url-work/17425)

<div class="topic-metadata">

**Author:** [@JennyMcCreadie](https://discourse.processing.org/u/JennyMcCreadie)\
**Replies:** 2\
**Last updated:** [January 29, 2020, 7:21pm UTC](https://discourse.processing.org/t/why-wont-my-json-url-work/17425 "2020-01-29T19:21:43Z")

</div>

Nothing I am doing seems to be working, I even used the same json url as used in this tutorial and it still keeps coming up with the error: "\> p5.js says: It looks like there was a problem loading your json. Try checkin…

---

## [Display images randomly by clicking](https://discourse.processing.org/t/display-images-randomly-by-clicking/17380)

<div class="topic-metadata">

**Author:** [@nicolas](https://discourse.processing.org/u/nicolas)\
**Replies:** 10\
**Last updated:** [January 27, 2020, 9:23pm UTC](https://discourse.processing.org/t/display-images-randomly-by-clicking/17380 "2020-01-27T21:23:44Z")

</div>

Hello, I’m trying to display images (10 or more) randomly when you click on the canvas. At the moment there is only one image displayed, and I don’t know how to proceed for the rest. Should I use img(); or createImg(); …

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

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