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
2 answers

Two arrays equality test

This is more of a logic question. I can't figure out what is wrong with my function // This function is meant to check if 3 pixels // are colored and therefore if the canvas is full function checkIfFull() { let emptyPixel = [0, 0, 0, 0]; …
1
vote
1 answer

Instantiating object in p5.js instance mode

I'm trying to instantiate an object on p5.js instance mode, however I've got lots of errors on the object's properties and functions. var sketch1 = function(p){ var dados = []; p.setup = function(){ var canvas = p.createCanvas(640,…
Leonardo
  • 13
  • 4
1
vote
1 answer

trying to store array values for an 'undo' function in p5js

I've made a sort of drawing application in p5js - I have a multidimensional array called points which consists of shapes, which have x,y coordinates for the points of shapes. So: shapes[0][0] = [10,10] shapes[1][3] = [47,98] etc. I have a…
mheavers
  • 29,530
  • 58
  • 194
  • 315
1
vote
1 answer

Loading images uploaded with a form not showing

The user uploads images with a form. The images should all be displayed in the canvas. Only one of multiple images shows. Maybe the images are not properly loaded? html: let value = 0; var images = []; function setup() { createCanvas(320,…
robinpdev
  • 25
  • 4
1
vote
1 answer

Calling a class in p5 that won't loop?

I’m currently working on a game with p5 which will include some pretty complicated stuff… at least for me anyway. How do I call a class without it looping in p5? Consider my following code: function draw() { lumberjack.clicked(); } class…
Maximilian
  • 537
  • 7
  • 18
1
vote
3 answers

Why will my animation not work if I declare my variable locally?

I'm quite new to JS so please excuse my ignorance but I can't figure out why my animation if statement doesn't work if I declare my speed variable locally in the move() function. If I don't declare the speed variable globally, the girl gets to the…
Maximilian
  • 537
  • 7
  • 18
1
vote
1 answer

P5.js send request to Azure Custom Vision

So, I take an image from a canvas using p5js and i want to send it to the Azure Custom Vision Service(the code bellow). Is p5 image even the same as the normal js image(like when you take a capture from a video) ? My problem is when i send a form…
1
vote
1 answer

Issues with keyIsDown() in p5js

I'm trying to make a basic 2d game with p5js and p5.play. An issue that seems to cause issues every time I try to do anything is the keyIsDown function. Is there a way to determine if a key is down before pressing it? If I used upKey =…
DocRatMD
  • 11
  • 2
1
vote
1 answer

How get return of value from the callback function of loadJSON in P5.js

Generally I have this code with Javascript and P5.js: Just for get data from url and work with it with other function even don't need to reload it many times. function setup() { var main = document.getElementById('main'); var start =…
user11091596
1
vote
0 answers

How do I fix "TypeError: vue_p5__WEBPACK_IMPORTED_MODULE_8__.createCanvas is not a function" when trying to use p5.js inside a nested vue component?

I am currently trying to create this app (https://repl.it/@prophetorpheus/collaborative-sketch) in vue.js as a vue component of my App.vue file. When i am trying to call the setup function inside my vue component ( i called it Whiteboard.vue) i get…
Lit Llama
  • 11
  • 1
1
vote
1 answer

Why processing keeps saying "SyntaxError : Expected ; but found size" but it run just ok in p5.js online editor?

The processing console keeps saying Syntax Error: Expected ; but found size. I have copy pasted my code to p5.js online editor and it ran just fine. var ur; var x; function setup() { createCanvas(400,400); x=width; ur = getURL(); } function…
Hadi KAR
  • 384
  • 3
  • 11
1
vote
2 answers

Getting pixel values of images in p5js

I have been working on some code that is supposed to draw a dot(ellipse) on each pixel that is black. I am new to the get function, and suspect that I might have made a mistake using it. Does anyone know why my code cannot successfully "dot" the map…
Bob Timmon
  • 81
  • 1
  • 6
1
vote
3 answers

How to draw an overlapping curve between two bezier points on existing curve p5.js

I'm using p5.js to draw a bezier curve. I want to draw a shorter, partially overlapping curve in another color. Basically, I want to change the color of the curve in certain places. I was able to draw the first curve and get two bezier points from…
glaemart
  • 129
  • 1
  • 10
1
vote
1 answer

How do I create a line between each point?

I want to create a tool similar to the pentool in photoshop/illustrator, but only using straight line. How do i create a line between each point? My first instinct was to push them into an Array, but I'm stack here, what do I do next? Code:…
Alex Arek
  • 57
  • 7
1
vote
1 answer

Some problems with generating the Mandelbrot set

I wrote a program on processing to generate the mandelbrot set and was successful but once i changed c to a constant complex number, I was unable to get any patterns with my program. I must be having a blind spot since I can't seem to debug my…
Him Chan
  • 41
  • 1