# p5.js

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

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

**Page:** 57

---

## [Rotation movement during noLoop](https://discourse.processing.org/t/rotation-movement-during-noloop/25629)

<div class="topic-metadata">

**Author:** [@sally](https://discourse.processing.org/u/sally)\
**Replies:** 3\
**Last updated:** [November 23, 2020, 7:47pm UTC](https://discourse.processing.org/t/rotation-movement-during-noloop/25629 "2020-11-23T19:47:17Z")

</div>

Hi, I’m new to coding for my student work. I’m making combining random objects + random words. I’m trying to put related code and some point it’s working. But when I put noLoop, the rotation movement is not working… …

---

## [Running in Browser](https://discourse.processing.org/t/running-in-browser/25621)

<div class="topic-metadata">

**Author:** [@cpw](https://discourse.processing.org/u/cpw)\
**Replies:** 3\
**Last updated:** [November 23, 2020, 11:20am UTC](https://discourse.processing.org/t/running-in-browser/25621 "2020-11-23T11:20:19Z")

</div>

Hi guys I have some code running in p5.js fine. I thought all I needed to do was export and be able to open the index.html file with a browser to run on my desktop however I am getting just a loading message. Any ideas…

---

## [How I can create a physical line using material.js?](https://discourse.processing.org/t/how-i-can-create-a-physical-line-using-material-js/25623)

<div class="topic-metadata">

**Author:** [@kokosic](https://discourse.processing.org/u/kokosic)\
**Replies:** 1\
**Last updated:** [November 23, 2020, 7:11am UTC](https://discourse.processing.org/t/how-i-can-create-a-physical-line-using-material-js/25623 "2020-11-23T07:11:28Z")

</div>

I have a simple p5.js code and I need add collision using matter.js. One of the options is to draw rectangles instead of lines and then hang the necessary component on them, but I don’t know how to rotate and place these…

---

## [Bulk preload images with different variable name from JSON - p5.js web](https://discourse.processing.org/t/bulk-preload-images-with-different-variable-name-from-json-p5-js-web/25610)

<div class="topic-metadata">

**Author:** [@patkosd](https://discourse.processing.org/u/patkosd)\
**Replies:** 1\
**Last updated:** [November 23, 2020, 2:15am UTC](https://discourse.processing.org/t/bulk-preload-images-with-different-variable-name-from-json-p5-js-web/25610 "2020-11-23T02:15:48Z")

</div>

Hi, I have a JSON file populated with “brandName” and “brandLogo” fields. I’m trying to preload 30ish logos to my project so I can display them when needed later on in the code. I’d also like to assign the images to va…

---

## [Using p5js with Angular 5](https://discourse.processing.org/t/using-p5js-with-angular-5/1971)

<div class="topic-metadata">

**Author:** [@mopy](https://discourse.processing.org/u/mopy)\
**Replies:** 3\
**Last updated:** [November 22, 2020, 3:56pm UTC](https://discourse.processing.org/t/using-p5js-with-angular-5/1971 "2020-11-22T15:56:11Z")

</div>

Could someone explain how to use p5.js in my Angular 5 project? I am pretty new to both and was unable to import and use p5js in my Angular component. I see that the type definition file exists in the p5js lib folder, bu…

---

## [How will you approach this picture?](https://discourse.processing.org/t/how-will-you-approach-this-picture/24837)

<div class="topic-metadata">

**Author:** [@Huno](https://discourse.processing.org/u/Huno)\
**Replies:** 23\
**Last updated:** [November 21, 2020, 10:15am UTC](https://discourse.processing.org/t/how-will-you-approach-this-picture/24837 "2020-11-21T10:15:20Z")

</div>

Like a lot of us, I’ve been a fan of Autechre since 2001 (I was 11) and I’ve been always amazed by their covers. There are a couple of covers that always make me think of raw code. So my question is, how will you appro…

---

## [Using mask to reveal background image](https://discourse.processing.org/t/using-mask-to-reveal-background-image/25528)

<div class="topic-metadata">

**Author:** [@andypurbrick](https://discourse.processing.org/u/andypurbrick)\
**Replies:** 2\
**Last updated:** [November 20, 2020, 4:22pm UTC](https://discourse.processing.org/t/using-mask-to-reveal-background-image/25528 "2020-11-20T16:22:06Z")

</div>

Hi, I’m trying to write a sketch that uses mask to temporarily reveal a background/bottom image when the mouse pointer moves but does not permanently draw over it. I have a sketch written based on reading docs and looki…

---

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

---

## [Is that possible to use p5.js in Swift?](https://discourse.processing.org/t/is-that-possible-to-use-p5-js-in-swift/25518)

<div class="topic-metadata">

**Author:** [@d.kudo](https://discourse.processing.org/u/d.kudo)\
**Replies:** 1\
**Last updated:** [November 18, 2020, 11:07pm UTC](https://discourse.processing.org/t/is-that-possible-to-use-p5-js-in-swift/25518 "2020-11-18T23:07:34Z")

</div>

Hi, there. is that possible to import or use p5.js project in Swift? or should I rewrite the code to Swift?

---

## [Print() no longer works into p5.js online editor?](https://discourse.processing.org/t/print-no-longer-works-into-p5-js-online-editor/25509)

<div class="topic-metadata">

**Author:** [@Laurent](https://discourse.processing.org/u/Laurent)\
**Replies:** 1\
**Last updated:** [November 18, 2020, 1:08pm UTC](https://discourse.processing.org/t/print-no-longer-works-into-p5-js-online-editor/25509 "2020-11-18T13:08:08Z")

</div>

Hi everyone, Does anyone face this problem ? In p5.js online editor, the print() function does not work anymore in the console panel of the editor. See for instance this sketch in the online editor (see alse code below)…

---

## [For loop doesn't load properly](https://discourse.processing.org/t/for-loop-doesnt-load-properly/25463)

<div class="topic-metadata">

**Author:** [@Gianni](https://discourse.processing.org/u/Gianni)\
**Replies:** 10\
**Last updated:** [November 16, 2020, 9:50pm UTC](https://discourse.processing.org/t/for-loop-doesnt-load-properly/25463 "2020-11-16T21:50:19Z")

</div>

Hello everyone! I’m working on a sketch that looks for collision between a grid of points and a random polygon. I’m trying to find a way to make sure the colliding points always match a chosen number. because the polyg…

---

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

---

## [Spacing out obstacles](https://discourse.processing.org/t/spacing-out-obstacles/25467)

<div class="topic-metadata">

**Author:** [@ninjarick](https://discourse.processing.org/u/ninjarick)\
**Replies:** 1\
**Last updated:** [November 16, 2020, 7:23pm UTC](https://discourse.processing.org/t/spacing-out-obstacles/25467 "2020-11-16T19:23:27Z")

</div>

I’ve hit another snag with my code. As of now, I have the obstacles moving towards the player at random with this code. // Spawn obstacles if (random(1) \< 0.01) { obstacle.push(new Obstacle()); } Though this c…

---

## [Calling Sketches](https://discourse.processing.org/t/calling-sketches/25457)

<div class="topic-metadata">

**Author:** [@cpw](https://discourse.processing.org/u/cpw)\
**Replies:** 2\
**Last updated:** [November 16, 2020, 12:08pm UTC](https://discourse.processing.org/t/calling-sketches/25457 "2020-11-16T12:08:19Z")

</div>

Is there a way to call a sketch from another sketch? Thanks for any pointers. Chris

---

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

---

## [Tone.js embedded/presentation does not work in Chrome browser](https://discourse.processing.org/t/tone-js-embedded-presentation-does-not-work-in-chrome-browser/25046)

<div class="topic-metadata">

**Author:** [@cpt.credible](https://discourse.processing.org/u/cpt.credible)\
**Replies:** 5\
**Last updated:** [November 12, 2020, 11:24am UTC](https://discourse.processing.org/t/tone-js-embedded-presentation-does-not-work-in-chrome-browser/25046 "2020-11-12T11:24:20Z")

</div>

Hi, I am having trouble getting a sequencer to run when embedded on a site in Chrome. E.G. this sketch runs fine in the editor: but when you try to embed or run it in presentation mode on chrome, the play button stops…

---

## [WEBGL Color Alpha Bug?](https://discourse.processing.org/t/webgl-color-alpha-bug/25080)

<div class="topic-metadata">

**Author:** [@stungeye](https://discourse.processing.org/u/stungeye)\
**Replies:** 5\
**Last updated:** [November 11, 2020, 4:46pm UTC](https://discourse.processing.org/t/webgl-color-alpha-bug/25080 "2020-11-11T16:46:16Z")

</div>

Same sketch. P5js version on the left and Java Processing version on the right. Why the color difference for: color(255, 0, 0, alpha); // alpha: 0 to 200 p5js is rendering as WEBGL. Java p5 is rendering as P3D. Do …

---

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

---

## [Is it possible to preload sounds into an array with p5 sound?](https://discourse.processing.org/t/is-it-possible-to-preload-sounds-into-an-array-with-p5-sound/25306)

<div class="topic-metadata">

**Author:** [@egg\_yolk](https://discourse.processing.org/u/egg_yolk)\
**Replies:** 2\
**Last updated:** [November 9, 2020, 10:13pm UTC](https://discourse.processing.org/t/is-it-possible-to-preload-sounds-into-an-array-with-p5-sound/25306 "2020-11-09T22:13:35Z")

</div>

I am using p5.js in a rather unconventional way where having sounds in an array would help a lot. Is it possible to do something like, function preload(){ for(i = 0; i \< songLocations.length; i++){ p5SongList\[i\] = lo…

---

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

---

## [Is there a way to running my P5.js code locally without a webserver?](https://discourse.processing.org/t/is-there-a-way-to-running-my-p5-js-code-locally-without-a-webserver/25284)

<div class="topic-metadata">

**Author:** [@GabrielVinicios](https://discourse.processing.org/u/GabrielVinicios)\
**Replies:** 1\
**Last updated:** [November 8, 2020, 5:07pm UTC](https://discourse.processing.org/t/is-there-a-way-to-running-my-p5-js-code-locally-without-a-webserver/25284 "2020-11-08T17:07:27Z")

</div>

Hi! I am developing some educational games in P5. Soon, I will bring them to you to see. Is there a way to running my P5.js code locally, without a webserver? I tought putting all the libraries (p5.js) and all my js f…

---

## [How P5.js use the Box2D of Processing?](https://discourse.processing.org/t/how-p5-js-use-the-box2d-of-processing/25272)

<div class="topic-metadata">

**Author:** [@NeoRei](https://discourse.processing.org/u/NeoRei)\
**Replies:** 2\
**Last updated:** [November 8, 2020, 5:22am UTC](https://discourse.processing.org/t/how-p5-js-use-the-box2d-of-processing/25272 "2020-11-08T05:22:27Z")

</div>

i can’t use the Box2D !Help

---

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

---

## [Why does my sketch look pixelated in Chrome?](https://discourse.processing.org/t/why-does-my-sketch-look-pixelated-in-chrome/25237)

<div class="topic-metadata">

**Author:** [@zenglenn](https://discourse.processing.org/u/zenglenn)\
**Replies:** 3\
**Last updated:** [November 7, 2020, 5:32pm UTC](https://discourse.processing.org/t/why-does-my-sketch-look-pixelated-in-chrome/25237 "2020-11-07T17:32:44Z")

</div>

Hi The sketch I’m working on has text and images that display perfectly in Safari - but in Chrome everything is pixelated. When I download the image from Chrome and open it up - it looks fine - is there anyway of fixin…

---

## [Function for a still camera? WEBGL](https://discourse.processing.org/t/function-for-a-still-camera-webgl/25249)

<div class="topic-metadata">

**Author:** [@WTnick](https://discourse.processing.org/u/WTnick)\
**Replies:** 1\
**Last updated:** [November 7, 2020, 5:01pm UTC](https://discourse.processing.org/t/function-for-a-still-camera-webgl/25249 "2020-11-07T17:01:48Z")

</div>

Hello! I started programming about a month ago. Anyways I was working on a first-person demo and decided to make it so the mouse would move the camera. To test it out I used cam.pan and made it follow mouseX and mouseY. …

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

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