微信小程序開發(fā)文檔
/ 微信小程序canvas中使用translate對坐標(biāo)原點(diǎn)進(jìn)行縮放
微信小程序canvas中使用translate對坐標(biāo)原點(diǎn)進(jìn)行縮放
translate
定義
對當(dāng)前坐標(biāo)系的原點(diǎn)(0, 0)進(jìn)行變換,默認(rèn)的坐標(biāo)系原點(diǎn)為頁面左上角。
參數(shù)
參數(shù) | 類型 | 說明 |
---|---|---|
x | Number | 水平坐標(biāo)平移量 |
y | Number | 豎直坐標(biāo)平移量 |
例子
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()