Skip to content

Clarified interval formula #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: gh-pages
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions examples/drawing_animate.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,16 @@ function smiley(x, y) {
function drawing() {
// The angle variable stores the current rotation
var angle = 0;
// Draw twenty frames per second (20 * 50 = 1000 milliseconds)
setInterval(frame, 50);

// We want to draw twenty frames per second
var framesPerSecond = 20;

// 1 second equals 1000 milliseconds.
var frameInterval = 1000 / framesPerSecond;

// setInterval expects the interval in milliseconds
setInterval(frame, frameInterval);

function frame() {
// Clear the screen
clear();
Expand Down