Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

In the WeChat program API, the image is drawn using drawImage, and the image remains the original size


May 19, 2021 WeChat Mini Program Development Document


Table of contents


In the WeChat program API, the image is drawn using drawImage, and the image remains the original size Drawing interfaces and methods

canvasContext.drawImage


Defined

Draws the image so that it remains the original size.

Parameters

Parameters Type Description
imageResource String The picture resource to draw
Number The x coordinates in the upper left corner of the image
Y Number The y coordinates in the upper left corner of the image
width Number The width of the image
height Number The height of the image

Example

const ctx = wx.createCanvasContext('myCanvas')

wx.chooseImage({
  success: function(res){
    ctx.drawImage(res.tempFilePaths[0], 0, 0, 150, 100)
    ctx.draw()
  }
})

In the WeChat program API, the image is drawn using drawImage, and the image remains the original size

In the WeChat program API, the image is drawn using drawImage, and the image remains the original size Drawing interfaces and methods