fill和stroke英文釋義
fillStyle & strokeStyle
背景顏色可以通過fillStyle來實現,描邊顏色可以通過strokeStyle來實現。
fillText &strokeText
fillText //在畫布上畫文本並填充預設定的fillStyle背景顏色
strokeText //在畫布上畫文本並填充預設定的strokeStyle邊框色
fillRect & strokeRect
fillRect // 在畫布上繪製背景已經着色了的矩形
strokeRect //在畫布上繪製邊框已經着色了的矩形
rect
rect 只是先創建矩形,在畫布中不會體現,只有在調用fill()或者stroke()之後纔會體現
fill & stroke
fill // 畫出含有背景顏色的矩形
stroke // 畫出含有邊框顏色的矩形
總結
畫矩形和填充顏色可以分開來寫,但是要注意順序,先設定填充或者描邊的顏色,再填充或描寫
可以通俗理解爲:(先選好哪隻顏色的筆fillStyle | strokeStyle,然後下手畫 fillRect | strokeRect。)
rect相當於在腦海裏面想象的畫什麼東西,這個可以在拿畫筆之前,可以在拿畫筆之後