buuing / lucky-canvas

🎖🎖🎖 基于 TS + Canvas 开发的【大转盘 / 九宫格 / 老虎机】抽奖插件,🌈 一套源码适配多端框架 JS / Vue / React / Taro / UniApp / 微信小程序等,🎨 奖品 / 文字 / 图片 / 颜色 / 按钮均可配置,支持同步 / 异步抽奖,🎯 概率前 / 后端可控,🚀 自动根据 dpr 调整清晰度适配移动端

Home Page:https://100px.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError: Failed to execute 'putImageData' on 'CanvasRenderingContext2D'

vvizden opened this issue · comments

  • 你当前是什么框架(必填):taro react
  • 你使用的是哪个包(必填):@lucky-canvas/taro
  • 你当前插件的版本(必填):^0.0.14
  • 当前环境是小程序还是浏览器(选填):小程序
  • 详细描述你的bug:
    TypeError: Failed to execute 'putImageData' on 'CanvasRenderingContext2D': 3 arguments required, but only 1 present.

追踪源码到这行:

image

rectInfo 长度是 4,slice(4, 6) 的话,putImageData 后面两个参数自然就缺失了

尝试在 taro-react 中使用图片圆角,formatter 函数时发现了这个问题

commented

我想看看你的formatter是怎么用的, 因为理论上小程序是无法使用这个属性的吧

我想看看你的formatter是怎么用的, 因为理论上小程序是无法使用这个属性的吧

{
  width: '80%',
  top: '20%',
  src: 'https://xxx/WechatIMG2720230111102023.jpeg',
  formatter(img) {
    const { width, height } = img
    const canvas = Taro.createOffscreenCanvas({
      type: '2d',
      width,
      height,
    })
    const ctx = canvas.getContext('2d') as any
    roundRectByArc(ctx, 0, 0, width, height, 50)
    ctx.clip()
    ctx.drawImage(img, 0, 0, width, height)
    return canvas
  },
},

理论上我也不知道行不行,就是按你的例子尝试写的

commented

我的例子是给pc端用的...小程序我没调试过, 估计有问题, 他参数都不一致, 缺斤少两的很正常, 所以我基本都放弃维护小程序了

我的例子是给pc端用的...小程序我没调试过, 估计有问题, 他参数都不一致, 缺斤少两的很正常, 所以我基本都放弃维护小程序了

了解🫡