# Beginners

**URL:** https://discourse.processing.org/c/p5js/p5js-beginners/16.md?page=3

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

**Page:** 4

---

## [Why is my p5js code is too slow after I upload it](https://discourse.processing.org/t/why-is-my-p5js-code-is-too-slow-after-i-upload-it/39936)

<div class="topic-metadata">

**Author:** [@vrtx](https://discourse.processing.org/u/vrtx)\
**Replies:** 5\
**Last updated:** [December 1, 2022, 1:14pm UTC](https://discourse.processing.org/t/why-is-my-p5js-code-is-too-slow-after-i-upload-it/39936 "2022-12-01T13:14:53Z")

</div>

Hello, i am just learning about these things, processing and p5… I made a sketch on Processing and transfer it to p5.js. What happend is that the resolution of my codes turned too slow, both of them. As o Processing as…

---

## ['Scaling' the canvas?](https://discourse.processing.org/t/scaling-the-canvas/39909)

<div class="topic-metadata">

**Author:** [@PaulR](https://discourse.processing.org/u/PaulR)\
**Replies:** 7\
**Last updated:** [November 29, 2022, 11:06am UTC](https://discourse.processing.org/t/scaling-the-canvas/39909 "2022-11-29T11:06:35Z")

</div>

Hello Is it possible to scale/change the resolution of the canvas in p5.js to create pixel type games? For example, to create a canvas which is 640x640 but will only display 160x160 ‘pixels’ (each being 4x4 actual pixel…

---

## [Canvas2D: Multiple readback operations](https://discourse.processing.org/t/canvas2d-multiple-readback-operations/39804)

<div class="topic-metadata">

**Author:** [@mattobject](https://discourse.processing.org/u/mattobject)\
**Replies:** 2\
**Last updated:** [November 20, 2022, 10:53pm UTC](https://discourse.processing.org/t/canvas2d-multiple-readback-operations/39804 "2022-11-20T22:53:20Z")

</div>

I’ve noticed in the past few months a new warning in the console when a sketch loads image files: p5.js:80807 Canvas2D: Multiple readback operations using getImageData are faster with the willReadFrequently attribute set…

---

## [How to create a 3D star?](https://discourse.processing.org/t/how-to-create-a-3d-star/39754)

<div class="topic-metadata">

**Author:** [@timob256](https://discourse.processing.org/u/timob256)\
**Replies:** 10\
**Last updated:** [November 19, 2022, 6:28pm UTC](https://discourse.processing.org/t/how-to-create-a-3d-star/39754 "2022-11-19T18:28:06Z")

</div>

please format code with \</\> button \* homework policy \* asking questions I trying create 3d star but this not good wraiting cone :disappointed: // звезда 3д модель function zvezda ( per\_x, per\_y, per\_z) { …

---

## [How to get 'get()' working on image created by 'createImg()'?](https://discourse.processing.org/t/how-to-get-get-working-on-image-created-by-createimg/39701)

<div class="topic-metadata">

**Author:** [@kkouch](https://discourse.processing.org/u/kkouch)\
**Replies:** 2\
**Last updated:** [November 15, 2022, 7:10am UTC](https://discourse.processing.org/t/how-to-get-get-working-on-image-created-by-createimg/39701 "2022-11-15T07:10:43Z")

</div>

Hello. I’m currently making a program where I need to get a section of an image and save it to a given variable. The problem is that ‘get()’ only works on p5.Image objects and when I try to use it on an image created by …

---

## [\[P5\] Is there a default font provided by WEB?](https://discourse.processing.org/t/p5-is-there-a-default-font-provided-by-web/39668)

<div class="topic-metadata">

**Author:** [@GWAK](https://discourse.processing.org/u/GWAK)\
**Replies:** 4\
**Last updated:** [November 13, 2022, 3:40am UTC](https://discourse.processing.org/t/p5-is-there-a-default-font-provided-by-web/39668 "2022-11-13T03:40:53Z")

</div>

\[P5\] Is there a default font provided by WEB? In ‘Processing-P5’, you can load a font with ‘loadFont’. Example source code: let myFont; function preload() { myFont = loadFont('assets/inconsolata.otf'); } H…

---

## [Random() vs. Math.random() in p5js](https://discourse.processing.org/t/random-vs-math-random-in-p5js/39660)

<div class="topic-metadata">

**Author:** [@rkotty](https://discourse.processing.org/u/rkotty)\
**Replies:** 2\
**Last updated:** [November 10, 2022, 3:24pm UTC](https://discourse.processing.org/t/random-vs-math-random-in-p5js/39660 "2022-11-10T15:24:52Z")

</div>

I wanted to create global random variables, but when I used random() outside of all the functions, random() was not recognized. A student Googled that I needed to use Math.random() in this case. Why is that?

---

## [My account web editor on P5js is safe for security?](https://discourse.processing.org/t/my-account-web-editor-on-p5js-is-safe-for-security/39599)

<div class="topic-metadata">

**Author:** [@wonwoo](https://discourse.processing.org/u/wonwoo)\
**Replies:** 1\
**Last updated:** [November 7, 2022, 8:44am UTC](https://discourse.processing.org/t/my-account-web-editor-on-p5js-is-safe-for-security/39599 "2022-11-07T08:44:09Z")

</div>

Hi, All. If I upload an image to my account web editor on P5js, is it safe for security? Maybe someone else can see it or use it without permission, right? Thanks. Best, @bemoregt.

---

## [Why background('rgba(0,255,0, 0.25)') inoperative？](https://discourse.processing.org/t/why-background-rgba-0-255-0-0-25-inoperative/39517)

<div class="topic-metadata">

**Author:** [@guanzhuyu](https://discourse.processing.org/u/guanzhuyu)\
**Replies:** 1\
**Last updated:** [October 31, 2022, 8:46am UTC](https://discourse.processing.org/t/why-background-rgba-0-255-0-0-25-inoperative/39517 "2022-10-31T08:46:03Z")

</div>

hello i us background(‘rgba(0,255,0, 0.25)’) in my code,but the Alpha inoperative? the browser is chrome (107.0.5304.88) background(‘rgba(0,255,0, 0.25)’);

---

## [Different results with the same code on a computer and a smartphone (with used loadPixels())](https://discourse.processing.org/t/different-results-with-the-same-code-on-a-computer-and-a-smartphone-with-used-loadpixels/39346)

<div class="topic-metadata">

**Author:** [@Nik](https://discourse.processing.org/u/Nik)\
**Replies:** 4\
**Last updated:** [October 26, 2022, 6:15pm UTC](https://discourse.processing.org/t/different-results-with-the-same-code-on-a-computer-and-a-smartphone-with-used-loadpixels/39346 "2022-10-26T18:15:12Z")

</div>

Hello. Different results are obtained with the same code on a computer(windows 10) and a smartphone(android) with used loadPixels(). Below is an example code and screenshots. /////////////////////////////////// function…

---

## [Why Are My Class Variables Not Working? \[SOLVED\]](https://discourse.processing.org/t/why-are-my-class-variables-not-working-solved/39401)

<div class="topic-metadata">

**Author:** [@bcgreen24](https://discourse.processing.org/u/bcgreen24)\
**Replies:** 3\
**Last updated:** [October 23, 2022, 8:13pm UTC](https://discourse.processing.org/t/why-are-my-class-variables-not-working-solved/39401 "2022-10-23T20:13:14Z")

</div>

I was having issues with a sketch I was working on, so I created this little test to try and narrow down the issue-- which is that this.x and this.y are both undefined, even though the Walker class has a constructor whic…

---

## [Meta get Attribute problem (solved)](https://discourse.processing.org/t/meta-get-attribute-problem-solved/39355)

<div class="topic-metadata">

**Author:** [@Tasp](https://discourse.processing.org/u/Tasp)\
**Replies:** 0\
**Last updated:** [October 19, 2022, 8:19am UTC](https://discourse.processing.org/t/meta-get-attribute-problem-solved/39355 "2022-10-19T08:19:18Z")

</div>

Edit: problem was the pixel density setting set to 3 or something creating a canvas being too large. Hi there. I’m creating right now a presentation to be run on iPads and used then in a Salesforce-Veeva system, and I’…

---

## [Use button.mouseOver inside a class](https://discourse.processing.org/t/use-button-mouseover-inside-a-class/39236)

<div class="topic-metadata">

**Author:** [@vkbr](https://discourse.processing.org/u/vkbr)\
**Replies:** 3\
**Last updated:** [October 13, 2022, 12:14am UTC](https://discourse.processing.org/t/use-button-mouseover-inside-a-class/39236 "2022-10-13T00:14:14Z")

</div>

Hello. I’, trying to wrap a p5 button in a class to make a different look. But I can’t make the listener to work, I think is a scope problem with my callback function atempt. Easy to understand by looking at the code. …

---

## [Intersection of two rectangles](https://discourse.processing.org/t/intersection-of-two-rectangles/39212)

<div class="topic-metadata">

**Author:** [@Shachar](https://discourse.processing.org/u/Shachar)\
**Replies:** 2\
**Last updated:** [October 11, 2022, 12:06pm UTC](https://discourse.processing.org/t/intersection-of-two-rectangles/39212 "2022-10-11T12:06:31Z")

</div>

Hi everyone! I’ve tried to create a rectangle class and check if two rectangles intersect. Their x and y values represent the centers. My intersection condition looks like this: r1.x+r1.w/2 \< r2.x-r2.w/2 || r2.x+r2.w/…

---

## [Using Images From URLs](https://discourse.processing.org/t/using-images-from-urls/39191)

<div class="topic-metadata">

**Author:** [@s31](https://discourse.processing.org/u/s31)\
**Replies:** 4\
**Last updated:** [October 10, 2022, 10:27am UTC](https://discourse.processing.org/t/using-images-from-urls/39191 "2022-10-10T10:27:04Z")

</div>

Hi, if you would ever be so inclined, could someone please show me the correct way to load images using a url as the path. It accepts urls and returns this error so i do not know what i am doing wrong. TypeError: Faile…

---

## [Making a setter in js](https://discourse.processing.org/t/making-a-setter-in-js/39186)

<div class="topic-metadata">

**Author:** [@vkbr](https://discourse.processing.org/u/vkbr)\
**Replies:** 5\
**Last updated:** [October 10, 2022, 2:14am UTC](https://discourse.processing.org/t/making-a-setter-in-js/39186 "2022-10-10T02:14:16Z")

</div>

Hello. I’m struggling with some simple stuff. I think… I have my object, an instance of a class. I’m trying to make one set() function that would get a indefined number of args, based on that I’d like to change some pr…

---

## [Questions on how p5.js generates random numbers](https://discourse.processing.org/t/questions-on-how-p5-js-generates-random-numbers/39128)

<div class="topic-metadata">

**Author:** [@reacttoimpact](https://discourse.processing.org/u/reacttoimpact)\
**Replies:** 1\
**Last updated:** [October 7, 2022, 10:00am UTC](https://discourse.processing.org/t/questions-on-how-p5-js-generates-random-numbers/39128 "2022-10-07T10:00:26Z")

</div>

Hi all, How does p5.js generate random numbers? What type of PRNG does it use? Does it use javascripts random function? If so how does that work? Where is the code that generates random numbers? is there anything in…

---

## [Why rotateX function not working](https://discourse.processing.org/t/why-rotatex-function-not-working/39097)

<div class="topic-metadata">

**Author:** [@timob256](https://discourse.processing.org/u/timob256)\
**Replies:** 2\
**Last updated:** [October 5, 2022, 3:53pm UTC](https://discourse.processing.org/t/why-rotatex-function-not-working/39097 "2022-10-05T15:53:09Z")

</div>

I call rotateX, but for some reason it does not work. All code : function setup() { createCanvas( 200, 200, WEBGL); angle = 0.0; // так тоже работает \_angle = 0 my\_point\_size = 20; my\_layer = 170; } f…

---

## [How to get the sketch title (or tab title) from within a sketch?](https://discourse.processing.org/t/how-to-get-the-sketch-title-or-tab-title-from-within-a-sketch/39057)

<div class="topic-metadata">

**Author:** [@paulwb](https://discourse.processing.org/u/paulwb)\
**Replies:** 1\
**Last updated:** [October 4, 2022, 8:06am UTC](https://discourse.processing.org/t/how-to-get-the-sketch-title-or-tab-title-from-within-a-sketch/39057 "2022-10-04T08:06:40Z")

</div>

I want to uniquely name the images I save from my sketch, so I can figure out what particular p5js sketch made what image. To do this, I need to determine the sketch name from within the sketch. I don’t want to type the…

---

## [Reproduce this with vector math... or not? - solved :)](https://discourse.processing.org/t/reproduce-this-with-vector-math-or-not-solved/38997)

<div class="topic-metadata">

**Author:** [@vkbr](https://discourse.processing.org/u/vkbr)\
**Replies:** 1\
**Last updated:** [September 27, 2022, 10:33pm UTC](https://discourse.processing.org/t/reproduce-this-with-vector-math-or-not-solved/38997 "2022-09-27T22:33:30Z")

</div>

Hello. I’m using scalar math to keep track of points relations to one another. It’s fine. I’m bad at vector math, but it looks to me that this would be really easier and cleaner using vectors. They are already all aroun…

---

## [Pixel array length unexpected](https://discourse.processing.org/t/pixel-array-length-unexpected/38963)

<div class="topic-metadata">

**Author:** [@Yra](https://discourse.processing.org/u/Yra)\
**Replies:** 7\
**Last updated:** [September 28, 2022, 12:26am UTC](https://discourse.processing.org/t/pixel-array-length-unexpected/38963 "2022-09-28T00:26:00Z")

</div>

Hello everybody! :slight\_smile: I’m currently having some unexpected problems with the pixels array. I have a canvas of 600x300, so I expect the array length to be 600x300x4=720 000. Instead if I log it I get 4 times …

---

## [Simple js arrow funtion and ternary operator question](https://discourse.processing.org/t/simple-js-arrow-funtion-and-ternary-operator-question/38993)

<div class="topic-metadata">

**Author:** [@vkbr](https://discourse.processing.org/u/vkbr)\
**Replies:** 4\
**Last updated:** [September 27, 2022, 6:18pm UTC](https://discourse.processing.org/t/simple-js-arrow-funtion-and-ternary-operator-question/38993 "2022-09-27T18:18:11Z")

</div>

What I’m doing wrong with my atempt to use an arrow function here? function setup() { createCanvas(400, 400); const x = 0; const y = 10; const t1 = x \> y ? x : () =\> console.log("nono from arrow"); const t2 = …

---

## [Javascript class - class instance variables declaration](https://discourse.processing.org/t/javascript-class-class-instance-variables-declaration/38936)

<div class="topic-metadata">

**Author:** [@vkbr](https://discourse.processing.org/u/vkbr)\
**Replies:** 2\
**Last updated:** [September 22, 2022, 11:55pm UTC](https://discourse.processing.org/t/javascript-class-class-instance-variables-declaration/38936 "2022-09-22T23:55:05Z")

</div>

In Java I could: class Stuff{ //a instance var not got trough constructor color c = color(0,0,0); Stuff(float \_x){ float x = \_x; } } in js, instance vars need all to be inside the constructo…

---

## [Javascript classes, but more a design question](https://discourse.processing.org/t/javascript-classes-but-more-a-design-question/38848)

<div class="topic-metadata">

**Author:** [@vkbr](https://discourse.processing.org/u/vkbr)\
**Replies:** 7\
**Last updated:** [September 19, 2022, 2:17pm UTC](https://discourse.processing.org/t/javascript-classes-but-more-a-design-question/38848 "2022-09-19T14:17:54Z")

</div>

Trying to figure out a design for this: I have a class Grid. I want to make points relative to a Grid instance (there will be only one instance of Grid). Relative means the point coordinates will change accordingly to …

---

## [Does loadStrings() load from the Browser cache?](https://discourse.processing.org/t/does-loadstrings-load-from-the-browser-cache/38700)

<div class="topic-metadata">

**Author:** [@Jan](https://discourse.processing.org/u/Jan)\
**Replies:** 2\
**Last updated:** [September 12, 2022, 1:25pm UTC](https://discourse.processing.org/t/does-loadstrings-load-from-the-browser-cache/38700 "2022-09-12T13:25:37Z")

</div>

Hello everyone, this is happening to me: I’m loading a txt file (only one line) once every 10 seconds with loadStrings() Works. Loaded it already a hundred times. Then the txt file on the server has changed. But loadS…

---

## [Adjust the text height of a radio button](https://discourse.processing.org/t/adjust-the-text-height-of-a-radio-button/38682)

<div class="topic-metadata">

**Author:** [@Sunt](https://discourse.processing.org/u/Sunt)\
**Replies:** 2\
**Last updated:** [September 8, 2022, 2:36pm UTC](https://discourse.processing.org/t/adjust-the-text-height-of-a-radio-button/38682 "2022-09-08T14:36:43Z")

</div>

Hi. I’m trying to align the text of a radio button. Without setting a specific font size, it is acceptable; but with smaller fonts, the text position will be lower. Is there a solution for that? function setup() { cr…

---

## [How to create a clean iframe](https://discourse.processing.org/t/how-to-create-a-clean-iframe/33753)

<div class="topic-metadata">

**Author:** [@sansonsan](https://discourse.processing.org/u/sansonsan)\
**Replies:** 12\
**Last updated:** [August 29, 2022, 8:38am UTC](https://discourse.processing.org/t/how-to-create-a-clean-iframe/33753 "2022-08-29T08:38:55Z")

</div>

Hello, I made a small code with p5js and I want to insert it with an iframe on my webpage. \<iframe frameborder="0"style="height: 300px; width: 300px; margin: 0 auto; display: block;" src="https://editor.p5js.org/sanson…

---

## [Combining matrix functions with applyMatrix()](https://discourse.processing.org/t/combining-matrix-functions-with-applymatrix/38475)

<div class="topic-metadata">

**Author:** [@Sunt](https://discourse.processing.org/u/Sunt)\
**Replies:** 2\
**Last updated:** [August 25, 2022, 2:31pm UTC](https://discourse.processing.org/t/combining-matrix-functions-with-applymatrix/38475 "2022-08-25T14:31:09Z")

</div>

Hi. In this code I have a rotating rectangle in the center of the canvas using the applyMatrix() function. In the reference it’s said that I can combine these functions into one. This is a powerful operation that can …

---

## [Checkbox style size](https://discourse.processing.org/t/checkbox-style-size/38406)

<div class="topic-metadata">

**Author:** [@Sunt](https://discourse.processing.org/u/Sunt)\
**Replies:** 2\
**Last updated:** [August 18, 2022, 1:18pm UTC](https://discourse.processing.org/t/checkbox-style-size/38406 "2022-08-18T13:18:51Z")

</div>

Hi, I am trying to change the size of the checkbox. The font size property works but not the box size. Thanks in advance. checkbox = createCheckbox('label', true); checkbox.style("font-size", '46px'); checkbox.s…

---

## [Programmatically uncheck a check box](https://discourse.processing.org/t/programmatically-uncheck-a-check-box/38393)

<div class="topic-metadata">

**Author:** [@Sunt](https://discourse.processing.org/u/Sunt)\
**Replies:** 3\
**Last updated:** [August 17, 2022, 4:39pm UTC](https://discourse.processing.org/t/programmatically-uncheck-a-check-box/38393 "2022-08-17T16:39:36Z")

</div>

Hi. How can I programmatically uncheck a check box.? I’ve searched and tried a lot of things like checkbox.elt.disabled = false; But nothing works. Thanks in advance.

[Previous page](https://discourse.processing.org/c/p5js/p5js-beginners/16.md?page=2)

[Next page](https://discourse.processing.org/c/p5js/p5js-beginners/16.md?page=4)
