A canvas text-shadow createPattern example

function canvasReady() {
  draw(document.getElementById('canvas').getContext('2d'));
}
function draw(ctx) {
  // create new image object to use as pattern
  var img = new Image();
  img.onload = function(){
    // create pattern
    var ptrn = ctx.createPattern(img,'repeat');

    ctx.textBaseline = "top";
    ctx.font = "36pt Arial";
    ctx.fillStyle = ptrn;
    ctx.strokeStyle = ptrn;

    var text = setShadow(ctx, "black", 10, 10, 4);
    ctx.fillText("fillText: "       + text, 20, 20);
    ctx.strokeText("strokeText: "   + text, 20, 80);

    // prevent IE6 memory leak
    img = null;
  }
  img.src = '../img/sky.jpg';
}
function setShadow(ctx, color, ox, oy, blur) {
  ctx.shadowColor = color;
  ctx.shadowOffsetX = ox;
  ctx.shadowOffsetY = oy;
  ctx.shadowBlur = blur;
  return [color, ox, oy, blur].join(", ");
}