canvas设置阴影
-
属性
shadowOffsetX = float 阴影向右偏移量 shadowOffsetY = float 阴影向下偏移量 shadowBlur = float 阴影模糊效果 shadowColor = color 阴影颜色
-
设置阴影
const canvas = document.getElementById('canvas'); const ctx = canvas.getContext('2d'); ctx.shadowOffsetX = 10; ctx.shadowOffsetY = 10; ctx.shadowBlur = 10; ctx.shadowColor = 'rgba(0, 0, 0, 0.5)'; ctx.fillRect(25, 25, 100, 100);