Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change frame rate in paper.js

In Paper.js, is it possible to change the frame rate of the onFrame(event)function? The paper.js website tutorial says the function is by default called 60 times per second, but it does not include if it is possible (and how) to change the frame rate of this function.

like image 590
Jiri Avatar asked Jan 15 '15 16:01

Jiri


1 Answers

No, but you can easily skip frames in the code within your onFrame function.


Example:

The following code emulates a 30 fps frame rate by skipping frames with an odd number, effectively halving the frame rate.

function onFrame(event) {
  if (event.count % 2 === 0) {
    //your code here
  }
}
like image 154
nicholaswmin Avatar answered Oct 22 '22 01:10

nicholaswmin