WeChat アプレット開発ドキュメント
/ 微信小程序canvas中使用translate對坐標原點進行縮放
微信小程序canvas中使用translate對坐標原點進行縮放
translate
定義
對當前坐標系的原點(0, 0)進行變換,默認的坐標系原點為頁面左上角。
參數(shù)
參數(shù) | 類型 | 說明 |
---|---|---|
x | Number | 水平坐標平移量 |
y | Number | 豎直坐標平移量 |
例子
const ctx = wx.createCanvasContext('myCanvas') ctx.strokeRect(10, 10, 150, 100) ctx.translate(20, 20) ctx.strokeRect(10, 10, 150, 100) ctx.translate(20, 20) ctx.strokeRect(10, 10, 150, 100) ctx.draw()