import Taro from '@tarojs/api' ; import { MethodHandler } from '../utils/handler' ; import { findDOM } from '../utils' ; todo export const canvasPutImageData = ( { canvasId , data , x , y , success , fail , complete } , inst ) => { const handle = new MethodHandler ( { name : 'canvasPutImageData' , success , fail , complete } ) ; const el = findDOM ( inst ) as HTMLElement ; const canvas = el ?. querySelector ( `canvas[canvas-id="${ canvasId }"]` ) as HTMLCanvasElement ; try { const ctx = canvas . getContext ( '2d' ) ; ctx ?. putImageData ( data as unknown as ImageData , x , y ) ; return handle . success ( ) ; } catch ( e ) { return handle . fail ( { errMsg : e . message } ) ; } } ;