November 2011
Intermediate to advanced
348 pages
7h 2m
English
Unlike the bubble recipe, whose width and height oscillate as a function of time, in this recipe we'll create a pendulum whose angle oscillates as a function of time.

Follow these steps to swing a pendulum back and forth:
Animation class:<head>
<script src="animation.js">
</script>Animation object and get the canvas context: <script>
window.onload = function(){
var anim = new Animation("myCanvas");
var canvas = anim.getCanvas();
var context = anim.getContext();var amplitude = Math.PI / 4; // 45 degrees var period = 4000; // ms var theta = 0; var ...
Read now
Unlock full access