三种比较好玩的黑客效果JS代码(摘取)

Posted zfx423

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了三种比较好玩的黑客效果JS代码(摘取)相关的知识,希望对你有一定的参考价值。

<html> <head> <title>The Matrix</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script> <meta charset="utf-8"> <script> /* ① 用setInterval(draw, 33)设定刷新间隔 ② 用String.fromCharCode(1e2+Math.random()*33)随机生成字母 ③ 用ctx.fillStyle=’rgba(0,0,0,.05)’; ctx.fillRect(0,0,width,height); ctx.fillStyle=’#0F0′; 反复生成opacity为0.5的半透明黑色背景 ④ 用x = (index * 10)+10;和yPositions[index] = y + 10;顺序确定显示字母的位置 ⑤ 用fillText(text, x, y); 在指定位置显示一个字母 以上步骤循环进行,就会产生《黑客帝国》的片头效果。 */ $(document).ready(function () { var s = window.screen; var width = q.width = s.width; var height = q.height; var yPositions = Array(300).join(0).split(‘‘); var ctx = q.getContext(‘2d‘); var draw = function () { ctx.fillStyle = ‘rgba(0,0,0,.05)‘; ctx.fillRect(0, 0, width, height); ctx.fillStyle = ‘red‘; ctx.font = ‘10pt Georgia‘; yPositions.map(function (y, index) { text = String.fromCharCode(1e2 + Math.random() * 33); x = (index * 10) + 10; q.getContext(‘2d‘).fillText(text, x, y); if (y > Math.random() * 1e4) { yPositions[index] = 0; } else { yPositions[index] = y + 10; } }); }; RunMatrix(); function RunMatrix() { Game_Interval = setInterval(draw, 30); } }); </script> </head> <body> <div align="center"> <canvas id="q" width="500" height="500"></canvas> </div> </body> </html>

以上是关于三种比较好玩的黑客效果JS代码(摘取)的主要内容,如果未能解决你的问题,请参考以下文章

超好玩的js页面效果---实现数值的动态变化

MySQL 的 binlog 的三种格式这么好玩

太震撼了!我把七大JS排序算法做成了可视化!!!太好玩了!

仿一个好玩的滑动效果

好玩儿的css

几道好玩的JS题目,看看你能答中几道。