Canvas--矩形

Canvas提供了一个直接绘制矩形的方法:rect(x,y,width,height)

1 context.rect(50,50,100,100)
2 
3 context.lineWidth = 10
4 context.strokeStyle = '#0091db'
5 context.fillStyle = '#00ff00'
6 
7 context.stroke()
8 context.fill()

  绘制矩形的其它方法:fillRect(x,y,width,height)、strokeRect(x,y,width,height)

1 context.lineWidth = 10
2 context.strokeStyle = '#0091db'
3 
4 context.strokeRect(50,50,100,100)

1 context.lineWidth = 10
2 context.fillStyle = '#00ff00'
3 
4 context.fillRect(50,50,100,100)

posted @ 2017-11-02 12:00  穿山甲到底说了什么  阅读(152)  评论(0编辑  收藏  举报