星际穿越粒子特效
代码语言:html
所属分类:粒子
代码描述:星际穿越粒子特效,按住左键出现粒子放大
代码标签: 特效
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> /******************** Common ********************/ html, body { height: 100%; width: 100%; font-family: Helvetica, verdana, monospace; color: #FFF; font-size: 100%; padding: 0; margin: 0; letter-spacing: 0.2rem; overflow: hidden; background: #000; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } a { color: #FFF; text-decoration: none; } h1 { font-size: 1.6rem; } p { padding: 0.8rem 0; font-size: 0.8rem; } header#header { position: absolute; top: 0; left: 0; padding: 1.6rem; } /******************** Contents ********************/ canvas#canvas { background: #000; } </style> </head> <body translate="no"> <header id="header"> <h1>goToTheMoon</h1> <p>Created date / April 19, 2020</p> </header> <main id="main"> <canvas id="canvas">This browser cannot use a canvas.</canvas> </main> <script> (function () { 'use strict'; window.addEventListener('load', function () { var canvas = document.getElementById('canvas'); if (!canvas || !canvas.getContext) { return false; } /******************** Random Number ********************/ function rand(min, max) { return Math.floor(Math.random() * (max - min + 1) + min); } /******************** Var ********************/ // canvas var ctx = canvas.getContext('2d'); var X = canvas.width = window.innerWidth; var Y = canvas.height = window.innerHeight; var mouseX = X / 2; var mouseY = Y / 2; /******************** Animation ********************/ window.requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame || function (cb) { setTimeout(cb, 17); }; /******************** Moon ********************/ var moonNum = 1; var moons = []; var radius = X / 2; if (X < 768) { radius = X / 2; } function Moon(ctx, x, y) { this.ctx = ctx; this.init(x, y); } Moon.prototype.init = function (x, y) { this.x = x; this.y = y; this.c = '255, 255, 255'; this.r = radius; }; Moon.prototype.resize = function () { this.x = X / 2; this.y = Y / 2; this.r = radius; }; Moon.prototype.render = function () { this.draw(); }; Moon.prototype.draw = f.........完整代码请登录后点击上方下载按钮下载查看
网友评论0