First open notepad.
Copy and paste the below code in the notepad.
Copy and paste the below code in the notepad.
<canvas id="canvasId"
width="1330" height="650" style="border:1px solid
black"></canvas>
<script
type="text/javascript">
var cW = 1330;
var cH = 650;
window.onload = windowReady(64);
/**
windowReady
*/
function windowReady(ascii_start) {
// Load the context of the canvas
var context =
document.getElementById('canvasId').getContext("2d");
var charArray = [];
for (var i = 0; i < 75; i++) {
var temp = [];
var yspeed = Math.random()
* 10;
var xspacing = Math.random() * 15 +
15;
var fontSize = Math.random() * 20 +
5;
var charlengh =
10+Math.floor(Math.random()*20);
for (var j = 0; j < charlengh;
j++) {
temp.push(new create_chars(i * 15 + xspacing, j * 20+20, yspeed, j,
fontSize));
}
charArray.push(temp);
}
function create_chars(xloc, yloc,
yspeed, j, fontSize) {
this.x = xloc;
this.y = -yloc;
this.dy = yspeed;
this.fontSize = fontSize;
if (j == 0)
this.color = "white";
else
this.color = "green";
this.text =
String.fromCharCode(ascii_start + Math.floor(Math.random()*65));
}
function Draw() {
context.globalCompositeOperation =
"source-over";
context.fillStyle =
"rgba(0,0,0,0.9)";
context.fillRect(0, 0, cW, cH);
context.globalCompositeOperation =
"lighter";
for (var k = 0; k <
charArray.length; k++) {
for (var m = 0; m <
charArray[k].length; m++) {
var charObject =
charArray[k][m];
context.fillStyle =
charObject.color;
context.font = "bold
"+charObject.fontSize+"px Arial";
context.fillText(charObject.text, charObject.x, charObject.y);
context.fill();
charObject.y +=
charObject.dy;
if (charObject.y > cH) {
charObject.y = 0; }
}
}
}
setInterval(Draw, 20);
}
</script>
Save as matrix.html, and
Select All Files instead of Text
Document(*txt) in the below tab.
Now open it in chrome!...
No comments:
Post a Comment