File size: 1,127 Bytes
ae4627d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | // Some variables
var FPS, message, rotation, abom, abomctx;
// Set some values
FPS = 20;
rotation = 0;
message = "Comic Sans ROCKS!";
// Functions
function drawText(ctx, message, rot) {
ctx.save();
ctx.translate(window.innerWidth*Math.random(), window.innerHeight*Math.random());
ctx.rotate(rot*Math.PI/180);
ctx.fillStyle = "white";
ctx.strokeStyle = "blue";
ctx.shadowBlur = 20 * Math.random() + 10;
ctx.shadowColor = "green";
//ctx.shadowColor = "rgb("+255*Math.random()+","+255*Math.random()+","+255*Math.random()+")";
ctx.shadowOffsetX = 20 * Math.random() - 10;
ctx.shadowOffsetY = 20 * Math.random() - 10;
ctx.font = "bold " + parseInt(120 * Math.random() + 30) + "pt Comic Sans MS";
ctx.fillText(message, 0, 0);
ctx.strokeText(message, 0, 0);
ctx.restore();
} // function drawText
// Fullscreen the canvas
abom = document.getElementById('abom');
abom.width = window.innerWidth-5;
abom.height = window.innerHeight-5;
// Get our context out, and go to town
abomctx = abom.getContext('2d');
setInterval(function(){
drawText(abomctx, message, rotation);
rotation = 360.0 * Math.random();
}, 1000/FPS);
|