-
Notifications
You must be signed in to change notification settings - Fork 0
/
Matrix_animation_of_code
133 lines (117 loc) · 4.33 KB
/
Matrix_animation_of_code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#*******************************************************************************************************************************
#This script creates an animation of matrix rain with a portion of our "find_balance_accuracy.r" script as the green text.
#This can be seen on the our poster as the visualization of the C.A.R.I.N.A pipeline.
#*******************************************************************************************************************************
<html>
<head>
<style>
/*basic reset */
*{
margin: 0;
padding: 0;
}
/* Page settings */
html {
width: 100%;
height: 100%;
background: radial-gradient(circle, #fff 0%, #aaa 100%) no-repeat;
overflow-x: hidden;
overflow-y: hidden;
}
body {
text-align: center;
display: table;
background: black;
width: 100%;
height: 100%;
overflow-x: hidden;
overflow-y: hidden;
}
canvas {display:block;}
#author {
position: absolute;
bottom: 10px;
left: 10px;
color : #0F0;
z-index : 1;
box-sizing: border-box;
vertical-align: middle;
}
span {
font-family: monospace;
font-size: 1.5em;
}
span:after {
content:"";
opacity: 0;
animation: cursor 1s infinite;
}
@keyframes cursor {
0% {
opacity: 0;
}
40% {
opacity: 0;
}
50% {
opacity: 1;
}
90% {
opacity: 1;
}
100% {
opacity: 0;
}
}
</style>
</head>
<body>
<canvas id="c"></canvas>
<span id = "author">gabe</span>
<script>
// geting canvas by id c
var c = document.getElementById("c");
var ctx = c.getContext("2d");
//making the canvas full screen
c.height = window.innerHeight;
c.width = window.innerWidth;
//chinese characters - taken from the unicode charset
var matrix = "list_of_sets = jklm$rf.stats$importance load(/scratch/for_gchavez/aklimate_results/brca/models/R1:F1_junkle_final_model.RData) ## Gabe & Jackie & Verrena & Chris";
//converting the string into an array of single characters
matrix = matrix.split("_");
var font_size = 10;
var columns = c.width / font_size; //number of columns for the rain
//an array of drops - one per column
var drops = [];
//x below is the x coordinate
//1 = y co-ordinate of the drop(same for every drop initially)
for(var x = 0; x < columns; x++)
drops[x] = 1;
//drawing the characters
function draw()
{
//Black BG for the canvas
//translucent BG to show trail
ctx.fillStyle = "rgba(0, 0, 0, 0.04)";
ctx.fillRect(0, 0, c.width, c.height);
ctx.fillStyle = "#0F0"; //green text
ctx.font = font_size + "px arial";
//looping over drops
for( var i = 0; i < drops.length; i++ )
{
//a random chinese character to print
var text = matrix[ Math.floor( Math.random() * matrix.length ) ];
//x = i*font_size, y = value of drops[i]*font_size
ctx.fillText(text, i * font_size, drops[i] * font_size);
//sending the drop back to the top randomly after it has crossed the screen
//adding a randomness to the reset to make the drops scattered on the Y axis
if( drops[i] * font_size > c.height && Math.random() > 0.975 )
drops[i] = 0;
//incrementing Y coordinate
drops[i]++;
}
}
setInterval( draw, 35 );
</script>
</body>
</html>