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
Tag: processing
How to display text sequentially using P5.js deviceMoved() function?
I am currently trying to make a program where the text changes as the phone moves every couple value(s) using the P5.JS deviceMoved() function. (the gif below displays how i wanted the text to change eventually as the device moved) As seen on the code below, I’ve put all the text in the array and I wanted to change the
How can I share methods that call P5.js functions between two different sketches/canvases?
Is there a way to share common methods between two different sketches/canvases? It only works if I’m not referencing any P5.js methods. In the example below there are two sketches and each is loaded into a different canvas element using the instance mode for P5.js. I’d like to be able to write a function that uses P5.js methods AND is
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,
Creating an “Animated” Spiky Ball in Processing.js
For my class, I’m creating a project in which a level includes a cursor in the form of an ellipse that reacts to a mousePressed command by having spikes protrude from within the ellipse and then recede back into the ellipse. The code for my cursor is right here: My teacher suggested I use createShape (TRIANGLE) within the ellipse and