# Coding Questions

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

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

**Page:** 26

---

## [Make older processing code compatible with processing 3](https://discourse.processing.org/t/make-older-processing-code-compatible-with-processing-3/25567)

<div class="topic-metadata">

**Author:** [@princess](https://discourse.processing.org/u/princess)\
**Replies:** 4\
**Last updated:** [November 20, 2020, 4:18pm UTC](https://discourse.processing.org/t/make-older-processing-code-compatible-with-processing-3/25567 "2020-11-20T16:18:56Z")

</div>

var colors; var type; function setup() { createCanvas(windowWidth, windowHeight); colors = \[ color(255, 0, 0), color(0, 255, 0), color(0, 0, 255) \]; type = 0; } function draw() { blendMode(BLEND); if(type ==…

---

## [Plotting a graph with beginShape() gives low resolution and gaps](https://discourse.processing.org/t/plotting-a-graph-with-beginshape-gives-low-resolution-and-gaps/25535)

<div class="topic-metadata">

**Author:** [@alphydan](https://discourse.processing.org/u/alphydan)\
**Replies:** 4\
**Last updated:** [November 19, 2020, 9:44pm UTC](https://discourse.processing.org/t/plotting-a-graph-with-beginshape-gives-low-resolution-and-gaps/25535 "2020-11-19T21:44:56Z")

</div>

Using p5.js, I have some data from a .csv file (in this case 1200 points) which I’m trying to plot. To do so, I have placed the points inside a beginShape() ... endShape() object. Here is a screenshot of part of the re…

---

## [Sketch works locally on server but when deployed failed load resources](https://discourse.processing.org/t/sketch-works-locally-on-server-but-when-deployed-failed-load-resources/25513)

<div class="topic-metadata">

**Author:** [@decentralizedmike](https://discourse.processing.org/u/decentralizedmike)\
**Replies:** 4\
**Last updated:** [November 19, 2020, 1:24am UTC](https://discourse.processing.org/t/sketch-works-locally-on-server-but-when-deployed-failed-load-resources/25513 "2020-11-19T01:24:39Z")

</div>

It looks like when I preview my project on the server it runs as expected, but I begin running into issues when I am trying to view it deployed on github pages. I have tried multiple browsers, and the page is stuck on l…

---

## [Debug with Editor](https://discourse.processing.org/t/debug-with-editor/25327)

<div class="topic-metadata">

**Author:** [@cpw](https://discourse.processing.org/u/cpw)\
**Replies:** 75\
**Last updated:** [November 18, 2020, 11:25pm UTC](https://discourse.processing.org/t/debug-with-editor/25327 "2020-11-18T23:25:11Z")

</div>

Hi All Is there a way to set though the code using https://editor.p5js.org/ ? Regards Chris

---

## [Someone please help solving a problem : shooting bullets](https://discourse.processing.org/t/someone-please-help-solving-a-problem-shooting-bullets/21210)

<div class="topic-metadata">

**Author:** [@Nis](https://discourse.processing.org/u/Nis)\
**Replies:** 5\
**Last updated:** [November 16, 2020, 9:00pm UTC](https://discourse.processing.org/t/someone-please-help-solving-a-problem-shooting-bullets/21210 "2020-11-16T21:00:24Z")

</div>

https://editor.p5js.org/Nis\_Collect/sketches/U0p3GjOK1 Above is the link of my code.Please ckeck the code. The small circle(ellipse) which is inside of the big circle should be shooted towards the player(blue coloured)…

---

## [Processing to p5.js sketch](https://discourse.processing.org/t/processing-to-p5-js-sketch/25449)

<div class="topic-metadata">

**Author:** [@femke](https://discourse.processing.org/u/femke)\
**Replies:** 1\
**Last updated:** [November 15, 2020, 10:54pm UTC](https://discourse.processing.org/t/processing-to-p5-js-sketch/25449 "2020-11-15T22:54:06Z")

</div>

Hi all, I’m pretty new to coding and I’m trying to convert a processing file to a p5.js file but it keeps giving me an error. I know there’s something wrong wrong about the PVector but not sure what. Can somebody help…

---

## [Particles inside a 3D object to be attracted](https://discourse.processing.org/t/particles-inside-a-3d-object-to-be-attracted/25375)

<div class="topic-metadata">

**Author:** [@BlueJack](https://discourse.processing.org/u/BlueJack)\
**Replies:** 1\
**Last updated:** [November 12, 2020, 7:08pm UTC](https://discourse.processing.org/t/particles-inside-a-3d-object-to-be-attracted/25375 "2020-11-12T19:08:50Z")

</div>

Hello, what is an effective way to deal with particles trapped inside a 3D object (box or cylinder, for exaple) being attracted by outer particle. The result is to get inside particles moving forward to the attractor, th…

---

## [Get() doesn't work properly on Safari (iOS/iPhone)](https://discourse.processing.org/t/get-doesnt-work-properly-on-safari-ios-iphone/25337)

<div class="topic-metadata">

**Author:** [@Logix](https://discourse.processing.org/u/Logix)\
**Replies:** 0\
**Last updated:** [November 11, 2020, 5:36am UTC](https://discourse.processing.org/t/get-doesnt-work-properly-on-safari-ios-iphone/25337 "2020-11-11T05:36:54Z")

</div>

get() captures a rectangular section of the canvas and returns it as an image. On Safari, if that rectangular section is within the canvas, the image is returned properly, but if that section extends beyond the canvas bo…

---

## [Obstacles in game not working properly](https://discourse.processing.org/t/obstacles-in-game-not-working-properly/25329)

<div class="topic-metadata">

**Author:** [@ninjarick](https://discourse.processing.org/u/ninjarick)\
**Replies:** 3\
**Last updated:** [November 10, 2020, 9:56pm UTC](https://discourse.processing.org/t/obstacles-in-game-not-working-properly/25329 "2020-11-10T21:56:57Z")

</div>

Hi there! I’ve hit a snag in my code. I want to be able to make a game where the player (a rect) jumps over obstacles. Similar to the no wifi Dino game. I’ve added code to make the player character flip when they jump. …

---

## [Two Player Pong game COLLISION FUNCTION DON'T WORK](https://discourse.processing.org/t/two-player-pong-game-collision-function-dont-work/24728)

<div class="topic-metadata">

**Author:** [@juzermala](https://discourse.processing.org/u/juzermala)\
**Replies:** 9\
**Last updated:** [November 9, 2020, 7:00am UTC](https://discourse.processing.org/t/two-player-pong-game-collision-function-dont-work/24728 "2020-11-09T07:00:14Z")

</div>

please format code with \</\> button \* homework policy \* asking questions |my coding for 2 player pong game in p5js. in my coding function collision do not work. ball bounces from all walls but do not bounce by hitti…

---

## [Flash Action Script](https://discourse.processing.org/t/flash-action-script/25181)

<div class="topic-metadata">

**Author:** [@markcosmic](https://discourse.processing.org/u/markcosmic)\
**Replies:** 4\
**Last updated:** [November 7, 2020, 6:52pm UTC](https://discourse.processing.org/t/flash-action-script/25181 "2020-11-07T18:52:14Z")

</div>

Hello everyone, A few tear back I made the mistake of writing my website in Flash Actionscript. Many of you are aware that Apple hasn’t supported it in years and soon FlashPlayer will be gone and no longer supported by …

---

## [Slow render in WebGL](https://discourse.processing.org/t/slow-render-in-webgl/25051)

<div class="topic-metadata">

**Author:** [@Tahsin](https://discourse.processing.org/u/Tahsin)\
**Replies:** 4\
**Last updated:** [November 5, 2020, 4:01am UTC](https://discourse.processing.org/t/slow-render-in-webgl/25051 "2020-11-05T04:01:54Z")

</div>

Hey, I want to make a terrain generator in p5. So, I need WebGL to rotate the canvas on X axis. But, even trying to render 500 lines makes the whole sketch extremely slow. If I remove the WEBGL, the sketch runs pretty fa…

---

## [Loading video from base64, putting it on the canvas and adding stuff to each frame, then get the base64 of the new video with canvas stuff](https://discourse.processing.org/t/loading-video-from-base64-putting-it-on-the-canvas-and-adding-stuff-to-each-frame-then-get-the-base64-of-the-new-video-with-canvas-stuff/25090)

<div class="topic-metadata">

**Author:** [@Bas950](https://discourse.processing.org/u/Bas950)\
**Replies:** 0\
**Last updated:** [November 1, 2020, 12:57am UTC](https://discourse.processing.org/t/loading-video-from-base64-putting-it-on-the-canvas-and-adding-stuff-to-each-frame-then-get-the-base64-of-the-new-video-with-canvas-stuff/25090 "2020-11-01T00:57:05Z")

</div>

Could someone help me with this: Loading video from base64, putting it on the canvas and adding stuff to each frame, then get the base64 of the new video with canvas stuff at the end. Already stuck at loading the video…

---

## [Instantiation not working in P5JS](https://discourse.processing.org/t/instantiation-not-working-in-p5js/25024)

<div class="topic-metadata">

**Author:** [@nateb](https://discourse.processing.org/u/nateb)\
**Replies:** 1\
**Last updated:** [October 31, 2020, 8:02pm UTC](https://discourse.processing.org/t/instantiation-not-working-in-p5js/25024 "2020-10-31T20:02:33Z")

</div>

I need to instantiate this so I can combine it with other sketches but keep getting an error. PLS HELP const radius = 100; let x, y; //code for icons p.setup = function(){ p.createCanvas(windowWidth, windowHeight); …

---

## [MousePressed : select only item in front](https://discourse.processing.org/t/mousepressed-select-only-item-in-front/24936)

<div class="topic-metadata">

**Author:** [@vlafortune](https://discourse.processing.org/u/vlafortune)\
**Replies:** 13\
**Last updated:** [October 31, 2020, 3:42pm UTC](https://discourse.processing.org/t/mousepressed-select-only-item-in-front/24936 "2020-10-31T15:42:59Z")

</div>

Hi! How can I select only the object in front when two objects are stacked? I made a very simple code to show what I mean. In this example, I would like to change only the color of the smaller circle. Thanks! let bubb…

---

## [Force calculation for magnetic pendulum and numerical integration](https://discourse.processing.org/t/force-calculation-for-magnetic-pendulum-and-numerical-integration/24972)

<div class="topic-metadata">

**Author:** [@Eioer](https://discourse.processing.org/u/Eioer)\
**Replies:** 0\
**Last updated:** [October 28, 2020, 3:03pm UTC](https://discourse.processing.org/t/force-calculation-for-magnetic-pendulum-and-numerical-integration/24972 "2020-10-28T15:03:27Z")

</div>

Hello everyone, I’ve been working on a simulation of a magnetic pendulum (Magnetic Pendulum for reference). Now, I have a question concerning how you calculate the forces/acceleration: In examples you find online of th…

---

## [Help with using input values with variables along with if, else if code](https://discourse.processing.org/t/help-with-using-input-values-with-variables-along-with-if-else-if-code/23910)

<div class="topic-metadata">

**Author:** [@DariusKempton](https://discourse.processing.org/u/DariusKempton)\
**Replies:** 29\
**Last updated:** [October 27, 2020, 5:08pm UTC](https://discourse.processing.org/t/help-with-using-input-values-with-variables-along-with-if-else-if-code/23910 "2020-10-27T17:08:03Z")

</div>

//Variables //Character Stat and Detail Variables //Character Details var Character\_Name = \[""\]; var Age = \[""\]; var Alignment = \[""\]; var Religion = \[""\]; var Background = \[""\]; var Hair = \[""\]; …

---

## [Shapes unexpectedly overlay other shapes](https://discourse.processing.org/t/shapes-unexpectedly-overlay-other-shapes/24946)

<div class="topic-metadata">

**Author:** [@alt](https://discourse.processing.org/u/alt)\
**Replies:** 13\
**Last updated:** [October 27, 2020, 3:12pm UTC](https://discourse.processing.org/t/shapes-unexpectedly-overlay-other-shapes/24946 "2020-10-27T15:12:25Z")

</div>

So, In my code, The circles sometimes fill up tiles that have been occupied by the Squares. As seen here: The relevant code is as follows function draw() { noStroke(); // These make a sort-of grid to be filled w…

---

## [How do I change the font that is used by a button in p5?](https://discourse.processing.org/t/how-do-i-change-the-font-that-is-used-by-a-button-in-p5/24887)

<div class="topic-metadata">

**Author:** [@The\_Rogue12](https://discourse.processing.org/u/The_Rogue12)\
**Replies:** 6\
**Last updated:** [October 26, 2020, 11:24pm UTC](https://discourse.processing.org/t/how-do-i-change-the-font-that-is-used-by-a-button-in-p5/24887 "2020-10-26T23:24:15Z")

</div>

I am not sure how I can do this. I have tried all the style() properties that I know, but none of them are able to change the font on a button. Example code I am trying to write: let drawButton; let circle = false; fun…

---

## [How can I put html text on top of a p5.js script?](https://discourse.processing.org/t/how-can-i-put-html-text-on-top-of-a-p5-js-script/24930)

<div class="topic-metadata">

**Author:** [@olaf000olaf](https://discourse.processing.org/u/olaf000olaf)\
**Replies:** 0\
**Last updated:** [October 26, 2020, 6:31pm UTC](https://discourse.processing.org/t/how-can-i-put-html-text-on-top-of-a-p5-js-script/24930 "2020-10-26T18:31:45Z")

</div>

How can put text on top of a p5js sketch in html?

---

## [Pixel arrays and performance issues in p5 and processing](https://discourse.processing.org/t/pixel-arrays-and-performance-issues-in-p5-and-processing/24891)

<div class="topic-metadata">

**Author:** [@Birb](https://discourse.processing.org/u/Birb)\
**Replies:** 6\
**Last updated:** [October 25, 2020, 10:55pm UTC](https://discourse.processing.org/t/pixel-arrays-and-performance-issues-in-p5-and-processing/24891 "2020-10-25T22:55:59Z")

</div>

This mainly applies to p5.js, but also Processing Java. Running this simple script in the p5 web editor gets me 3 frames per second, at only 400x400 resolution. What is it about this script that is so slow, and is there…

---

## [Need help creating a function that delays draw()](https://discourse.processing.org/t/need-help-creating-a-function-that-delays-draw/24839)

<div class="topic-metadata">

**Author:** [@The\_Rogue12](https://discourse.processing.org/u/The_Rogue12)\
**Replies:** 7\
**Last updated:** [October 25, 2020, 6:47pm UTC](https://discourse.processing.org/t/need-help-creating-a-function-that-delays-draw/24839 "2020-10-25T18:47:19Z")

</div>

I am currently working on a small game, and am trying to figure out how to delay the draw() function for about 6 seconds so that I can write some text on the screen in time with a song. I have the code set up so that the…

---

## [How do I lerp() colors on a curve? (non linear interpolation)](https://discourse.processing.org/t/how-do-i-lerp-colors-on-a-curve-non-linear-interpolation/24815)

<div class="topic-metadata">

**Author:** [@Birb](https://discourse.processing.org/u/Birb)\
**Replies:** 3\
**Last updated:** [October 22, 2020, 8:26pm UTC](https://discourse.processing.org/t/how-do-i-lerp-colors-on-a-curve-non-linear-interpolation/24815 "2020-10-22T20:26:52Z")

</div>

How do I interpolate two (or maybe even more) colors in a non-linear way along a curve? For example, instead of the mid-point being 50/50, I would want it to be 25/75, or shifted according to the control point. I tried …

---

## [Read the pixels of input file](https://discourse.processing.org/t/read-the-pixels-of-input-file/24797)

<div class="topic-metadata">

**Author:** [@pixelMaker](https://discourse.processing.org/u/pixelMaker)\
**Replies:** 1\
**Last updated:** [October 21, 2020, 3:26pm UTC](https://discourse.processing.org/t/read-the-pixels-of-input-file/24797 "2020-10-21T15:26:20Z")

</div>

Hi, I have been working with processing on java for a while, but new to JS. I am trying to let the user upload an image, and then I want to be able to use get() or pixels\[\] to read specific pixels within the image the …

---

## [Continuously update drawing during mouseDragged](https://discourse.processing.org/t/continuously-update-drawing-during-mousedragged/24762)

<div class="topic-metadata">

**Author:** [@rajmb](https://discourse.processing.org/u/rajmb)\
**Replies:** 6\
**Last updated:** [October 21, 2020, 1:54pm UTC](https://discourse.processing.org/t/continuously-update-drawing-during-mousedragged/24762 "2020-10-21T13:54:41Z")

</div>

I am trying to create a simple mspaint like application on the web using p5 as a learning exercise. I have provided a button to draw an ellipse on the canvas and want to show the ellipse being resized as the mouse is dra…

---

## [Trying to make a cross on this grid](https://discourse.processing.org/t/trying-to-make-a-cross-on-this-grid/24676)

<div class="topic-metadata">

**Author:** [@marcospyder](https://discourse.processing.org/u/marcospyder)\
**Replies:** 6\
**Last updated:** [October 19, 2020, 12:09pm UTC](https://discourse.processing.org/t/trying-to-make-a-cross-on-this-grid/24676 "2020-10-19T12:09:09Z")

</div>

Just as the title explains. I managed to make one line go across the grid, but i’m not sure how to do the other line to create a cross. The idea is to make an expression just like “x===y” to automaticly make the other li…

---

## [Disappearance of curves in the order they appear](https://discourse.processing.org/t/disappearance-of-curves-in-the-order-they-appear/24553)

<div class="topic-metadata">

**Author:** [@qWici](https://discourse.processing.org/u/qWici)\
**Replies:** 2\
**Last updated:** [October 16, 2020, 7:40pm UTC](https://discourse.processing.org/t/disappearance-of-curves-in-the-order-they-appear/24553 "2020-10-16T19:40:45Z")

</div>

I have this code: var i = 0; function setup() { createCanvas(windowWidth, windowHeight); background(0); colorMode(HSB, 255); } function windowResized() { resizeCanvas(windowWidth, windowHeight); bac…

---

## [Direction of Particles in simple physics engine interact in weird ways](https://discourse.processing.org/t/direction-of-particles-in-simple-physics-engine-interact-in-weird-ways/24579)

<div class="topic-metadata">

**Author:** [@hensn](https://discourse.processing.org/u/hensn)\
**Replies:** 2\
**Last updated:** [October 14, 2020, 3:23pm UTC](https://discourse.processing.org/t/direction-of-particles-in-simple-physics-engine-interact-in-weird-ways/24579 "2020-10-14T15:23:58Z")

</div>

Hi guys, I’m playing around with the simple physics engine from this video: https://www.youtube.com/watch?v=BjoM9oKOAKY What I wanted to do is to have two particles that just move in one direction. To do this I create …

---

## [Click and point game with array - troubleshooting](https://discourse.processing.org/t/click-and-point-game-with-array-troubleshooting/24504)

<div class="topic-metadata">

**Author:** [@vlafortune](https://discourse.processing.org/u/vlafortune)\
**Replies:** 7\
**Last updated:** [October 12, 2020, 9:58pm UTC](https://discourse.processing.org/t/click-and-point-game-with-array-troubleshooting/24504 "2020-10-12T21:58:20Z")

</div>

Hi, I’m making a click and point type of game. I want to sort fishes by their color. I want to remove the blue fishes from the big aquarium and “store” them for further use in the small aquarium. I putting here what I’…

---

## [Tinting a shape in p5js isn't working, how could I tint it then?](https://discourse.processing.org/t/tinting-a-shape-in-p5js-isnt-working-how-could-i-tint-it-then/24550)

<div class="topic-metadata">

**Author:** [@olaf000olaf](https://discourse.processing.org/u/olaf000olaf)\
**Replies:** 1\
**Last updated:** [October 12, 2020, 7:56pm UTC](https://discourse.processing.org/t/tinting-a-shape-in-p5js-isnt-working-how-could-i-tint-it-then/24550 "2020-10-12T19:56:17Z")

</div>

I did a little bit of processing and now in p5js I’m trying to tint a shape using tint(); but it won’t work, how should I tint it?

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

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