1、canvas阴影

  1. <style>
  2. canvas {
  3. width: 500px;
  4. height: 300px;
  5. border: 1px solid;
  6. }
  7. </style>
  8. </head>
  9. <body>
  10. <canvas id="can" width="500px" height="300px"></canvas>
  11. <script>
  12. var canvas = document.getElementById("can");
  13. var ctx = canvas.getContext("2d");
  14. ctx.beginPath();
  15. ctx.shadowColor = "black";//阴影颜色
  16. ctx.shadowBlur = 30; //阴影大小,阴影是骑在线上的
  17. ctx.sahdowOffsetX = 15; //ctx.sahdowOffsetY
  18. ctx.fillRect(0,0,200,200);
  19. </script>
  20. </body>