ctx = uni.createCanvasContext(this.id, this)
ctx.drawImage('/static/image/invitaion/postcard_default.png', 0, 0, this.width, this.height)
ctx.draw()
let width = this.width 1.5
let positionY = 270
ctx.drawImage('/static/image/invitaion/poster_bottom.png', this.width / 2 - width / 2, positionY, width,
this
.height)
ctx.draw(true)
let logoWidth = 50;
ctx.drawImage('/static/image/logo.png', this.width / 2 - logoWidth / 2, positionY + 30, logoWidth,
logoWidth)
ctx.draw(true)
ctx.setFontSize(10)
ctx.setTextAlign('center')
ctx.setFillStyle('#000000')
ctx.fillText('布丁影视', this.width / 2, positionY + 30 + 70)
let top = positionY + 30 + 70;
let startX = this.width / 2 - (this.qrcodeSize + this.margin 2) / 2
let backgroundColor = '#ffffff'
let foregroundColor = '#000000'
ctx.drawImage('/static/image/invitaion/poster_qr_bg.png', startX, top, this.qrcodeSize + this.margin 2,
this.qrcodeSize + this.margin 2)
for (var row = 0; row < this.modules.length; row++) {
for (var col = 0; col < this.modules.length; col++) {
// 计算每一个小块的位置
var x = col this.tileSize + this.margin
var y = row this.tileSize + this.margin
var w = this.tileSize
var h = this.tileSize
var style = this.modules[row][col] ? foregroundColor : backgroundColor
ctx.setFillStyle(style)
ctx.fillRect(startX + x, top + y, w, h)
}
}
ctx.setFontSize(14)
ctx.setTextAlign('center')
ctx.setFillStyle('#000000')
ctx.fillText('邀请码:' + this.code + '(长按复制)', this.width / 2, positionY + 30 + 70 + 115)
ctx.draw(true)
ctx.save()
1 个回复
BoredApe - 有问题就会有答案。
请上传一个能重现问题的测试工程