Canvas--阴影

1、shadowColor:设置阴影颜色,默认值为 '#000'。与 shadowBlur 属性一起使用,来创建阴影。

 1 context.fillStyle = '#0091db'
 2 context.shadowColor = '#ff0000'
 3 for (let i = 0; i < 10; i++) {
 4     context.beginPath()
 5     context.shadowBlur = 5 * (i + 1)
 6     if (i < 5) {
 7         context.fillRect(50 + 200 * i, 50, 100, 80)
 8     } else {
 9         context.fillRect(50 + 200 * (i - 5), 250, 100, 80)
10     }
11 }

2、shadowOffsetXshadowOffsetY属性:定义阴影与形状的水平、垂直距离。

1 context.beginPath()
2 context.fillStyle = '#0091db'
3 context.shadowBlur = 5
4 context.shadowColor = '#000'
5 context.shadowOffsetX = 10
6 context.shadowOffsetY = -10
7 context.fillRect(50,50,100,80)

posted @ 2017-11-08 09:40  穿山甲到底说了什么  阅读(172)  评论(0编辑  收藏  举报