We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi Guys,
I have a question about Javascript and function draw ()
.
function draw ()
plays my animation in the loop at a very high frequency. Is it possible to make this frequency slower?
My animation changes with the help of an input number, which changes so fast! But I dont want the animation to change all the time, so my idea is:
1) I have to make the loop frequency slower so that only every fourth input number for example is considered.
Or 2) I would say that the input number is for example measured for 4 seconds and then an average number is calculated.
I hope you understand my question! I'm not so fit in the programming language yet!
Many greetings Sarah
Answers
https://p5js.org/reference/#/p5/frameRate
https://p5js.org/reference/#/p5/frameCount
thanks for your reply! :) I tried to use
frameRate()
, writing it insetup
, but it didn't changed the frequency. Did I missed anything in the code?Callback is named draw(), not draw_js(): L-)
https://p5js.org/reference/#/p5/draw
As much as possible, create a runnable sample when asking folks for help.
Even better, host the runnable sample here: *-:)
https://OpenProcessing.org/sketch/create
my code is running perfectly with
draw_js
! when I change the name it's not :( but probablyframeRate()
refers to onlyfunction draw()
.thanks for your reply! Maybe I have to change my code before I can work with
frameRate
...@SarahMarlene -- re:
That is correct. Unless something else in your code is calling draw_js explicitly, then the code you are putting in draw_js does nothing. Only draw (not functions with the name draw in them, like myDraw, drawIt, draw_something) is the main function in Processing that is called every frame.
@SarahMarlene - if accurate timing is important then you need to use time-based animation - look it up ;)
Basically store the time when your sketch starts and each frame (inside
draw()
) check against current time until the target is met...