Giter Club home page Giter Club logo

canvas-frame-player's Introduction

CanvasFramePlayer 模块

使用方法

/* 使用npm */
npm install --save canvas-frame-player
/* 使用bower */
bower install --save canvas-frame-player
/* 网页直接调用 */
<script src="dist/frame-player.min.js"></script>

本地测试

  • 安装依赖
npm install
  • 启动服务
npm start

配置属性

framePlayer.init({
  nodeName: '#canvas',
  nodeClass: '',
  width: 750,
  height: 1207
});
  • nodeName: canvas外层元素
  • nodeClass: canvas外层元素样式类名
  • width: (default: 750px) canvas宽度
  • height: (default: 1207px) canvas高度

方法调用

  • 加载序列帧图片
/**
 * @param {Array} frames 序列帧数组
 * @param {String} tag 序列帧索引
 */
framePlayer.loadFrame(frames, tag);
  • 播放序列帧
/**
 * @param {String} tag 序列帧索引
 * @param {Number} duration 持续时间,单位ms
 * @param {Number} times 动画播放次数 [times<0:无限次, times=0:不播放, times>0:播放times次]
 * @param {Function} onPlayStart 开始播放回调函数
 * @param {Function} onPlayEnd 结束播放回调函数
 */
framePlayer.play(tag, duration, times, onPlayStart, onPlayEnd);
  • 清除屏幕内容
framePlayer.clear();
  • 停止动画
framePlayer.stop();

canvas-frame-player's People

Contributors

ogoss avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.