https://github.com/ayamflow/fps-control
A naive FPS throttler implementation
https://github.com/ayamflow/fps-control
Last synced: 12 months ago
JSON representation
A naive FPS throttler implementation
- Host: GitHub
- URL: https://github.com/ayamflow/fps-control
- Owner: ayamflow
- License: mit
- Created: 2017-06-08T23:26:35.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2022-05-03T16:51:19.000Z (about 4 years ago)
- Last Synced: 2025-05-23T19:48:40.779Z (about 1 year ago)
- Language: JavaScript
- Size: 1.95 KB
- Stars: 16
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
fps-control
===
### A naive FPS throttler implementation
### Installation :package:
`npm i fps-control -S`
### Usage & example :floppy_disk:
```
import FPSControl from 'fps-control'
let fps = new FPSControl(30);
function update() {
if (!fps.check()) return;
// Drawn at 30FPS
ctx.drawImage(sprite.img, sprite.x, sprite.y);
}
```
* `new FPSControl(framerate)`
Returns a new instance sync to a given `framerate` value
* `instance.set(framerate)`
Sets `framerate` as the target framerate. Some examples values are 60 (no throttling), 30 (1/2 throttling).
* `instance.check()`
Returns `true` if the current frame matches the target framerate, `false` otherwise.
### License :pencil:
MIT.