1.0.1 • Published 4 years ago

play-picture-with-canvas v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

参数说明

参数类型是否必须默认值说明
canvaselement-canvas对象
imgListarry-图片资源列表
timingnumber-一帧的时长
swidthnumber-被剪切图像的宽度
sheightnumber-被剪切图像的高度
sxnumber0开始剪切的 x 坐标位置
synumber0开始剪切的 y 坐标位置
xnumber0在画布上放置图像的 x 坐标位置
ynumber0在画布上放置图像的 y 坐标位置

|

示例用法

import { playPictureWithCanvas } from 'play-picture-with-canvas'

// 图片资源列表
let imgList = []

for (let i = 0; i < 140; i++) {
    const num = String(i).padStart(String(140).length, 0)
    const img = require('@/static/img/example/person/2_00' + num + '.png')
    // 或直接引用网络资源路径: cost img = 'http://xxx.net/xxx/xxx.png'
    imgList.push(img)
}

// 返回一个清除定时器的方法
const clearTimer = playPictureWithCanvas(canvans, imgList, 66, 889, 500)

// 在需要清除的地方调用一下即可
clearTimer()