The question is
This is exactly what I need, but it again uses $("#test"). Can I change this so that value is just a JavaScript value and that it will scroll across a canvas?
And yes you can, you can just get rid of the jQuery inside the callback for animate()
and use the now
variable for anything you'd like, for instance moving text on a canvas
$({ left: 300 }).animate({ left: 10 }, {duration: 5000, step: function(now, fx) {
moveMyFrackingCanvas(now);
}});
function moveMyFrackingCanvas(val) {
var c=document.getElementById("myCanvas");
c.width = c.width;
var ctx=c.getContext("2d");
ctx.font="30px Verdana";
var gradient=ctx.createLinearGradient(0,0,c.width,0);
gradient.addColorStop("0","magenta");
gradient.addColorStop("0.5","blue");
gradient.addColorStop("1.0","red");
ctx.fillStyle=gradient;
ctx.fillText("Holy Crap!", val, 90);
}