Canvas 给图形绘制阴影

/**
 * 图形绘制阴影
 */
function initDemo6() {
    var canvas = document.getElementById("demo6");
    if (!canvas) return;
    var context = canvas.getContext("2d");
    context.fillStyle = "#02c9e5";
    context.shadowOffsetX = 10; // 阴影横向位移
    context.shadowOffsetY = 10; // 阴影纵向位移
    context.shadowColor = 'rgba(100, 100, 100, 0.5)'; // 阴影颜色
    context.shadowBlur = 7.5; // 阴影模糊范围
    context.fillRect(25, 25, 300, 300);
}

 

posted @ 2017-04-11 11:13  就只是小茗  阅读(1078)  评论(0编辑  收藏  举报