canvas球体走光运动效果
代码语言:html
所属分类:动画
代码描述:canvas球体走光运动效果
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> * { margin: 0; padding: 0; border: 0; background: #000 } canvas { position: relative; top:50%; left:50%; margin-left:-50vmin; width:100vmin; height:100vmin; overflow:hidden; } </style> </head> <body translate="no"> <canvas></canvas> <script> var canvas, ctx, max, p, count; window.onload = function () { var a, b, r; canvas = document.getElementsByTagName('canvas')[0]; ctx = canvas.getContext('2d'); canvas.width = canvas.height = 400; ctx.fillRect(0, 0, 400, 400); max = 80; count = 150; p = []; r = 0; for (a = 0; a < max; a++) { p.push([Math.cos(r), Math.sin(r), 0]); r += Math.PI * 2 / max; } for (a = 0; a < max; a++) p.push([0, p[a][0], p[a][1]]); for (a = 0; a < max; a++) p.push([p[a][1], 0, p[a][0]]); rus(); }; function rus() { var a, b, c, d, e, s, tim, p2, xp, yp, xp2, yp2, x, y, z, x1, y1, z1; ctx.globalCompositeOperation = "source-over"; ctx.fillStyle = "rgba(0,0,0,0.03)"; ctx.........完整代码请登录后点击上方下载按钮下载查看
网友评论0