Skip to content
Advertisement

Tag: processing

Cursor trail algorithm for p5.js

I found this little coding exercise on Processing’s website (https://processing.org/examples/storinginput.html) and decided to make a p5.js version of it. The part that I do not understand about this algorithm is how the ellipses drawn (in the trail) shrinks when variable i, which is used as the scale of the ellipse, is increasing. I suspect that it has something to do

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

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