# p5.js

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

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

**Page:** 19

---

## [Weird jump using \`textAscent() and \`textDescent()\`](https://discourse.processing.org/t/weird-jump-using-textascent-and-textdescent/39308)

<div class="topic-metadata">

**Author:** [@vkbr](https://discourse.processing.org/u/vkbr)\
**Replies:** 4\
**Last updated:** [October 17, 2022, 10:37pm UTC](https://discourse.processing.org/t/weird-jump-using-textascent-and-textdescent/39308 "2022-10-17T22:37:38Z")

</div>

From the example of textAscent() in reference I built a littel test. Actually i was going to ask a different question, but then I find a wierd behavior that I can not understand: There is a jump in values of textAscent …

---

## [ImageData scaling/size issue](https://discourse.processing.org/t/imagedata-scaling-size-issue/39314)

<div class="topic-metadata">

**Author:** [@Pieter](https://discourse.processing.org/u/Pieter)\
**Replies:** 1\
**Last updated:** [October 17, 2022, 6:24pm UTC](https://discourse.processing.org/t/imagedata-scaling-size-issue/39314 "2022-10-17T18:24:10Z")

</div>

I’m trying to make a simple pixel drawing utility, this is easy enough to emulate using rect() calls, but I want to edit the pixel data directly. The problem seems to be that for some reason my calls to drawingContext.pu…

---

## [Windowing Function on Real time fake signal with customizable overappling window?](https://discourse.processing.org/t/windowing-function-on-real-time-fake-signal-with-customizable-overappling-window/39323)

<div class="topic-metadata">

**Author:** [@black](https://discourse.processing.org/u/black)\
**Replies:** 0\
**Last updated:** [October 17, 2022, 4:22pm UTC](https://discourse.processing.org/t/windowing-function-on-real-time-fake-signal-with-customizable-overappling-window/39323 "2022-10-17T16:22:04Z")

</div>

I was trying to create a sliding window on a signal. I have implemented the windowing function on a precalculated data from a csv file but when I was trying to do the same for a real time data where we dont have data ava…

---

## [Use shader with another createCanvas](https://discourse.processing.org/t/use-shader-with-another-createcanvas/39280)

<div class="topic-metadata">

**Author:** [@Omri](https://discourse.processing.org/u/Omri)\
**Replies:** 2\
**Last updated:** [October 15, 2022, 4:27pm UTC](https://discourse.processing.org/t/use-shader-with-another-createcanvas/39280 "2022-10-15T16:27:15Z")

</div>

hey, I’m doing a sketch with shaders inside a p5. I have 3 p5.Renderer object using createGraphics. the first one is the “screen” that I’m painting on, and the others are ‘currentFrame’ & ‘lastFrame’ which I’m trying to…

---

## [Contribution guide for a Student Frontend Developer](https://discourse.processing.org/t/contribution-guide-for-a-student-frontend-developer/39114)

<div class="topic-metadata">

**Author:** [@Jayaditya](https://discourse.processing.org/u/Jayaditya)\
**Replies:** 1\
**Last updated:** [October 13, 2022, 3:00pm UTC](https://discourse.processing.org/t/contribution-guide-for-a-student-frontend-developer/39114 "2022-10-13T15:00:33Z")

</div>

Hello Sir / Madam, My name is Jayaditya and currently pursuing my B.tech 2nd year CS Major in India. Recently I am enrolled in a Udemy Course to Learn Web development , I have completed the most part on Frontend deve…

---

## [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. …

---

## [Why colors look different in different browsers?](https://discourse.processing.org/t/why-colors-look-different-in-different-browsers/39219)

<div class="topic-metadata">

**Author:** [@Nik](https://discourse.processing.org/u/Nik)\
**Replies:** 3\
**Last updated:** [October 12, 2022, 5:24pm UTC](https://discourse.processing.org/t/why-colors-look-different-in-different-browsers/39219 "2022-10-12T17:24:16Z")

</div>

Hello! I noticed that the colors in different browsers are different. Below is a simple example with code and explanations: //////////////////// function setup() { createCanvas(1000, 1000); background(255); fill(255);…

---

## [touchStarted on Safari Iphone](https://discourse.processing.org/t/touchstarted-on-safari-iphone/39221)

<div class="topic-metadata">

**Author:** [@jaimico](https://discourse.processing.org/u/jaimico)\
**Replies:** 2\
**Last updated:** [October 12, 2022, 12:28am UTC](https://discourse.processing.org/t/touchstarted-on-safari-iphone/39221 "2022-10-12T00:28:34Z")

</div>

Hello, I am preparing an exhibition of my students’ projects, from the Share option, like this In a computer web browser it works, but it doesn’t work when opening the code in iphone safari. How can I make it work i…

---

## [Coding Sun, Moon and Earth realistically](https://discourse.processing.org/t/coding-sun-moon-and-earth-realistically/38008)

<div class="topic-metadata">

**Author:** [@Beppo](https://discourse.processing.org/u/Beppo)\
**Replies:** 5\
**Last updated:** [October 11, 2022, 3:00pm UTC](https://discourse.processing.org/t/coding-sun-moon-and-earth-realistically/38008 "2022-10-11T15:00:21Z")

</div>

Hello, for a scool project I have to code the in the reality existing system containing sun, moon and earth as realistically as possible. In my opinion the three bodies should move witch my current code as they do in rea…

---

## [Optimization question about WEBGL](https://discourse.processing.org/t/optimization-question-about-webgl/39196)

<div class="topic-metadata">

**Author:** [@Omri](https://discourse.processing.org/u/Omri)\
**Replies:** 2\
**Last updated:** [October 11, 2022, 12:12pm UTC](https://discourse.processing.org/t/optimization-question-about-webgl/39196 "2022-10-11T12:12:10Z")

</div>

Hey, I’m doing an interactive project and I need it to be as fast as possible without delay or lags. As part of the project, I have a video (let’s say from the webcam) on part of the canvas, and on top of the video I dr…

---

## [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…

---

## [How to implement ctrl+Z to undo in a custom p5.js drawing program?](https://discourse.processing.org/t/how-to-implement-ctrl-z-to-undo-in-a-custom-p5-js-drawing-program/23703)

<div class="topic-metadata">

**Author:** [@gquevedoe2505](https://discourse.processing.org/u/gquevedoe2505)\
**Replies:** 16\
**Last updated:** [October 8, 2022, 9:09pm UTC](https://discourse.processing.org/t/how-to-implement-ctrl-z-to-undo-in-a-custom-p5-js-drawing-program/23703 "2022-10-08T21:09:25Z")

</div>

Hi I need help with the question…

---

## [Newb Question: Saving to PDF](https://discourse.processing.org/t/newb-question-saving-to-pdf/39123)

<div class="topic-metadata">

**Author:** [@Tatcoddes](https://discourse.processing.org/u/Tatcoddes)\
**Replies:** 6\
**Last updated:** [October 8, 2022, 6:00pm UTC](https://discourse.processing.org/t/newb-question-saving-to-pdf/39123 "2022-10-08T18:00:05Z")

</div>

I am trying to save my sketches to PDF. The most commonly mentioned way of doing this is to use this: https://github.com/zenozeng/p5.js-pdf but I am testing it with one of his simple example codes and it just loads a b…

---

## [P5 code into Java + help in understanding (artwork)](https://discourse.processing.org/t/p5-code-into-java-help-in-understanding-artwork/39145)

<div class="topic-metadata">

**Author:** [@Hanna](https://discourse.processing.org/u/Hanna)\
**Replies:** 10\
**Last updated:** [October 8, 2022, 1:25pm UTC](https://discourse.processing.org/t/p5-code-into-java-help-in-understanding-artwork/39145 "2022-10-08T13:25:40Z")

</div>

Hi everyone, for a project I am trying to implement a movement similar to this example in my code.: Shark - OpenProcessing Unfortunately, the code is written in P5 and I work in Java. Can someone help me to rewrite the…

---

## [How to generate points/ellipse within a circle area](https://discourse.processing.org/t/how-to-generate-points-ellipse-within-a-circle-area/20933)

<div class="topic-metadata">

**Author:** [@yuinjann](https://discourse.processing.org/u/yuinjann)\
**Replies:** 3\
**Last updated:** [May 17, 2020, 6:10pm UTC](https://discourse.processing.org/t/how-to-generate-points-ellipse-within-a-circle-area/20933 "2020-05-17T18:10:59Z")

</div>

Hello! I’m trying to generate ellipses within an ellipse, or a circular area. for example: for (let i=0; i\< 100; i++){ ellipse (random(width), random(height), 10) } noLoop(); Is there a way to generate these random ci…

---

## [P5 code into Java code](https://discourse.processing.org/t/p5-code-into-java-code/39141)

<div class="topic-metadata">

**Author:** [@Hanna](https://discourse.processing.org/u/Hanna)\
**Replies:** 10\
**Last updated:** [October 7, 2022, 4:48pm UTC](https://discourse.processing.org/t/p5-code-into-java-code/39141 "2022-10-07T16:48:54Z")

</div>

Hello everyone, I am getting into programming and processing and am finding it difficult to adapt code written for “p5” into “Java”. Can anyone possibly help me how to convert this code for sand into a java code? Kind …

---

## [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…

---

## [Use of for-loop to create a stair of ellipses](https://discourse.processing.org/t/use-of-for-loop-to-create-a-stair-of-ellipses/26271)

<div class="topic-metadata">

**Author:** [@Jayda](https://discourse.processing.org/u/Jayda)\
**Replies:** 51\
**Last updated:** [October 7, 2022, 3:18am UTC](https://discourse.processing.org/t/use-of-for-loop-to-create-a-stair-of-ellipses/26271 "2022-10-07T03:18:41Z")

</div>

Do someone know how to create the pattern with loops?

---

## [Please Delete - resolved](https://discourse.processing.org/t/please-delete-resolved/39106)

<div class="topic-metadata">

**Author:** [@Tatcoddes](https://discourse.processing.org/u/Tatcoddes)\
**Replies:** 0\
**Last updated:** [October 5, 2022, 8:08pm UTC](https://discourse.processing.org/t/please-delete-resolved/39106 "2022-10-05T20:08:22Z")

</div>

Resolved via re-installing … please Delete

---

## [Help with specific Vector Addition](https://discourse.processing.org/t/help-with-specific-vector-addition/39050)

<div class="topic-metadata">

**Author:** [@Tilman](https://discourse.processing.org/u/Tilman)\
**Replies:** 6\
**Last updated:** [October 5, 2022, 7:06pm UTC](https://discourse.processing.org/t/help-with-specific-vector-addition/39050 "2022-10-05T19:06:48Z")

</div>

Hi, I have a sketch where a mover moves along a sinusoidal path. From that mover two vectors emerge. Vector A rotating in the direction of the path. Vector B pointing at a position at the bottom center of the canvas. …

---

## [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…

---

## [Flipping book page effect on text](https://discourse.processing.org/t/flipping-book-page-effect-on-text/39059)

<div class="topic-metadata">

**Author:** [@fijthecreator](https://discourse.processing.org/u/fijthecreator)\
**Replies:** 2\
**Last updated:** [October 4, 2022, 12:25pm UTC](https://discourse.processing.org/t/flipping-book-page-effect-on-text/39059 "2022-10-04T12:25:36Z")

</div>

Hi Community, as I have already opened up a discussion about a separate project I am curious about the possibility to recreate this effect: 3d Shape fill connects to first vertex on P5.js webGL - Stack Overflow in p5.js. …

---

## [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…

---

## [Post can be deleted sorry!](https://discourse.processing.org/t/post-can-be-deleted-sorry/39047)

<div class="topic-metadata">

**Author:** [@Tilman](https://discourse.processing.org/u/Tilman)\
**Replies:** 0\
**Last updated:** [October 2, 2022, 5:22pm UTC](https://discourse.processing.org/t/post-can-be-deleted-sorry/39047 "2022-10-02T17:22:40Z")

</div>

please delete this post . thank you!

---

## [Need Help With keyTyped in P5](https://discourse.processing.org/t/need-help-with-keytyped-in-p5/39006)

<div class="topic-metadata">

**Author:** [@killacam](https://discourse.processing.org/u/killacam)\
**Replies:** 1\
**Last updated:** [September 28, 2022, 7:47pm UTC](https://discourse.processing.org/t/need-help-with-keytyped-in-p5/39006 "2022-09-28T19:47:28Z")

</div>

Hi! I’m having an issue with my code. I’m making a dress up game and her hair and outfits are supposed to change whenever you press a key, but it’s not working! Here’s the code: let dg1; let dghair1; let dghair2; le…

---

## [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 = …

[Previous page](https://discourse.processing.org/c/p5js/10.md?page=17)

[Next page](https://discourse.processing.org/c/p5js/10.md?page=19)
