gsap三维方块塌陷动画矩阵效果代码
代码语言:html
所属分类:动画
代码描述:gsap三维方块塌陷动画矩阵效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> html, body { width:100%; height:100%; overflow:hidden; background:#000; padding:0; margin:0; } </style> </head> <body> <canvas class="c"></canvas> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/gsap.3.5.2.js"></script> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/zepto.min.js"></script> <script> var c = $('.c')[0], ctx = c.getContext("2d"), cw = 0, ch = 0, hue = 180, img = new Image(), img2 = new Image(), nCubes = 0, cubes = [], Cube = function(index, _x, _y, _s){ //console.log(_x,_y) this.img = img; this.img2 = img2; this.scale = _s; this.x = _x; this.y = _y; this.z = this.img2_opacity = 0; this.draw = function(){ ctx.translate(this.x, this.y + this.z); ctx.drawImage(this.img, -100 / 2 * this.scale, -200 / 2 * this.scale, 100 * this.scale, 200 * this.scale); ctx.globalAlpha = this.img2_opacity; ctx.drawImage(this.img2, -100 / 2 * this.scale, -200 / 2 * this.scale, 100 * this.scale, 200 * this.scale); ctx.globalAlpha = 1; ctx.translate(-this.x, -(this.y + this.z)); } this.draw(); }; img.src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAADIBAMAAADsElnyAAAAJFBMVEVHcEw+Pj5aWloQEBAZGRleXl6AgIDAwMBwcHCampq7u7tzc3M0sGdFAAAABXRSTlMAp/UwQ5FLsO8AAADxSURBVHgB7c9HcQRhDITRn8NgMABDWAjO6ewMYLgsWef8akelk.........完整代码请登录后点击上方下载按钮下载查看
网友评论0