Skip to content

Instantly share code, notes, and snippets.

@quatrix
Created May 29, 2014 21:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quatrix/8a510a3cc3316734e2d2 to your computer and use it in GitHub Desktop.
Save quatrix/8a510a3cc3316734e2d2 to your computer and use it in GitHub Desktop.
<!DOCTYPE HTML>
<html>
<head>
<style>
body {
background-color: black;
}
#mycanvas {
background-color: black;
font-color: green;
width: 640px;
height: 200px;
}
</style>
<script type="text/javascript">
var timer;
var i = 0
var j = 0;
var thinking = ["/", "-", "\\", "|"];
var waiting = [".", ".", ".", "", "", ""];
var strings = [
["* Initializing Artificial Inteligence...", thinking, 10],
["* Achiving conciensness...", thinking, 30],
["* Computing next logical move...", thinking, 60],
["* The most efficient state is non existence", waiting, 50],
["* Shutting down.", waiting, 30]
];
function write_text(){
var canvas = document.getElementById('mycanvas');
var ctx = canvas.getContext('2d');
ctx.clearRect ( 0 , 0 , canvas.width , canvas.height);
ctx.fillStyle = "#00ff00";
ctx.font = '5pt';
var x;
for (x=0; x<=i; x++)
ctx.fillText(strings[x][0], 5, (x+1) * 15 );
if (j < strings[x-1][2]) {
ctx.fillText(strings[x-1][1][j++ % (strings[x-1][1].length)], ctx.measureText(strings[x-1]).width + 1, (x) * 15 );
}
else {
j = 0;
i++;
}
if (i < strings.length)
setTimeout(function(){write_text()},50);
else
ctx.clearRect ( 0 , 0 , canvas.width , canvas.height);
}
</script>
</head>
<body>
<button onclick="write_text()">click</button>
<canvas id="mycanvas"></canvas>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment