Skip to content
Advertisement

Tag: p5.js

P5 try to factorize Graphics and Canvas code

I want to factorize code for drawing same thing in a graphics or in the standard canvas. ( In my real program, i want to have autonomous class that draw themselves in some context given at construction time ) I cannot find some equivalent from canvas that can match graphics instructions except line. In the following, i try to give

How to use windowWidth and windowHeight outside of setup()?

I need the screen dimensions for a project, but trying windowWidth and windowHeight yields an error saying I can’t use them outside of setup(). I also tried defining the windowWidth and Height to a new constant, but it simply says the constant has not been defined. Here’s the current state of my code (doesn’t work, but gives a pretty good

How to draw a star in P5.js?

I’m trying to make a class “star” with a method inside of it that, at given coordinates and size, draws a star. Something like rect() or ellipse() functions. How can make it? Answer

Passing value from p5 sketch to React (with react-p5-wrapper)

I have a p5 webcam video prediction system working right now. Currently, I’m trying to plug this into a React app to create a fuller web app. My problem is, the prediction is now only made in my p5 sketch, I want the prediction value to be passed into React’s App.js for further constructions. Is there any method of doing

p5.js how to freeze canvas?

I try to do something like that : But i want to “freeze” this canvas, so if i load the page i will have 30 rect() at a random height between 30 and 120. Answer One option would be to use noLoop() method inside setup function that will stop draw method loop. Note that with using noLoop and loop methods,

Advertisement