canvas实现粒子的拖尾效果
/**
* @Author SuZhe
* @DateTime 2019-03-15
* @desc 兼容 requestAnimFrame
* @return {[Function]} requestAnimFrame不兼容的浏览器使用定时器代替
*/
window.requestAnimFrame = (function(){
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
function( callback ){
window.setTimeout(callback, 1000 / 60);
};
})();
/**
* @Author SuZhe
* @DateTime 2019-03-15
* @desc 椭圆动画效果 star运动
* @param {[Object]} canvasId [画布布id]
*/
function CanvasAnimation(param){
if(param.ele){
this.canvas = param.ele;
this.cxt = this.canvas.getContext('2d');
this.param = param;
if(param.type){
//star
this.starArr = [[],[],[],[]]; //star数量集合
this.step = [80,-40,40,260]; //步长位置集合
this.color = ['230,116,182'