# Coding Questions

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

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

**Page:** 14

---

## [P5.js Soft body dynamics on text](https://discourse.processing.org/t/p5-js-soft-body-dynamics-on-text/34225)

<div class="topic-metadata">

**Author:** [@Didicw93](https://discourse.processing.org/u/Didicw93)\
**Replies:** 1\
**Last updated:** [December 24, 2021, 8:05am UTC](https://discourse.processing.org/t/p5-js-soft-body-dynamics-on-text/34225 "2021-12-24T08:05:44Z")

</div>

I’m trying to figure out how to apply the basic soft dynamic in the reference page of P5.js on to typography/text. at the moment i think that the only option is to draw the shapes of the letters via “beginShape()” any s…

---

## [Calling Method Properties Issue](https://discourse.processing.org/t/calling-method-properties-issue/34138)

<div class="topic-metadata">

**Author:** [@anoniem](https://discourse.processing.org/u/anoniem)\
**Replies:** 2\
**Last updated:** [December 20, 2021, 2:43pm UTC](https://discourse.processing.org/t/calling-method-properties-issue/34138 "2021-12-20T14:43:43Z")

</div>

Hi, I’m having problem with my OOP homework. So I’m basically working on a sheep that moves around, and is draggable. When those Sheeps intersect a new one should be made. I wrote down the code for this on line 101 an…

---

## [Saving canvas to a file](https://discourse.processing.org/t/saving-canvas-to-a-file/11027)

<div class="topic-metadata">

**Author:** [@astraszab](https://discourse.processing.org/u/astraszab)\
**Replies:** 4\
**Last updated:** [December 17, 2021, 1:36pm UTC](https://discourse.processing.org/t/saving-canvas-to-a-file/11027 "2021-12-17T13:36:03Z")

</div>

I need to save canvas to a file inside a server directory to process it later in another program. When I use saveCanvas() browser creates a prompt window. How can I save a file to a specified directory without a prompt w…

---

## [P5 js collision of classes ALL HELP WELCOME 🙏](https://discourse.processing.org/t/p5-js-collision-of-classes-all-help-welcome/34144)

<div class="topic-metadata">

**Author:** [@maximleyssens](https://discourse.processing.org/u/maximleyssens)\
**Replies:** 1\
**Last updated:** [December 16, 2021, 10:29pm UTC](https://discourse.processing.org/t/p5-js-collision-of-classes-all-help-welcome/34144 "2021-12-16T22:29:03Z")

</div>

i am trying to make the class whitecell eat the bloodscells can anyone help me with this I have tried everything but noting works I am obligated to use oop but if this Is to hard to do i will just use functions , all i r…

---

## [P5js Class issue](https://discourse.processing.org/t/p5js-class-issue/33869)

<div class="topic-metadata">

**Author:** [@anoniem](https://discourse.processing.org/u/anoniem)\
**Replies:** 14\
**Last updated:** [December 15, 2021, 11:29am UTC](https://discourse.processing.org/t/p5js-class-issue/33869 "2021-12-15T11:29:13Z")

</div>

I want to drag multiple squares around, that’s why I put it in a class. Also because the subject at school is OOP. Why exactly isn’t it working? It worked perfectly fine without using a class. Online editor: p5.js Web…

---

## [Collision problem I really need your help ... begging](https://discourse.processing.org/t/collision-problem-i-really-need-your-help-begging/34136)

<div class="topic-metadata">

**Author:** [@maximleyssens](https://discourse.processing.org/u/maximleyssens)\
**Replies:** 7\
**Last updated:** [December 16, 2021, 7:31am UTC](https://discourse.processing.org/t/collision-problem-i-really-need-your-help-begging/34136 "2021-12-16T07:31:11Z")

</div>

hey i am really struggeling with this collision issue I want to make the white cell eat the bloodcell when they collide can u please help me let MAX\_NUM = 50; let circles = \[\]; class Circle { constructor(x, y, ) …

---

## [Collision in p5 js](https://discourse.processing.org/t/collision-in-p5-js/34120)

<div class="topic-metadata">

**Author:** [@maximleyssens](https://discourse.processing.org/u/maximleyssens)\
**Replies:** 0\
**Last updated:** [December 14, 2021, 8:56pm UTC](https://discourse.processing.org/t/collision-in-p5-js/34120 "2021-12-14T20:56:35Z")

</div>

hey, i have a school project where I need to let creatures interact with each other this is done by collision I already have made a big part but now I wanted to make that u can eat the red circles by moving on them with…

---

## [I need a quick explanation how this works cause i don't get it](https://discourse.processing.org/t/i-need-a-quick-explanation-how-this-works-cause-i-dont-get-it/34096)

<div class="topic-metadata">

**Author:** [@parichko](https://discourse.processing.org/u/parichko)\
**Replies:** 3\
**Last updated:** [December 13, 2021, 2:54pm UTC](https://discourse.processing.org/t/i-need-a-quick-explanation-how-this-works-cause-i-dont-get-it/34096 "2021-12-13T14:54:07Z")

</div>

let x let y let s1 let s2 function setup() { createCanvas(400, 400); frameRate(60) x = 50 y = 50 s1 = 1 s2 = 1 } function draw() { background('black'); ellipse(x,y,100) x += s1 y += s2 if (y \> 350 && x \> 350){ s2 \*= -1 …

---

## [\[p5.js\] Is it possible to edit the 'initial-scale' of 'meta\[name=viewport\]'?](https://discourse.processing.org/t/p5-js-is-it-possible-to-edit-the-initial-scale-of-meta-name-viewport/34087)

<div class="topic-metadata">

**Author:** [@GWAK](https://discourse.processing.org/u/GWAK)\
**Replies:** 8\
**Last updated:** [December 13, 2021, 9:16am UTC](https://discourse.processing.org/t/p5-js-is-it-possible-to-edit-the-initial-scale-of-meta-name-viewport/34087 "2021-12-13T09:16:29Z")

</div>

Is it possible to edit the ‘initial-scale’ of ‘meta\[name=viewport\]’? through ‘js’ \*link: html - Change initial scale with javascript - Stack Overflow if (document.documentElement.clientWidth \< 480) { document.q…

---

## [Trying to make a multidimensional array which can connect to my buttons Please Help as soon as possible Please](https://discourse.processing.org/t/trying-to-make-a-multidimensional-array-which-can-connect-to-my-buttons-please-help-as-soon-as-possible-please/34047)

<div class="topic-metadata">

**Author:** [@tkenyon](https://discourse.processing.org/u/tkenyon)\
**Replies:** 1\
**Last updated:** [December 11, 2021, 8:34am UTC](https://discourse.processing.org/t/trying-to-make-a-multidimensional-array-which-can-connect-to-my-buttons-please-help-as-soon-as-possible-please/34047 "2021-12-11T08:34:08Z")

</div>

please format code with \</\> button \* homework policy \* asking questions I am trying to make a multidimensional array, storing my array of images on one and states on the left side and storing the images on the right s…

---

## [Merging 2 sketches into 1](https://discourse.processing.org/t/merging-2-sketches-into-1/34051)

<div class="topic-metadata">

**Author:** [@medikid](https://discourse.processing.org/u/medikid)\
**Replies:** 2\
**Last updated:** [December 11, 2021, 3:17pm UTC](https://discourse.processing.org/t/merging-2-sketches-into-1/34051 "2021-12-11T15:17:44Z")

</div>

please format code with \</\> button \* homework policy \* asking questions hi, i have two sketches let scale = 0.004; function setup() { createCanvas(1200, 1200); smooth() } function draw() { for(let x = 100;…

---

## [8 bezier parameters to 12 bezier parameters in 3d](https://discourse.processing.org/t/8-bezier-parameters-to-12-bezier-parameters-in-3d/33595)

<div class="topic-metadata">

**Author:** [@medikid](https://discourse.processing.org/u/medikid)\
**Replies:** 7\
**Last updated:** [December 11, 2021, 3:10pm UTC](https://discourse.processing.org/t/8-bezier-parameters-to-12-bezier-parameters-in-3d/33595 "2021-12-11T15:10:39Z")

</div>

please format code with \</\> button \* homework policy \* asking questions hi, i have old piece of code which i somehow transported to newest processing. it makes piles of bezier curves, circles in this case. from th…

---

## [Please help asap for homework](https://discourse.processing.org/t/please-help-asap-for-homework/34035)

<div class="topic-metadata">

**Author:** [@parichko](https://discourse.processing.org/u/parichko)\
**Replies:** 2\
**Last updated:** [December 11, 2021, 2:26am UTC](https://discourse.processing.org/t/please-help-asap-for-homework/34035 "2021-12-11T02:26:44Z")

</div>

I have a homework till today 12 i need to make a circle change shape when it hits the wall and a circle that bounces of walls

---

## [P\_4\_3\_1\_02 Image](https://discourse.processing.org/t/p-4-3-1-02-image/34039)

<div class="topic-metadata">

**Author:** [@asymmetric](https://discourse.processing.org/u/asymmetric)\
**Replies:** 1\
**Last updated:** [December 10, 2021, 10:14pm UTC](https://discourse.processing.org/t/p-4-3-1-02-image/34039 "2021-12-10T22:14:11Z")

</div>

please format code with \</\> button \* homework policy \* asking questions Hi Processing community! I would like to upload a photograph from my computer to interact with the code that is provided for P\_4\_3\_1\_02. How wo…

---

## [Get HSB-mode saturation of a color constructed in RGB](https://discourse.processing.org/t/get-hsb-mode-saturation-of-a-color-constructed-in-rgb/33674)

<div class="topic-metadata">

**Author:** [@modusponens](https://discourse.processing.org/u/modusponens)\
**Replies:** 6\
**Last updated:** [December 10, 2021, 6:59pm UTC](https://discourse.processing.org/t/get-hsb-mode-saturation-of-a-color-constructed-in-rgb/33674 "2021-12-10T18:59:33Z")

</div>

If I set colorMode(RGB) and create a color c, then get saturation(c), it always gives me the HSL-mode saturation number, which is different from the HSB-mode number. I can’t think of any way to get the HSB-mode saturatio…

---

## [PNG files appear pixelated](https://discourse.processing.org/t/png-files-appear-pixelated/34011)

<div class="topic-metadata">

**Author:** [@guitarguy](https://discourse.processing.org/u/guitarguy)\
**Replies:** 2\
**Last updated:** [December 9, 2021, 9:42pm UTC](https://discourse.processing.org/t/png-files-appear-pixelated/34011 "2021-12-09T21:42:12Z")

</div>

please format code with \</\> button \* homework policy \* asking questions Hello, we are using p5js to render a PNG in a browser. However, the higher the resolution the PNG is, the more pixelated it appears to the viewe…

---

## [Whats wrong with this code i am trying to make the circle bounce of the wall and go back to the starting point](https://discourse.processing.org/t/whats-wrong-with-this-code-i-am-trying-to-make-the-circle-bounce-of-the-wall-and-go-back-to-the-starting-point/33995)

<div class="topic-metadata">

**Author:** [@parichko](https://discourse.processing.org/u/parichko)\
**Replies:** 4\
**Last updated:** [December 9, 2021, 1:50pm UTC](https://discourse.processing.org/t/whats-wrong-with-this-code-i-am-trying-to-make-the-circle-bounce-of-the-wall-and-go-back-to-the-starting-point/33995 "2021-12-09T13:50:44Z")

</div>

let circleX = 0 let circleY = 200 let circleD = 100 function setup() { createCanvas(400, 400); } function draw() { background(220); circle(circleX,circleY,circleD) circleX = circleX + 1 if(circleX == 400){ ci…

---

## [Trying to learn how to make simple buttons in p5js](https://discourse.processing.org/t/trying-to-learn-how-to-make-simple-buttons-in-p5js/34014)

<div class="topic-metadata">

**Author:** [@parichko](https://discourse.processing.org/u/parichko)\
**Replies:** 2\
**Last updated:** [December 9, 2021, 1:50pm UTC](https://discourse.processing.org/t/trying-to-learn-how-to-make-simple-buttons-in-p5js/34014 "2021-12-09T13:50:13Z")

</div>

i am trying to learn how to make a simple button that prints hello in p5js or something else simple but when i tried to do it my self it didn’t work. Can someone just show me the code of a button that prints smth(or anyt…

---

## [\[p5.js\] Is there another way to print to Excel (or pdf)?](https://discourse.processing.org/t/p5-js-is-there-another-way-to-print-to-excel-or-pdf/34007)

<div class="topic-metadata">

**Author:** [@GWAK](https://discourse.processing.org/u/GWAK)\
**Replies:** 2\
**Last updated:** [December 9, 2021, 3:19am UTC](https://discourse.processing.org/t/p5-js-is-there-another-way-to-print-to-excel-or-pdf/34007 "2021-12-09T03:19:53Z")

</div>

You can find out how to print through ‘JS’ (JAVA Script) by searching ‘Google’. excel Export html table data to Excel using JavaScript / JQuery is not working properly in chrome browser - Stack Overflow pdf jspdf -…

---

## [WEBGL context lost error](https://discourse.processing.org/t/webgl-context-lost-error/34005)

<div class="topic-metadata">

**Author:** [@Sap](https://discourse.processing.org/u/Sap)\
**Replies:** 1\
**Last updated:** [December 8, 2021, 10:50pm UTC](https://discourse.processing.org/t/webgl-context-lost-error/34005 "2021-12-08T22:50:41Z")

</div>

Hello, I created a website where I’m using face detection (ml5js), video capture of the webcam, and 3d shapes. I’m using the video as a texture of the 3d shapes. When I’m using only 1 shape everything is okay but when…

---

## [\[p5.js\] When a button is pressed, I want to close the menu bar. Help](https://discourse.processing.org/t/p5-js-when-a-button-is-pressed-i-want-to-close-the-menu-bar-help/33986)

<div class="topic-metadata">

**Author:** [@GWAK](https://discourse.processing.org/u/GWAK)\
**Replies:** 5\
**Last updated:** [December 8, 2021, 1:22am UTC](https://discourse.processing.org/t/p5-js-when-a-button-is-pressed-i-want-to-close-the-menu-bar-help/33986 "2021-12-08T01:22:26Z")

</div>

js file function setup() { } function draw() { } html file \<html\> \<head\> \<meta charset="utf-8"\> \<meta name="viewport" content="width=device-width, initial-scale=1.0"\> \<link rel="stylesheet" href="style…

---

## [If statement with color not working](https://discourse.processing.org/t/if-statement-with-color-not-working/33904)

<div class="topic-metadata">

**Author:** [@MoonAlien822](https://discourse.processing.org/u/MoonAlien822)\
**Replies:** 8\
**Last updated:** [December 7, 2021, 9:00pm UTC](https://discourse.processing.org/t/if-statement-with-color-not-working/33904 "2021-12-07T21:00:44Z")

</div>

why is clicks not getting higher whe I click on the cookie? var clicks = 0; let cookie; function setup() { createCanvas(windowWidth, windowHeight); background(100); cookie = color(132, 86, 60, 255); } function dra…

---

## [Displaying for a certain amount of time](https://discourse.processing.org/t/displaying-for-a-certain-amount-of-time/33926)

<div class="topic-metadata">

**Author:** [@k5221](https://discourse.processing.org/u/k5221)\
**Replies:** 1\
**Last updated:** [December 4, 2021, 9:40pm UTC](https://discourse.processing.org/t/displaying-for-a-certain-amount-of-time/33926 "2021-12-04T21:40:58Z")

</div>

I’m trying to switch between two visuals on the screen (orbitpic(), meltingGlobal() ) every 5 seconds. If I call either of them, it works. After switching inside the if statement, if(millis() - ptime \> 5000), I want to k…

---

## [\[p5.js\] How do you know it's a device? / how to make menubar?](https://discourse.processing.org/t/p5-js-how-do-you-know-its-a-device-how-to-make-menubar/33918)

<div class="topic-metadata">

**Author:** [@GWAK](https://discourse.processing.org/u/GWAK)\
**Replies:** 1\
**Last updated:** [December 4, 2021, 2:32pm UTC](https://discourse.processing.org/t/p5-js-how-do-you-know-its-a-device-how-to-make-menubar/33918 "2021-12-04T14:32:16Z")

</div>

Hello. We would appreciate it if you could let us know if you have any questions. In p5 coding, ‘desktop’, ‘mobile’ How do you know it’s a device? Usually I want to implement a menu bar on the homepage. 2-1) Are…

---

## [Extending a line](https://discourse.processing.org/t/extending-a-line/9880)

<div class="topic-metadata">

**Author:** [@kristofbolyai](https://discourse.processing.org/u/kristofbolyai)\
**Replies:** 9\
**Last updated:** [December 3, 2021, 12:15pm UTC](https://discourse.processing.org/t/extending-a-line/9880 "2021-12-03T12:15:25Z")

</div>

I have a line between two circles and I want to go them to go across the whole screen, but I only have the circle center position This is what I have: https://imgur.com/a/hJQ4mAv I want it to look like this: . PS: …

---

## [P5.js choosing randomly from an array of functions](https://discourse.processing.org/t/p5-js-choosing-randomly-from-an-array-of-functions/33666)

<div class="topic-metadata">

**Author:** [@okkobroderson](https://discourse.processing.org/u/okkobroderson)\
**Replies:** 10\
**Last updated:** [November 24, 2021, 7:09pm UTC](https://discourse.processing.org/t/p5-js-choosing-randomly-from-an-array-of-functions/33666 "2021-11-24T19:09:22Z")

</div>

hi, first post! i have declared an array of functions like funx = \[func1, func2, ...\]; in the draw loop i want to call theese randomly like funx\[random(funx)\](); it works when i call the functions by index like fun…

---

## [Transitioning from scalar to vector](https://discourse.processing.org/t/transitioning-from-scalar-to-vector/33680)

<div class="topic-metadata">

**Author:** [@ADG](https://discourse.processing.org/u/ADG)\
**Replies:** 3\
**Last updated:** [November 23, 2021, 4:25am UTC](https://discourse.processing.org/t/transitioning-from-scalar-to-vector/33680 "2021-11-23T04:25:44Z")

</div>

Hello, I’m trying to rewrite my programs & classes to use vectors. vectors themselves are easy, but going about the operations in p5.js has me getting lost in the syntax. As a simple example I make 2 vectors to create…

---

## [Control the order of returning callbacks](https://discourse.processing.org/t/control-the-order-of-returning-callbacks/33657)

<div class="topic-metadata">

**Author:** [@SMD](https://discourse.processing.org/u/SMD)\
**Replies:** 2\
**Last updated:** [November 22, 2021, 5:55am UTC](https://discourse.processing.org/t/control-the-order-of-returning-callbacks/33657 "2021-11-22T05:55:50Z")

</div>

Hi all I’m trying to load multiple large images (3600x1800) into a p5 sketch. I can’t use preload because there are over 300 of them and memory issues are crashing the browser. Speed isn’t important though so I’m using …

---

## [Check is coordinates are within a shape boundaries](https://discourse.processing.org/t/check-is-coordinates-are-within-a-shape-boundaries/33292)

<div class="topic-metadata">

**Author:** [@zjorge](https://discourse.processing.org/u/zjorge)\
**Replies:** 3\
**Last updated:** [November 21, 2021, 5:56pm UTC](https://discourse.processing.org/t/check-is-coordinates-are-within-a-shape-boundaries/33292 "2021-11-21T17:56:04Z")

</div>

I have previously managed to check or detect if a click is inside a circle or a rectangle. Now I want to fill a shape with dots using Poisson-Disc algorithm. How can I detect if the current dot is within the bounds of …

---

## [OrbitControl embeded conflict with scroll on page](https://discourse.processing.org/t/orbitcontrol-embeded-conflict-with-scroll-on-page/32547)

<div class="topic-metadata">

**Author:** [@Sophie1000](https://discourse.processing.org/u/Sophie1000)\
**Replies:** 2\
**Last updated:** [November 18, 2021, 5:40pm UTC](https://discourse.processing.org/t/orbitcontrol-embeded-conflict-with-scroll-on-page/32547 "2021-11-18T17:40:11Z")

</div>

Hello, I’m working on that project : https://sophie1000.com/F360D/F360D/index.html Each 3D object is in a canvas with OrbitControl, then embedded in iframe. On the global page, there is a horizontal scroll that works …

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

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