首页 > 代码库 > 背景测试
背景测试
背景测试
========================
Demo 1 Demo 2 Demo 3 Demo 4 Demo 5 Demo 6 Demo 7
<script type="text/javascript">// max) { var hold = max; max = min; min = hold; } return Math.floor(Math.random() * (max - min + 1)) + min;}var Star = function() { this.orbitRadius = random(w / 2 - 50); this.radius = random(100, this.orbitRadius) / 10; this.orbitX = w / 2; this.orbitY = h / 2; this.timePassed = random(0, maxStars); this.speed = random(this.orbitRadius) / 900000; this.alpha = random(2, 10) / 10; count++; stars[count] = this;}Star.prototype.draw = function() { var x = Math.sin(this.timePassed + 1) * this.orbitRadius + this.orbitX, y = Math.cos(this.timePassed) * this.orbitRadius/2 + this.orbitY, twinkle = random(10); if (twinkle === 1 && this.alpha > 0) { this.alpha -= 0.05; } else if (twinkle === 2 && this.alpha < 1) { this.alpha += 0.05; } ctx.globalAlpha = this.alpha; ctx.drawImage(canvas2, x - this.radius / 2, y - this.radius / 2, this.radius, this.radius); this.timePassed += this.speed;}for (var i = 0; i < maxStars; i++) { new Star();}function animation() { ctx.globalCompositeOperation = ‘source-over‘; ctx.globalAlpha = 0.8; ctx.fillStyle = ‘hsla(‘ + hue + ‘, 64%, 6%, 1)‘; ctx.fillRect(0, 0, w, h) ctx.globalCompositeOperation = ‘lighter‘; for (var i = 1, l = stars.length; i < l; i++) { stars[i].draw(); }; window.requestAnimationFrame(animation);}animation();// ]]></script>背景测试
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。