# Coding Questions

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

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

**Page:** 8

---

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

---

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

---

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

---

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

---

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

---

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

---

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

---

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

---

## [Simplified my question: Array - 2 movers from circle border should move through circle center but they move parallel](https://discourse.processing.org/t/simplified-my-question-array-2-movers-from-circle-border-should-move-through-circle-center-but-they-move-parallel/38960)

<div class="topic-metadata">

**Author:** [@Tilman](https://discourse.processing.org/u/Tilman)\
**Replies:** 3\
**Last updated:** [September 25, 2022, 3:26pm UTC](https://discourse.processing.org/t/simplified-my-question-array-2-movers-from-circle-border-should-move-through-circle-center-but-they-move-parallel/38960 "2022-09-25T15:26:26Z")

</div>

I posted this before but made the code simpler so I can explain my problem. When I call two individual movers it works but as soon as I use an array not: I have a circle and with an array define two points on that circl…

---

## [\[p5\] cycle of work order](https://discourse.processing.org/t/p5-cycle-of-work-order/38955)

<div class="topic-metadata">

**Author:** [@GWAK](https://discourse.processing.org/u/GWAK)\
**Replies:** 5\
**Last updated:** [September 24, 2022, 7:29am UTC](https://discourse.processing.org/t/p5-cycle-of-work-order/38955 "2022-09-24T07:29:01Z")

</div>

\[p5\] cycle of work order In ‘p5’, ‘preload()’ function is provided to prepare in advance. However, there are cases where priority is needed even within the ‘preload()’ function. So, the order was given through t…

---

## [Loading screen with preload](https://discourse.processing.org/t/loading-screen-with-preload/38917)

<div class="topic-metadata">

**Author:** [@Omri](https://discourse.processing.org/u/Omri)\
**Replies:** 16\
**Last updated:** [September 22, 2022, 3:44pm UTC](https://discourse.processing.org/t/loading-screen-with-preload/38917 "2022-09-22T15:44:19Z")

</div>

Hi all, I’m using the function preload in my p5 project, because of that I have a couple of seconds of a white page at the beginning, so I want to create a loading screen. I tried to do the following here: and instead…

---

## [Help with createSelect() using array](https://discourse.processing.org/t/help-with-createselect-using-array/38822)

<div class="topic-metadata">

**Author:** [@zara2355](https://discourse.processing.org/u/zara2355)\
**Replies:** 12\
**Last updated:** [September 22, 2022, 6:49am UTC](https://discourse.processing.org/t/help-with-createselect-using-array/38822 "2022-09-22T06:49:07Z")

</div>

Hi all, I was hoping to get some advice on how to use createSelect() a little better. im trying to incorporate a dropdown to use with an autosuggest in my sketch. I sort of have it working, but instead of listing each it…

---

## [Pass Slider value into a class](https://discourse.processing.org/t/pass-slider-value-into-a-class/38668)

<div class="topic-metadata">

**Author:** [@Tilman](https://discourse.processing.org/u/Tilman)\
**Replies:** 19\
**Last updated:** [September 22, 2022, 6:34am UTC](https://discourse.processing.org/t/pass-slider-value-into-a-class/38668 "2022-09-22T06:34:17Z")

</div>

I am doing the NOC 5.3 Steering Behaviour coding challenge and try to map certain values like: maxSpeed, maxForce, and slowRadius to sliders. I also watched the slider tutorials by dan but struggle to implement this corr…

---

## [Help with javascript \`this\` keyword and \`bind\`](https://discourse.processing.org/t/help-with-javascript-this-keyword-and-bind/38897)

<div class="topic-metadata">

**Author:** [@vkbr](https://discourse.processing.org/u/vkbr)\
**Replies:** 11\
**Last updated:** [September 21, 2022, 2:34pm UTC](https://discourse.processing.org/t/help-with-javascript-this-keyword-and-bind/38897 "2022-09-21T14:34:59Z")

</div>

It’s a bit of a follow up of this question but no need to read back. As that one is marked solved, I’m starting a new topic. Not pasting the whole code, but making a pseudo example here to isolate the issue. I cooked …

---

## [Low video quality using createVideo](https://discourse.processing.org/t/low-video-quality-using-createvideo/38912)

<div class="topic-metadata">

**Author:** [@Omri](https://discourse.processing.org/u/Omri)\
**Replies:** 5\
**Last updated:** [September 21, 2022, 2:19pm UTC](https://discourse.processing.org/t/low-video-quality-using-createvideo/38912 "2022-09-21T14:19:52Z")

</div>

hey, I have a video.mp4 on my computer and I want to load it to a p5 sketch. this is the code: let pause\_vid = true; function preload() { vid = createVideo("video.mp4"); } function setup() { createCanvas(window.inn…

---

## [Calculate specific angle between velocity.heading and p5.Vector](https://discourse.processing.org/t/calculate-specific-angle-between-velocity-heading-and-p5-vector/38882)

<div class="topic-metadata">

**Author:** [@Tilman](https://discourse.processing.org/u/Tilman)\
**Replies:** 2\
**Last updated:** [September 21, 2022, 9:12am UTC](https://discourse.processing.org/t/calculate-specific-angle-between-velocity-heading-and-p5-vector/38882 "2022-09-21T09:12:10Z")

</div>

Hi, I know how to calculate an angle between two vectors and did this. But in this example (derived from the NOC steering behavior tutorial) I did calculate the angle from the vehicle to the center of the canvas(grey ci…

---

## [P5.js input text](https://discourse.processing.org/t/p5-js-input-text/38887)

<div class="topic-metadata">

**Author:** [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Replies:** 4\
**Last updated:** [September 20, 2022, 9:57pm UTC](https://discourse.processing.org/t/p5-js-input-text/38887 "2022-09-20T21:57:02Z")

</div>

Hello all, I have 2 questions about text input. a) I am looking for a text field where suggestions of what you going to type appear underneath your text. Similar to when you use save as and type an existing file name …

---

## [Set attractor/repeller corresponding to mouse pressed LEFT/RIGHT](https://discourse.processing.org/t/set-attractor-repeller-corresponding-to-mouse-pressed-left-right/38862)

<div class="topic-metadata">

**Author:** [@Tilman](https://discourse.processing.org/u/Tilman)\
**Replies:** 1\
**Last updated:** [September 19, 2022, 7:39pm UTC](https://discourse.processing.org/t/set-attractor-repeller-corresponding-to-mouse-pressed-left-right/38862 "2022-09-19T19:39:11Z")

</div>

Hi am trying to modify the “Attraction and Repulsion Forces” NOC tutorial code and set either an attractor or repeller on mouse LEFT(attractor) or RIGHT(repeller) pressed into the canvas. I got something working but when…

---

## [Array releasing particles in specific intervals](https://discourse.processing.org/t/array-releasing-particles-in-specific-intervals/38836)

<div class="topic-metadata">

**Author:** [@Tilman](https://discourse.processing.org/u/Tilman)\
**Replies:** 9\
**Last updated:** [September 18, 2022, 7:19pm UTC](https://discourse.processing.org/t/array-releasing-particles-in-specific-intervals/38836 "2022-09-18T19:19:41Z")

</div>

Hi, I have made an array of particles and I initiate the particles in the draw function to get a particle stream. But what I really want is to release the particles from the array at specific intervals. Like every seco…

---

## [Create a box with different colored sides](https://discourse.processing.org/t/create-a-box-with-different-colored-sides/38792)

<div class="topic-metadata">

**Author:** [@heylittlechef](https://discourse.processing.org/u/heylittlechef)\
**Replies:** 4\
**Last updated:** [September 16, 2022, 10:24am UTC](https://discourse.processing.org/t/create-a-box-with-different-colored-sides/38792 "2022-09-16T10:24:40Z")

</div>

Hi! I’m just starting out and want to make a box with different colored sides. Any tips?

---

## [Array problem with SLIDER VALUE through for loop](https://discourse.processing.org/t/array-problem-with-slider-value-through-for-loop/38753)

<div class="topic-metadata">

**Author:** [@wasif9098](https://discourse.processing.org/u/wasif9098)\
**Replies:** 12\
**Last updated:** [September 16, 2022, 6:08am UTC](https://discourse.processing.org/t/array-problem-with-slider-value-through-for-loop/38753 "2022-09-16T06:08:22Z")

</div>

I’m new to JS and p5. I was trying to make a slider which controls the number of objects through array and for loop. But I’m facing two problems. Problem 1. If the slider value is above 49, it gives this error “Cannot…

---

## [Place a circle on the surface of a sphere](https://discourse.processing.org/t/place-a-circle-on-the-surface-of-a-sphere/38770)

<div class="topic-metadata">

**Author:** [@rickard](https://discourse.processing.org/u/rickard)\
**Replies:** 6\
**Last updated:** [September 15, 2022, 11:36am UTC](https://discourse.processing.org/t/place-a-circle-on-the-surface-of-a-sphere/38770 "2022-09-15T11:36:05Z")

</div>

Hi, I’m trying to place a circle on the surface of a sphere. I’ve already have the coordinates but i’m struggling a bit with the rotation (see screenshots). I’ve tried using the theta and phi values used when creating …

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

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