dg.js cosine wave animation example - Djordje Rakonjac / december, 2015
Cosine wave function example. Try zooming in and out (mouse scroll on canvas).
var canvas = dg.Canvas("testcanvas", { border: "1px solid #ccc"});
var axes = dg.Axes([canvas.width() / 4, canvas.height() / 1.5]).hide(false);
var f = dg.Function(function(x) { return Math.cos(x); }, dg.color.rand()).step(0.1);
var interval = setInterval(animate, 30);
var step = 0.05;
var t = 0;
function animate() {
f.setF(function(x) { return Math.cos(x) * Math.sin(t); });
t += step;
}