Cax 內(nèi)置 Bitmap

2018-06-21 11:13 更新

Bitmap 用于顯示圖像,使用例子如下:

const bitmap = new cax.Bitmap(img)
stage.add(bitmap)
stage.update()

如果只傳 url 而不是 Image 對(duì)象的實(shí)例,需要這樣:

const bitmap = new cax.Bitmap('./wepay.png', ()=>{
  stage.update()
})
stage.add(bitmap)

這里需要注意小程序需要配置 downloadFile 需要配置合法域名才能正常加載到圖片。

可以設(shè)置圖片裁剪顯示區(qū)域,和其他 transform 屬性:

bitmap.rect = [0, 0, 170, 140]
bitmap.x = 200
以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)