Skip to content
This repository was archived by the owner on Jun 19, 2025. It is now read-only.

Clarified interval formula #38

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