partimation
基于canvas的一个粒子动画库
通过配置文字或者图片以及相关动画参数,只需简单的函数调用就能进行期望的粒子动画
本地demo
clone git@github.com:kmCha/partimation.gitcd partimationnpm run dev
安装
npm install --save partimation
<script src="http://www.kmhaoshuai.com/public/partimation.js"></script>
使用方法
- 通过在html中引入partimation.js之后
typeof windowPartimate === 'function'
- 通过在node中用commonJS的require引入partimation.js
var Partimate =
初始化动画对象
var particle = '#canvas' // 输入参数为canvas元素的id
配置文字
particle
其中textX
可以为function,文字的宽度会作为参数传入该函数中,方便定位
{ return width + 200 }
配置图片
particle
配置动画
particle
绘制静态图
particle
该方法返回一个promise对象,方便在静态图绘制完成之后进行某些操作
particle
开始粒子动画
particle
该方法返回一个promise对象,方便在粒子动画完成之后进行某些操作
particle
清除画布
particle
清除文本、图像配置
particleparticle