function imageLoaded()

in content/foundation/press/kit/overlays/love-apache-overlay.js [39:87]


  function imageLoaded() {
    var twibbons = ["twibbon_1"];
    var twibbonXY = [[0, 0]];
    var button = [];

    imgWidth = img.width;
    imgHeight = img.height;

    aspectRatio = imgWidth / imgHeight;

    newImgWidth = imgWidth < imgHeight ? 264 : 264 * aspectRatio;
    newImgHeight = imgHeight < imgWidth ? 264 : 264 / aspectRatio;

    dstX = newImgWidth > 264 ? ((newImgWidth - 264) / 2) * -1 : 0;
    dstY = newImgHeight > 264 ? ((newImgHeight - 264) / 2) * -1 : 0;

    // draw each of the operations
    for (var n = 0; n < twibbons.length; n++) {
      var canvas = document.getElementById("canvas_" + twibbons[n]);
      canvas.width = 400;
      canvas.height = 400;
      var ctx = canvas.getContext("2d");
      ctx.drawImage(
        img,
        0,
        0,
        img.width,
        img.height,
        68,
        68,
        newImgWidth,
        newImgHeight
      );
      ctx.drawImage(
        twibbonImg[n],
        0,
        0,
        400,
        400,
        twibbonXY[n][0],
        twibbonXY[n][1],
        400,
        400
      );

      var dataURL = canvas.toDataURL();
      document.getElementById("img_" + twibbons[n]).src = dataURL;
    }
  }