小程序图片相关操作
q1:在图片上根据传过来的坐标绘制图形
imageWidth = res.width;
imageHeight = res.height;
wx.getSystemInfo({
success (res) {
windowWidth = res.windowWidth
windowHeight = res.windowHeight
}
})
let a = windowWidth/imageWidth/2;
let b = windowHeight/imageHeight/2;
let widRate = a.toFixed(2);
let heiRate = b.toFixed(2);
const ctx = wx.createCanvasContext('shareCanvas');
let result = JSON.parse(options.item)
let coordinate = result.coordinate
let first = coordinate[0];
let second = coordinate[1];
let thrid = coordinate[2];
let fourth = coordinate[3];
ctx.drawImage(imageUrl, 0, 0,windowWidth/2,windowHeight/2);
ctx.moveTo(first[0]*widRate, first[1]*heiRate)
ctx.lineTo(second[0]*widRate, second[