Mini Program uses canvas to generate pictures

use canvas to generate pictures in Mini Program. There are layouts such as text in the pictures, which are similar to the QR code pictures in Alipay. Does Mini Program have a similar library?

Mar.12,2021

has carried out a similar project. At present, after the dom operation (poster making), write it to canvas, and finally generate an image


do you want to achieve the screenshot function in Mini Program?


text you can wrap the text according to the width of the device and the measureText of the canvas.
at the same time, you can calculate the dynamic height of the text
let ctx = wx.createCanvasContext ("myCanvas")
draw text
draw ctx.drawImage
draw () draw
wx.canvasToTempFilePath generate picture address
wx.previewImage preview picture with scan function

Menu