Canvas 阴影效果

shadow

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>shadow</title>
</head>

<body>
    <canvas id='myCanvas' width='800' height='600'>
        your browser does not support canvas
    </canvas>
    <script type="text/javascript">
    var c = document.getElementById('myCanvas');
    var ctx = c.getContext('2d');
    ctx.shadowColor = '#ff0000';
    ctx.shadowBlur = 10;
    ctx.shadowOffsetX = 20;
    ctx.shadowOffsetY = 30;
    var img = new Image();
    img.src = 'face.jpg';
    img.onload = function() {
        ctx.drawImage(img, 0, 0);
    };
    </script>
</body>

</html>