Questions tagged [p5.js]

p5.js is a JavaScript library that starts with the original goal of processing, to make coding accessible for artists, designers, educators, and beginners, and reinterprets this for today’s web.

p5.js is a JavaScript library that starts with the original goal of processing, to make coding accessible for artists, designers, educators, and beginners, and reinterprets this for today’s web. p5.js has a full set of drawing functionality too.

See also:

3071 questions
1
vote
1 answer

P5.js mousePressed() function not working :/

I have all of p5 installed and that is working fine, however whenever I come to use mousePressed() it does not work (keyPressed does not work either). Here is the part with the problem: //press play button if (mouseX > 120 && mouseX < 480 &&…
Alfie Atkinson
  • 58
  • 1
  • 10
1
vote
0 answers

ReferenceError: process is not defined, Error in heroku app with node and sockets.io

Just deployed an app (https://socket-draw-app.herokuapp.com/) on Heroku but am getting this error: ReferenceError: process is not defined. in a javascript file: sketch.js. I am using the p5.js library. Code below (firstly the sketch.js and then my…
Louis
  • 11
  • 2
1
vote
2 answers

Making an object move toward the cursor - JavaScript - p5.js

I am new to JavaScript and wanted to make a simple script in which an object (a square in this case) moves towards the cursor. The idea is that the square traces the cursor, slowing down as it gets closer to it. So far, my code looks like this: var…
frijnsje
  • 33
  • 2
  • 6
1
vote
1 answer

Accessing array give undefined p5.js

this is my second attempt at this question, hopefully, I can be a little clearer as to my problem. I have an initial p5.js setup: // Setup empty array (I beleive 'position' this is in the global scope?) let position = [] //p5 setup function…
James
  • 1,355
  • 3
  • 14
  • 38
1
vote
1 answer

p5.js: resize canvas height when div changes height

I'm trying to make the canvas with p5.js resize together with a div in which it is in when clicking on a button that extends this div giving it additional height. I don't need the canvas to reload, instead I just need it to add some additional…
Kaori
  • 49
  • 1
  • 7
1
vote
1 answer

P5.js updatePixels() doesn't work

I want to update each pixel to red, so this is my code const canvasWidth = 800 const canvasHeight = 600 function setup() { createCanvas(canvasWidth, canvasHeight) loadPixels() let xoff = 0 for (let x = 0; x < canvasWidth; x++) { let…
hh54188
  • 14,887
  • 32
  • 113
  • 184
1
vote
1 answer

How to create multiple objects in one single frame? (Creative Coding)

I've been starting creative coding and now got a little problem: I wrote a class that builds a single "Raindrop" and with an array and a for loop, I managed to make a rainy-like animation. But for now, only 1 raindrop is spawned per frame. But I…
1
vote
1 answer

p5.speech.js continuous won't become true

I've been playing around with p5.speech.js the past few days. I am able to record myself for short periods of time but it stops short. I later learned that there is a continuous bool that allows you to keep recording so I decided to implement it. I…
Asori12
  • 133
  • 1
  • 14
1
vote
1 answer

How to convert Ints to Strings in p5.js

I have looked into JS and the P5.js references and I can't figure out what's wrong with this code. I'm using p5.js with the DOM and Sound libraries var year = 0 var yearST function setup() { createCanvas(1000, 750); } function draw() { …
1
vote
1 answer

Uncaught reference error, "..." is not defined

I'm trying to load 3 characters from 5 difference websites and a concatenate them into one string, even though I'm using a try & catch statement the strings say'uncaught reference error' and any codes with numbers cause a 'unexpected tokens error'.…
1
vote
0 answers

Function Scope in P5.js

I am using the p5.js library as the basis for my program due to its ease of implementing visual features to javascript, however I have run into a bit of trouble. I am wanting to create multiple canvases within the same file to be displayed on an…
user4168341
1
vote
1 answer

Text animation with p5.js and js lagging

I have the following code which uses parts of the p5.js library to animate some text in a fade in - fade out manner (which keeps looping indefinetely), i also inserted an image to make things clearer. The problem is that after the first loop is done…
mitseas
  • 45
  • 5
1
vote
4 answers

p5 resize window without clearing the background

The following code makes use of the p5dom add-on to position the canvas in the centre of the window. To dynamically resize the canvas I'm using the windowResized() function. I want to keep the background function in setup. How do I prevent the…
James
  • 1,355
  • 3
  • 14
  • 38
1
vote
1 answer

p5 understanding an function parameter

in an example given on the p5 Site a parameter (I think that's the correct term) is used 'function(other)' which I can't quite understand. I appreciate you will need the full code which is available from the above link. Anyone care to explain would…
James
  • 1,355
  • 3
  • 14
  • 38
1
vote
1 answer

Calling setup() and draw() in a callback after async data is loaded

I am trying to use p5.js for my project, but I have a problem figuring out how I could invoke the setup() and draw() functions in a callback function. My code looks something like this: const sentence = "was a French statesman and military leader…
Jousi
  • 456
  • 4
  • 26
1 2 3
99
100