Advertisement
danateruel

Neon Light {Multi-Wipe} Text Effect code

Sep 17th, 2012
376
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.83 KB | None | 0 0
  1. <script type="text/javascript">
  2.  
  3. // <![CDATA[
  4.  
  5. // all colours must be in format '#NNNNNN', not 'red' or 'rgb(7,8,9)'
  6.  
  7. var fgcolour="#6600cc"; // foreground colour
  8.  
  9. var hlcolour="#aa77ff"; // highlight colour
  10.  
  11. var bgcolour="#ffffff"; // background colour
  12.  
  13. var glcolour="#cc99ff"; // colour of glow around letters
  14.  
  15. var speed=66; // speed colours change, 1 second = 1000
  16.  
  17. var delay=50; // how long to wait between wipes
  18.  
  19. var alink="http://www.mf2fm.com/rv"; // page to link text to (set to ="" for no link)
  20.  
  21.  
  22.  
  23. /****************************
  24.  
  25. *Multi-Wipe Neon Text Effect*
  26.  
  27. *(c)2003-12 mf2fm web-design*
  28.  
  29. * http://www.mf2fm.com/rv *
  30.  
  31. * DON'T EDIT BELOW THIS BOX *
  32.  
  33. ****************************/
  34.  
  35. var w_txt, w_txl;
  36.  
  37. var w_flp=bgcolour;
  38.  
  39. var w_sty=Math.floor(Math.random()*8);
  40.  
  41. var w_cnt=-1;
  42.  
  43. var wipes=new Array();
  44.  
  45. var wrand=new Array();
  46.  
  47. window.onload=function() { if (document.getElementById) {
  48.  
  49. var i, wiper, wipei;
  50.  
  51. wiper=document.getElementById("wipe");
  52.  
  53. w_txt=wiper.firstChild.nodeValue;
  54.  
  55. w_txl=w_txt.length;
  56.  
  57. while (wiper.childNodes.length) wiper.removeChild(wiper.childNodes[0]);
  58.  
  59. for (i=0; i<w_txl; i++) {
  60.  
  61. wipei=document.createElement("span");
  62.  
  63. wipei.appendChild(document.createTextNode(w_txt.charAt(i)));
  64.  
  65. wipes[i]=wipei.style;
  66.  
  67. wipes[i].textShadow=glcolour+" 0px 0px 5px";
  68.  
  69. wipes[i].color=fgcolour;
  70.  
  71. wiper.appendChild(wipei);
  72.  
  73. }
  74.  
  75. if (alink) {
  76.  
  77. wiper.style.cursor="pointer";
  78.  
  79. wiper.onclick=function() { top.location.href=alink; }
  80.  
  81. }
  82.  
  83. for (i=0; i<w_txl; i++) wrand[i]=i;
  84.  
  85. wiper=setInterval("randwipe()", speed);
  86.  
  87. }}
  88.  
  89.  
  90.  
  91. function c(i, shade) {
  92.  
  93. if (shade==bgcolour) wipes[i].textShadow="none";
  94.  
  95. else wipes[i].textShadow=glcolour+" 0px 0px 5px";
  96.  
  97. wipes[i].color=shade;
  98.  
  99. }
  100.  
  101.  
  102.  
  103. function randwipe() {
  104.  
  105. var w_old;
  106.  
  107. if (w_cnt++<w_txl+2+delay*(w_flp==fgcolour)) eval("wipe"+w_sty+"();");
  108.  
  109. else {
  110.  
  111. w_cnt=-1;
  112.  
  113. w_flp=(w_flp==fgcolour)?bgcolour:fgcolour;
  114.  
  115. w_old=w_sty;
  116.  
  117. while (w_old==w_sty) w_sty=Math.floor(Math.random()*9);
  118.  
  119. }
  120.  
  121. }
  122.  
  123.  
  124.  
  125. function dechex(dec) { return ((dec<16)?"0":"")+dec.toString(16); }
  126.  
  127.  
  128.  
  129. function wipe0() { // full curtains
  130.  
  131. var half=Math.floor(w_txl/2);
  132.  
  133. if (w_cnt<w_txl) {
  134.  
  135. c(w_cnt, (w_cnt<half)?hlcolour:w_flp);
  136.  
  137. c(w_txl-w_cnt-1, (w_cnt<half)?hlcolour:w_flp);
  138.  
  139. }
  140.  
  141. }
  142.  
  143.  
  144.  
  145. function wipe1() { // random
  146.  
  147. var i, rand, temp;
  148.  
  149. if (w_cnt==0) {
  150.  
  151. for (i=0; i<w_txl; i++) {
  152.  
  153. rand=Math.floor(Math.random()*w_txl);
  154.  
  155. temp=wrand[i];
  156.  
  157. wrand[i]=wrand[rand];
  158.  
  159. wrand[rand]=temp;
  160.  
  161. }
  162.  
  163. }
  164.  
  165. if (w_cnt<w_txl) c(wrand[w_cnt], hlcolour);
  166.  
  167. if (w_cnt>0 && w_cnt<w_txl+1) c(wrand[w_cnt-1], w_flp);
  168.  
  169. }
  170.  
  171.  
  172.  
  173. function wipe2() { // forwards
  174.  
  175. if (w_cnt<w_txl) c(w_cnt, hlcolour);
  176.  
  177. if (w_cnt>0 && w_cnt<w_txl+1) c(w_cnt-1, w_flp);
  178.  
  179. }
  180.  
  181.  
  182.  
  183. function wipe3() { // backwards
  184.  
  185. if (w_cnt<w_txl) c(w_txl-(w_cnt+1), hlcolour);
  186.  
  187. if (w_cnt>0 && w_cnt<w_txl+1) c(w_txl-w_cnt, w_flp);
  188.  
  189. }
  190.  
  191.  
  192.  
  193. function wipe4() { // searchlight
  194.  
  195. if (w_cnt<w_txl) c(w_cnt, hlcolour);
  196.  
  197. if (w_cnt>0 && w_cnt<w_txl+1) c(w_cnt-1, w_flp);
  198.  
  199. if (w_cnt>1 && w_cnt<w_txl+2) c(w_cnt-2, hlcolour);
  200.  
  201. if (w_cnt>2 && w_cnt<w_txl+3) c(w_cnt-3, (w_flp==fgcolour)?bgcolour:fgcolour);
  202.  
  203. if (w_cnt==w_txl+2) w_flp=(w_flp==fgcolour)?bgcolour:fgcolour;
  204.  
  205. }
  206.  
  207.  
  208.  
  209. function wipe5() { // fade
  210.  
  211. var i;
  212.  
  213. if (w_cnt<w_txl+3) {
  214.  
  215. var start=(w_flp==fgcolour)?bgcolour:fgcolour;
  216.  
  217. var temp="#";
  218.  
  219. for (i=1; i<6; i+=2) {
  220.  
  221. var hex1=parseInt(start.substring(i,i+2),16);
  222.  
  223. var hex2=parseInt(w_flp.substring(i,i+2),16);
  224.  
  225. temp+=dechex(Math.floor(hex1+(hex2-hex1)*(w_cnt/(w_txl+2))));
  226.  
  227. }
  228.  
  229. for (i=0; i<w_txl; i++) c(i, temp);
  230.  
  231. }
  232.  
  233. }
  234.  
  235.  
  236.  
  237. function wipe6() { // flash
  238.  
  239. var i;
  240.  
  241. if (w_cnt<6*Math.floor(w_txl/6)+3) {
  242.  
  243. if (w_cnt%6==0 || w_cnt%6==3) for (i=0; i<w_txl; i++) c(i, hlcolour);
  244.  
  245. else if (w_cnt%6==1) for (i=0; i<w_txl; i++) c(i, w_flp);
  246.  
  247. else if (w_cnt%6==4) for (i=0; i<w_txl; i++) c(i, (w_flp==fgcolour)?bgcolour:fgcolour);
  248.  
  249. }
  250.  
  251. }
  252.  
  253.  
  254.  
  255. function wipe7() { // checkerboard
  256.  
  257. var qtr=Math.floor(w_txl/4);
  258.  
  259. if (w_cnt<qtr) {
  260.  
  261. c(w_cnt, hlcolour);
  262.  
  263. c(w_cnt+2*qtr, hlcolour);
  264.  
  265. }
  266.  
  267. else if (w_cnt<2*qtr) {
  268.  
  269. c(w_cnt-qtr, w_flp);
  270.  
  271. c(w_cnt+qtr, w_flp);
  272.  
  273. }
  274.  
  275. else if (w_cnt<3*qtr) {
  276.  
  277. c(w_cnt-qtr, hlcolour);
  278.  
  279. c(w_cnt+qtr, hlcolour);
  280.  
  281. }
  282.  
  283. else if (w_cnt<w_txl) {
  284.  
  285. c(w_cnt-2*qtr, w_flp);
  286.  
  287. c(w_cnt, w_flp);
  288.  
  289. }
  290.  
  291. }
  292.  
  293.  
  294.  
  295. function wipe8() { // half curtains
  296.  
  297. var half=Math.floor(w_txl/2);
  298.  
  299. if (w_cnt<half) {
  300.  
  301. c(w_cnt, hlcolour);
  302.  
  303. c(w_txl-w_cnt-1, hlcolour);
  304.  
  305. }
  306.  
  307. else if (w_cnt<w_txl) {
  308.  
  309. c(w_cnt-half, w_flp);
  310.  
  311. c(w_txl+half-w_cnt-1, w_flp);
  312.  
  313. }
  314.  
  315. }
  316.  
  317. // ]]>
  318.  
  319. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement