# Coding Questions

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

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

**Page:** 17

---

## [P5.js goes to Processing abnormally slow！](https://discourse.processing.org/t/p5-js-goes-to-processing-abnormally-slow/31984)

<div class="topic-metadata">

**Author:** [@AbleYudada](https://discourse.processing.org/u/AbleYudada)\
**Replies:** 6\
**Last updated:** [August 29, 2021, 1:48pm UTC](https://discourse.processing.org/t/p5-js-goes-to-processing-abnormally-slow/31984 "2021-08-29T13:48:10Z")

</div>

Hello everyone! Does anyone have any research on the transition from p5js to processing? I tried to convert the p5js code to processing successfully but it runs abnormally slowly. I am not sure what went wrong. Can anyo…

---

## [Defining setup() and draw() at runtime](https://discourse.processing.org/t/defining-setup-and-draw-at-runtime/31728)

<div class="topic-metadata">

**Author:** [@javagar](https://discourse.processing.org/u/javagar)\
**Replies:** 8\
**Last updated:** [August 27, 2021, 11:26pm UTC](https://discourse.processing.org/t/defining-setup-and-draw-at-runtime/31728 "2021-08-27T23:26:17Z")

</div>

The following probably ought not be done, as it seems, at best, poor programming style. Perhaps, even worse, it could break in the future. However, as of this time, it does work without any obvious problem, so here goes,…

---

## [createSlider does not work sometimes](https://discourse.processing.org/t/createslider-does-not-work-sometimes/31935)

<div class="topic-metadata">

**Author:** [@Ariadne](https://discourse.processing.org/u/Ariadne)\
**Replies:** 2\
**Last updated:** [August 27, 2021, 4:21am UTC](https://discourse.processing.org/t/createslider-does-not-work-sometimes/31935 "2021-08-27T04:21:29Z")

</div>

So in the start of my code, I define time as the return value of createSlider(0, 1, 1 / animationSmoothness, where animationSmoothness is 16. But when I try to call the value() method of time, an error shows up. Why? Co…

---

## [How to render LaTeX?](https://discourse.processing.org/t/how-to-render-latex/31841)

<div class="topic-metadata">

**Author:** [@Ariadne](https://discourse.processing.org/u/Ariadne)\
**Replies:** 4\
**Last updated:** [August 23, 2021, 2:40pm UTC](https://discourse.processing.org/t/how-to-render-latex/31841 "2021-08-23T14:40:10Z")

</div>

For a recent math visualizer I was programming, I needed to render LaTeX. I normally use Manim for such visualisations, but this time I decided to use p5.js. But it appears that there is no library to do this. What can …

---

## [How to use export & import in p5.js](https://discourse.processing.org/t/how-to-use-export-import-in-p5-js/31724)

<div class="topic-metadata">

**Author:** [@JaPatProccesingDis](https://discourse.processing.org/u/JaPatProccesingDis)\
**Replies:** 9\
**Last updated:** [August 22, 2021, 3:01pm UTC](https://discourse.processing.org/t/how-to-use-export-import-in-p5-js/31724 "2021-08-22T15:01:20Z")

</div>

Hello guys! I have some code stored in my GitHub repository…here is its jsdelivr link https://cdn.jsdelivr.net/gh/JaPatGitHub/EduSimulations@main/Tools/x-y-coordinate%20pointer.js Now, I try importing this into the p5.…

---

## [Multiple sketches in instance mode](https://discourse.processing.org/t/multiple-sketches-in-instance-mode/11222)

<div class="topic-metadata">

**Author:** [@cnie](https://discourse.processing.org/u/cnie)\
**Replies:** 3\
**Last updated:** [August 21, 2021, 9:46pm UTC](https://discourse.processing.org/t/multiple-sketches-in-instance-mode/11222 "2021-08-21T21:46:48Z")

</div>

I am quite new to p5 and am struggling to achieve multiple canvases on a single webpage. I can manage to to get two running, using two instance functions, but I can’t figure out how to position them off their default pos…

---

## [Importing shader .glsl files to Wordpress](https://discourse.processing.org/t/importing-shader-glsl-files-to-wordpress/31821)

<div class="topic-metadata">

**Author:** [@CraigO](https://discourse.processing.org/u/CraigO)\
**Replies:** 2\
**Last updated:** [August 21, 2021, 9:57pm UTC](https://discourse.processing.org/t/importing-shader-glsl-files-to-wordpress/31821 "2021-08-21T21:57:03Z")

</div>

Hey, I have shader files in my p5 project running and displaying perfectly on my local server. The files are preloaded via loadShader because I can access the file path. However, shader .glsl file paths are not accessi…

---

## [Double Möbius strip](https://discourse.processing.org/t/double-mobius-strip/31362)

<div class="topic-metadata">

**Author:** [@fleshcircuit](https://discourse.processing.org/u/fleshcircuit)\
**Replies:** 2\
**Last updated:** [July 24, 2021, 2:56pm UTC](https://discourse.processing.org/t/double-mobius-strip/31362 "2021-07-24T14:56:12Z")

</div>

I am currently working on a mobius strip animation based on this example: Mobius Strip Animation - #6 by glv However, I am trying to figure out a way to increase the folds and double the strip. This is my first attempt …

---

## [Smooth animation/interpolation](https://discourse.processing.org/t/smooth-animation-interpolation/31623)

<div class="topic-metadata">

**Author:** [@anoniim](https://discourse.processing.org/u/anoniim)\
**Replies:** 5\
**Last updated:** [August 19, 2021, 2:44am UTC](https://discourse.processing.org/t/smooth-animation-interpolation/31623 "2021-08-19T02:44:30Z")

</div>

When animating a property of an object, I’d like the property to change slowly at first, then speed up and slow down at the end again. For linear change, there is the lerp() method in Processing PApplet for linear inter…

---

## [Dealing with editing large images](https://discourse.processing.org/t/dealing-with-editing-large-images/26846)

<div class="topic-metadata">

**Author:** [@tinywitchdraws](https://discourse.processing.org/u/tinywitchdraws)\
**Replies:** 3\
**Last updated:** [August 4, 2021, 5:44pm UTC](https://discourse.processing.org/t/dealing-with-editing-large-images/26846 "2021-08-04T17:44:40Z")

</div>

Hi all, I’m working on a little p5js app that will take an image and convert the brightness to opacity. So far, it works well but it crashes the browser when editing large images. here’s the code: https://editor.p5js.or…

---

## [Using. img.get to retrieve color values](https://discourse.processing.org/t/using-img-get-to-retrieve-color-values/31778)

<div class="topic-metadata">

**Author:** [@glen](https://discourse.processing.org/u/glen)\
**Replies:** 2\
**Last updated:** [August 18, 2021, 11:34am UTC](https://discourse.processing.org/t/using-img-get-to-retrieve-color-values/31778 "2021-08-18T11:34:07Z")

</div>

I am using the following code let c = img.get(xPos,yPos); to sample a color from a pixel of an image and it works brilliantly as I can then fill or stroke with the variable (c) My question is how do I then make (c) us…

---

## [How do I use the X and Y values from an object from touches in P5js?](https://discourse.processing.org/t/how-do-i-use-the-x-and-y-values-from-an-object-from-touches-in-p5js/31766)

<div class="topic-metadata">

**Author:** [@nothingness](https://discourse.processing.org/u/nothingness)\
**Replies:** 4\
**Last updated:** [August 18, 2021, 12:19am UTC](https://discourse.processing.org/t/how-do-i-use-the-x-and-y-values-from-an-object-from-touches-in-p5js/31766 "2021-08-18T00:19:09Z")

</div>

This is my first week playing with P5js and Processing so be gentle. I’ve got the following P5js code where I’m looking at touch values. By pressing multi-points on a touch screen brings up more circles anchored to a ce…

---

## [Show country names in a p5 worldmap](https://discourse.processing.org/t/show-country-names-in-a-p5-worldmap/31519)

<div class="topic-metadata">

**Author:** [@Zqrni](https://discourse.processing.org/u/Zqrni)\
**Replies:** 10\
**Last updated:** [August 12, 2021, 9:14pm UTC](https://discourse.processing.org/t/show-country-names-in-a-p5-worldmap/31519 "2021-08-12T21:14:29Z")

</div>

Hi there, I need to show the country name when we have the pointer over a country position on a world map. Could you guys please help me? Don’t even know from where to start with this. The code is in this codepen: T…

---

## [Area of triangle](https://discourse.processing.org/t/area-of-triangle/31652)

<div class="topic-metadata">

**Author:** [@peterson](https://discourse.processing.org/u/peterson)\
**Replies:** 5\
**Last updated:** [August 12, 2021, 7:46pm UTC](https://discourse.processing.org/t/area-of-triangle/31652 "2021-08-12T19:46:42Z")

</div>

type or paste code here \`\</\>button\*/t/2147askingquestionshowtogetareaoftriangle\`\`

---

## [Custom button class that can call given function](https://discourse.processing.org/t/custom-button-class-that-can-call-given-function/31670)

<div class="topic-metadata">

**Author:** [@Sayochi](https://discourse.processing.org/u/Sayochi)\
**Replies:** 3\
**Last updated:** [August 11, 2021, 8:02pm UTC](https://discourse.processing.org/t/custom-button-class-that-can-call-given-function/31670 "2021-08-11T20:02:27Z")

</div>

Im trying to make a custom buttons for fun. i want to be able to give him functions and run the functions when I click it. I already completed the clicking detection part. how can I somehow pass the function information …

---

## [Creating and removing one object from an array](https://discourse.processing.org/t/creating-and-removing-one-object-from-an-array/31601)

<div class="topic-metadata">

**Author:** [@atagger](https://discourse.processing.org/u/atagger)\
**Replies:** 14\
**Last updated:** [August 9, 2021, 8:32pm UTC](https://discourse.processing.org/t/creating-and-removing-one-object-from-an-array/31601 "2021-08-09T20:32:31Z")

</div>

This is probably a really silly question, but I can’t seem to find an answer. If you want to create one object and then delete it, what is the typical way to do this? Since I only have one object I don’t want to push it …

---

## [Reading pixels from an image](https://discourse.processing.org/t/reading-pixels-from-an-image/31592)

<div class="topic-metadata">

**Author:** [@Kiliad](https://discourse.processing.org/u/Kiliad)\
**Replies:** 32\
**Last updated:** [August 9, 2021, 10:58am UTC](https://discourse.processing.org/t/reading-pixels-from-an-image/31592 "2021-08-09T10:58:05Z")

</div>

Hi. I’m having a problem with what I thought would be a a very simple piece of code. There’s not much point posting any of my attempts as I’m confused enough as is. Ultimately I have something more complex in mind, bu…

---

## [Unable to perform CSS image-rendering on p5 canvas in the browser](https://discourse.processing.org/t/unable-to-perform-css-image-rendering-on-p5-canvas-in-the-browser/31600)

<div class="topic-metadata">

**Author:** [@willyfly](https://discourse.processing.org/u/willyfly)\
**Replies:** 4\
**Last updated:** [August 7, 2021, 10:12am UTC](https://discourse.processing.org/t/unable-to-perform-css-image-rendering-on-p5-canvas-in-the-browser/31600 "2021-08-07T10:12:43Z")

</div>

First, sorry for my English and I’ll try to explain. I’m trying to display pixelated image on p5 canvas in the browser by providing the canvas element in style.css with image-rendering property. I found code below by Be…

---

## [Try to access parseObj(model,strings) in P5 code](https://discourse.processing.org/t/try-to-access-parseobj-model-strings-in-p5-code/31593)

<div class="topic-metadata">

**Author:** [@pirela](https://discourse.processing.org/u/pirela)\
**Replies:** 2\
**Last updated:** [August 6, 2021, 8:34pm UTC](https://discourse.processing.org/t/try-to-access-parseobj-model-strings-in-p5-code/31593 "2021-08-06T20:34:23Z")

</div>

I create obj data on the fly and want to use it directly without going through a file. loadModel( model, fileName) uses a file, but internally it uses the function : (line 100206 of p5.js) : function parseObj(model, …

---

## [Help - push an array into array simple question](https://discourse.processing.org/t/help-push-an-array-into-array-simple-question/31577)

<div class="topic-metadata">

**Author:** [@atagger](https://discourse.processing.org/u/atagger)\
**Replies:** 12\
**Last updated:** [August 6, 2021, 12:34am UTC](https://discourse.processing.org/t/help-push-an-array-into-array-simple-question/31577 "2021-08-06T00:34:10Z")

</div>

I’m racking my head not understanding why this doesn’t work. i was expecting the sampleBuffer array to become a length 32 array containing 32 arrays each with 3 random numbers. Instead I get a length 32 array of 32 arra…

---

## [Create very few particles on a particle system](https://discourse.processing.org/t/create-very-few-particles-on-a-particle-system/31478)

<div class="topic-metadata">

**Author:** [@avivtech](https://discourse.processing.org/u/avivtech)\
**Replies:** 3\
**Last updated:** [July 29, 2021, 9:39am UTC](https://discourse.processing.org/t/create-very-few-particles-on-a-particle-system/31478 "2021-07-29T09:39:22Z")

</div>

Hi, I am trying to create bubbles simulation. I want a bubble to appear every 1-2 sec. and to burst at the bottom of the canvas. I have this so far: https://codepen.io/Avivtech/pen/yLbKooV I can not get to create only…

---

## [Wait or delay into Loop](https://discourse.processing.org/t/wait-or-delay-into-loop/31468)

<div class="topic-metadata">

**Author:** [@Eddie\_float](https://discourse.processing.org/u/Eddie_float)\
**Replies:** 2\
**Last updated:** [July 27, 2021, 10:11pm UTC](https://discourse.processing.org/t/wait-or-delay-into-loop/31468 "2021-07-27T22:11:39Z")

</div>

I want to create a pause, wait or delay inside the loops. Is this possible?

---

## [Determining the correct detailX & detailY value for p5.Geometry](https://discourse.processing.org/t/determining-the-correct-detailx-detaily-value-for-p5-geometry/31464)

<div class="topic-metadata">

**Author:** [@hardwhere](https://discourse.processing.org/u/hardwhere)\
**Replies:** 0\
**Last updated:** [July 27, 2021, 5:11pm UTC](https://discourse.processing.org/t/determining-the-correct-detailx-detaily-value-for-p5-geometry/31464 "2021-07-27T17:11:14Z")

</div>

I’m generating geometry using p5.Geometry, but having trouble determining what the correct detailX and detailY values to use are. According to the comments in the source code, detailX is the “number of vertices on horizo…

---

## [Line Drawings with p5.Geometry](https://discourse.processing.org/t/line-drawings-with-p5-geometry/30953)

<div class="topic-metadata">

**Author:** [@hardwhere](https://discourse.processing.org/u/hardwhere)\
**Replies:** 2\
**Last updated:** [July 27, 2021, 3:59pm UTC](https://discourse.processing.org/t/line-drawings-with-p5-geometry/30953 "2021-07-27T15:59:54Z")

</div>

Hello! I was recently able to get help on a question with p5.Geometry (here) and am back with another question: Is it possible to use p5.Geometry to make a line drawing? In immediate mode, we can pass a parameter to beg…

---

## [Thin lines look different in Safari?](https://discourse.processing.org/t/thin-lines-look-different-in-safari/31460)

<div class="topic-metadata">

**Author:** [@astrom.hjalmar](https://discourse.processing.org/u/astrom.hjalmar)\
**Replies:** 1\
**Last updated:** [July 27, 2021, 3:14pm UTC](https://discourse.processing.org/t/thin-lines-look-different-in-safari/31460 "2021-07-27T15:14:19Z")

</div>

Hi all, I was hoping to get some help with this as I’m really stumped. When I draw thin lines (stroke weight \< 1) in p5js it looks a lot brighter in Safari compared to Chrome (example sketch). Has anyone else found a wa…

---

## [How to smoothly fading between multiple shaders with p5.js?](https://discourse.processing.org/t/how-to-smoothly-fading-between-multiple-shaders-with-p5-js/22645)

<div class="topic-metadata">

**Author:** [@Spenc](https://discourse.processing.org/u/Spenc)\
**Replies:** 1\
**Last updated:** [July 27, 2021, 8:44am UTC](https://discourse.processing.org/t/how-to-smoothly-fading-between-multiple-shaders-with-p5-js/22645 "2021-07-27T08:44:18Z")

</div>

I am trying to figure out how to fade between an array of shaders at random rates and random opacities. I tried creating an if statement that would provide a new target opacity and target rate of time it would take to fu…

---

## [P5js instance mode - how to manage functions?](https://discourse.processing.org/t/p5js-instance-mode-how-to-manage-functions/25369)

<div class="topic-metadata">

**Author:** [@amygoodchild](https://discourse.processing.org/u/amygoodchild)\
**Replies:** 4\
**Last updated:** [July 23, 2021, 9:00pm UTC](https://discourse.processing.org/t/p5js-instance-mode-how-to-manage-functions/25369 "2021-07-23T21:00:30Z")

</div>

I am using instance mode for a p5js project and I am trying to figure out the best way to keep my functions organised. Here is how I had my code organised originally: var rotateSketch = function(p){ p.setup = funct…

---

## [Multiple frame rates at any speed from 1 to 30FPS](https://discourse.processing.org/t/multiple-frame-rates-at-any-speed-from-1-to-30fps/31398)

<div class="topic-metadata">

**Author:** [@4dplane](https://discourse.processing.org/u/4dplane)\
**Replies:** 1\
**Last updated:** [July 23, 2021, 10:46am UTC](https://discourse.processing.org/t/multiple-frame-rates-at-any-speed-from-1-to-30fps/31398 "2021-07-23T10:46:52Z")

</div>

Hi, I am working in P5.JS and I am trying to achieve multiple frame rates for multiple animations that can have any framerate between 1FPS to 30FPS. Here is the main question: How to keep the master FPS at frameRate(30)…

---

## [Transitions between states](https://discourse.processing.org/t/transitions-between-states/31376)

<div class="topic-metadata">

**Author:** [@k5221](https://discourse.processing.org/u/k5221)\
**Replies:** 4\
**Last updated:** [July 22, 2021, 4:23pm UTC](https://discourse.processing.org/t/transitions-between-states/31376 "2021-07-22T16:23:00Z")

</div>

Hi, I have drawIntro() for drawing the black intro screen and drawPlaying for the game screen. The screen switches to the playing mode when a player clicks the start button (handled by the mousePressed() below). What I …

---

## [Capture image is not shown](https://discourse.processing.org/t/capture-image-is-not-shown/31377)

<div class="topic-metadata">

**Author:** [@k5221](https://discourse.processing.org/u/k5221)\
**Replies:** 2\
**Last updated:** [July 22, 2021, 12:18pm UTC](https://discourse.processing.org/t/capture-image-is-not-shown/31377 "2021-07-22T12:18:25Z")

</div>

Hi, since some point of coding, my code has not been able to show an image on the canvas… My original intent was make the captured image (by webcam) as a background once the button is clicked and game starts playing, but…

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

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