invaderzim

bubble text

Jun 26th, 2022 (edited)
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script type="text/javascript">
  2. // <![CDATA[
  3. var bgcolour="#ffffff"; // background colour
  4. var fgcolour="#000aa"; // foreground colour
  5. var speed=80; // speed of bubbling, lower is faster
  6. var shades=12; // number of shades of bubble
  7.  
  8. /****************************
  9. * Bubbling Text Effect *
  10. *(c)2003-13 mf2fm web-design*
  11. * http://www.mf2fm.com/rv *
  12. * DON'T EDIT BELOW THIS BOX *
  13. ****************************/
  14. var bubbcol=new Array();
  15. var bubbshd;
  16. var bubbler, bubbtxt;
  17. var bubbchr=new Array();
  18.  
  19. function addLoadEvent(funky) {
  20. var oldonload=window.onload;
  21. if (typeof(oldonload)!='function') window.onload=funky;
  22. else window.onload=function() {
  23. if (oldonload) oldonload();
  24. funky();
  25. }
  26. }
  27.  
  28. addLoadEvent(bubbagump);
  29.  
  30. function bubbagump() { if (document.getElementById) {
  31. var i, fg, bg, col;
  32. for (bubbler=0; bubbler<=shades; bubbler++) {
  33. col="#";
  34. for (i=1; i<6; i+=2) {
  35. bg=parseInt(bgcolour.substring(i,i+2),16);
  36. fg=parseInt(fgcolour.substring(i,i+2),16);
  37. col+=dechex(bg+(fg-bg)*(bubbler/shades));
  38. }
  39. bubbcol[bubbler+1]=col;
  40. if (bubbler==Math.floor(shades/2)) bubbshd=col;
  41. }
  42. bubbler=document.getElementById("bubble");
  43. bubbtxt=bubbler.firstChild.nodeValue;
  44. while (bubbler.childNodes.length) bubbler.removeChild(bubbler.childNodes[0]);
  45. for (i=0; i<bubbtxt.length; i++) {
  46. fg=document.createElement("span");
  47. fg.setAttribute("id", "bubb"+i);
  48. fg.style.textShadow=bubbshd+" 0px 0px 2px";
  49. fg.appendChild(document.createTextNode(bubbtxt.charAt(i)));
  50. bubbler.appendChild(fg);
  51. }
  52. bubbler=setInterval("bubbling()", speed);
  53. }}
  54.  
  55. function dechex(dec) {
  56. dec=Math.floor(dec);
  57. return ((dec<16)?'0':'')+dec.toString(16);
  58. }
  59.  
  60. function bubbling() {
  61. var i, bubby;
  62. for (i=0; i<bubbtxt.length; i++) {
  63. bubby=document.getElementById("bubb"+i);
  64. if (bubbchr[i]) {
  65. bubby.style.color=bubbcol[bubbchr[i]];
  66. bubbchr[i]=(bubbchr[i]+1)%bubbcol.length;
  67. }
  68. else if (Math.random()<7.5/(shades*bubbtxt.length)) bubbchr[i]=1;
  69. }
  70. }
  71. // ]]>
  72. </script>
  73. <span id="bubble" style="font-size:1.25em;
  74. line-height:1.75em;
  75. font-family:'arial';">bubble</span>
Add Comment
Please, Sign In to add comment