Langsung ke konten utama

Cara Buat Efek "Matrix"



Simple Matrix Effect Using Javascript
Hai sobat blogger :D, ada yang aneh gak dari gambar itu? :3 yap, itu bukan gambar tapi script yang mimin temuin hehe :D Penasaran kan gimana caranya? :3 oke, cekidot
Nah, sebelum mulai ada baiknya kalian ngerti dulu deh apa itu HTML, CSS, sama JavaScript. Mau belajar cepet tanpa guru? cekidot guys :D Oke, mimin asumsikan kalian udah ngerti ya? YA? IYA?! :3 oke, lanjut. Sekarang buka notepad(++ kalau ada). Nah, buat dokumen baru terus ketik (atau copas aja deh. Kecuali kalau kalian sanggup :3) script ini :
1:  <style type="text/css">  
2:  .matrix { font-family:Lucida Console, Courier, Monotype; font-size:10pt; text-align:center; width:10px; padding:0px; margin:0px;}  
3:  </style>  
4:  <script language="JavaScript" type="text/javascript">  
5:  var rows=5; // harus ganjil  
6:  var speed=50; // kecil lebih cepat  
7:  var reveal=2; // antara 0 sampai 2. Lebih besar, lebih cepat text tampil  
8:  var effectalign="center"  
9:  var w3c=document.getElementById && !window.opera;;  
10:  var ie45=document.all && !window.opera;  
11:  var ma_tab, matemp, ma_bod, ma_row, x, y, columns, ma_txt, ma_cho;  
12:  var m_coch=new Array();  
13:  var m_copo=new Array();  
14:  window.onload=function() {  
15:  if (!w3c && !ie45) return  
16:  var matrix=(w3c)?document.getElementById("matrix"):document.all["matrix"];  
17:  ma_txt=(w3c)?matrix.firstChild.nodeValue:matrix.innerHTML;  
18:  ma_txt=" "+ma_txt+" ";  
19:  columns=ma_txt.length;  
20:  if (w3c) {  
21:  while (matrix.childNodes.length) matrix.removeChild(matrix.childNodes[0]);  
22:  ma_tab=document.createElement("table");  
23:  ma_tab.setAttribute("border", 0);  
24:  ma_tab.setAttribute("align", effectalign);  
25:  ma_tab.style.backgroundColor="#000000";  
26:  ma_bod=document.createElement("tbody");  
27:  for (x=0; x<rows; x++) {  
28:  ma_row=document.createElement("tr");  
29:  for (y=0; y<columns; y++) {  
30:  matemp=document.createElement("td");  
31:  matemp.setAttribute("id", "Mx"+x+"y"+y);  
32:  matemp.className="matrix";  
33:  matemp.appendChild(document.createTextNode(String.fromCharCode(160)));  
34:  ma_row.appendChild(matemp);  
35:  }  
36:  ma_bod.appendChild(ma_row);  
37:  }  
38:  ma_tab.appendChild(ma_bod);  
39:  matrix.appendChild(ma_tab);  
40:  } else {  
41:  ma_tab='<ta'+'ble align="'+effectalign+'" border="0" style="background-color:#000000">';  
42:  for (var x=0; x<rows; x++) {  
43:  ma_tab+='<t'+'r>';  
44:  for (var y=0; y<columns; y++) {  
45:  ma_tab+='<t'+'d class="matrix" id="Mx'+x+'y'+y+'"> </'+'td>';  
46:  }  
47:  ma_tab+='</'+'tr>';  
48:  }  
49:  ma_tab+='</'+'table>';  
50:  matrix.innerHTML=ma_tab;  
51:  }  
52:  ma_cho=ma_txt;  
53:  for (x=0; x<columns; x++) {  
54:  ma_cho+=String.fromCharCode(32+Math.floor(Math.random()*94));  
55:  m_copo[x]=0;  
56:  }  
57:  ma_bod=setInterval("mytricks()", speed);  
58:  }  
59:  function mytricks() {  
60:  x=0;  
61:  for (y=0; y<columns; y++) {  
62:  x=x+(m_copo[y]==100);  
63:  ma_row=m_copo[y]%100;  
64:  if (ma_row && m_copo[y]<100) {  
65:  if (ma_row<rows+1) {  
66:  if (w3c) {  
67:  matemp=document.getElementById("Mx"+(ma_row-1)+"y"+y);  
68:  matemp.firstChild.nodeValue=m_coch[y];  
69:  }  
70:  else {  
71:  matemp=document.all["Mx"+(ma_row-1)+"y"+y];  
72:  matemp.innerHTML=m_coch[y];  
73:  }  
74:  matemp.style.color="#33ff66";  
75:  matemp.style.fontWeight="bold";  
76:  }  
77:  if (ma_row>1 && ma_row<rows+2) {  
78:  matemp=(w3c)?document.getElementById("Mx"+(ma_row-2)+"y"+y):document.all["Mx"+(ma_row-2)+"y"+y];  
79:  matemp.style.fontWeight="normal";  
80:  matemp.style.color="#00ff00";  
81:  }  
82:  if (ma_row>2) {  
83:  matemp=(w3c)?document.getElementById("Mx"+(ma_row-3)+"y"+y):document.all["Mx"+(ma_row-3)+"y"+y];  
84:  matemp.style.color="#009900";  
85:  }  
86:  if (ma_row<Math.floor(rows/2)+1) m_copo[y]++;  
87:  else if (ma_row==Math.floor(rows/2)+1 && m_coch[y]==ma_txt.charAt(y)) zoomer(y);  
88:  else if (ma_row<rows+2) m_copo[y]++;  
89:  else if (m_copo[y]<100) m_copo[y]=0;  
90:  }  
91:  else if (Math.random()>0.9 && m_copo[y]<100) {  
92:  m_coch[y]=ma_cho.charAt(Math.floor(Math.random()*ma_cho.length));  
93:  m_copo[y]++;  
94:  }  
95:  }  
96:  if (x==columns) clearInterval(ma_bod);  
97:  }  
98:  function zoomer(ycol) {  
99:  var mtmp, mtem, ytmp;  
100:  if (m_copo[ycol]==Math.floor(rows/2)+1) {  
101:  for (ytmp=0; ytmp<rows; ytmp++) {  
102:  if (w3c) {  
103:  mtmp=document.getElementById("Mx"+ytmp+"y"+ycol);  
104:  mtmp.firstChild.nodeValue=m_coch[ycol];  
105:  }  
106:  else {  
107:  mtmp=document.all["Mx"+ytmp+"y"+ycol];  
108:  mtmp.innerHTML=m_coch[ycol];  
109:  }  
110:  mtmp.style.color="#33ff66";  
111:  mtmp.style.fontWeight="bold";  
112:  }  
113:  if (Math.random()<reveal) {  
114:  mtmp=ma_cho.indexOf(ma_txt.charAt(ycol));  
115:  ma_cho=ma_cho.substring(0, mtmp)+ma_cho.substring(mtmp+1, ma_cho.length);  
116:  }  
117:  if (Math.random()<reveal-1) ma_cho=ma_cho.substring(0, ma_cho.length-1);  
118:  m_copo[ycol]+=199;  
119:  setTimeout("zoomer("+ycol+")", speed);  
120:  }  
121:  else if (m_copo[ycol]>200) {  
122:  if (w3c) {  
123:  mtmp=document.getElementById("Mx"+(m_copo[ycol]-201)+"y"+ycol);  
124:  mtem=document.getElementById("Mx"+(200+rows-m_copo[ycol]--)+"y"+ycol);  
125:  }  
126:  else {  
127:  mtmp=document.all["Mx"+(m_copo[ycol]-201)+"y"+ycol];  
128:  mtem=document.all["Mx"+(200+rows-m_copo[ycol]--)+"y"+ycol];  
129:  }  
130:  mtmp.style.fontWeight="normal";  
131:  mtem.style.fontWeight="normal";  
132:  setTimeout("zoomer("+ycol+")", speed);  
133:  }  
134:  else if (m_copo[ycol]==200) m_copo[ycol]=100+Math.floor(rows/2);  
135:  if (m_copo[ycol]>100 && m_copo[ycol]<200) {  
136:  if (w3c) {  
137:  mtmp=document.getElementById("Mx"+(m_copo[ycol]-101)+"y"+ycol);  
138:  mtmp.firstChild.nodeValue=String.fromCharCode(160);  
139:  mtem=document.getElementById("Mx"+(100+rows-m_copo[ycol]--)+"y"+ycol);  
140:  mtem.firstChild.nodeValue=String.fromCharCode(160);  
141:  }  
142:  else {  
143:  mtmp=document.all["Mx"+(m_copo[ycol]-101)+"y"+ycol];  
144:  mtmp.innerHTML=String.fromCharCode(160);  
145:  mtem=document.all["Mx"+(100+rows-m_copo[ycol]--)+"y"+ycol];  
146:  mtem.innerHTML=String.fromCharCode(160);  
147:  }  
148:  setTimeout("zoomer("+ycol+")", speed);  
149:  }  
150:  }  
151:  // </script>  
152:  <div id="matrix">  
153:  Simple Matrix Effect Using Javascript</div>  

Nah, kalau ente udah copy ntu script diatas, klik save as, ganti extensionya jadi all type, *apa aja*.html. Atau bagi kalian para blogger atau web designer yang lagi cari ide monggo :3 NB : Warna Merah Berarti Bebas Di-Edit *Sumber+Demo*

Komentar

Postingan populer dari blog ini

Cara Mengetahui Username Komputer Menggunakan Command Prompt

Hai Sobat Reader, Pada kesempatan Kali ini saya akan membagikan tips yang mungkin bisa bermanfaat bagi seluruh mahluk hidup yang ada di alam semesta ini :v yaitu Cara Mengetahui Username Komputer Menggunakan Command Prompt. NOTE : Cara ini bukan untuk  Hacking  atau Semacamnya,  Nah Biasanya Saat Kita ingin Menerima/Mengirim file dari Komputer/Laptop lain Selalu ada Gambar seperti Dibawah ini      Padahal Kita sudah memasukan Username dan Password yang menurut kita benar ( Padahal Salah :p *le komputer )