Inset-shadow on HTML5 canvas image

后端 未结 5 1893
遥遥无期
遥遥无期 2021-01-03 15:19

I\'ve seen this question before but the answers given are for canvas images that have been drawn on via path however, i\'m drawing an image.

Is it possible to creat

5条回答
  •  伪装坚强ぢ
    2021-01-03 15:37

    Inspired by K3N's answer, I've created Inset.js for this exact situation!

    Inset.js

    Only requires setting ctx.shadowInset = true;

    For example: http://codepen.io/patlillis/pen/ryoWey

    var ctx = canvas.getContext('2d');
    var img = new Image;
    img.onload = function() {
      ctx.shadowInset = true;
      ctx.shadowBlur = 25;
      ctx.shadowColor = "#000";
      ctx.drawImage(this, 0, 0);
    }
    img.src = "http://i.imgur.com/Qrfga2b.png";
    

提交回复
热议问题