home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 25: Programming / pc_actual_25.iso / HTML / AceHTML / AceHTML4Free.exe / %MAINDIR% / EScripts / jscript / degrade.scr < prev    next >
Encoding:
Text File  |  2001-09-06  |  1.3 KB  |  61 lines

  1. <SCRIPT LANGUAGE="JavaScript">
  2. <!-- begin script
  3. function maketable(n) {
  4.   var nb;
  5.   this.length = n;
  6.   for (var i = 1; i <=n; i++)
  7.     if (i<10) {
  8.       nb = i+"";
  9.       nb = nb.substring(0,1);       
  10.       this[i] = nb;
  11.     }
  12.   return this;
  13. }
  14.  
  15. function conversion(color) {
  16.   var hexa1;
  17.   var hexa2;
  18.   var colorHexa;
  19.   tabHex = new maketable(16);
  20.  
  21.   tabHex[10]="A"; tabHex[11]="B"; tabHex[12]="C"; tabHex[13]="D"; tabHex[14]="E"; tabHex[15]="F";
  22.   hexa2 = (color%16);
  23.   hexa1 = parseInt(color/16);
  24.   hexa2 = tabHex[hexa2];
  25.   if (hexa2 == null)
  26.     hexa2 = "0";
  27.   hexa1 = tabHex[hexa1];
  28.   if (hexa1 == null)
  29.     hexa1 = "0";
  30.   colorHexa = hexa1 + hexa2;
  31.   return colorHexa;
  32. }
  33.  
  34. function degrade(atext, asize, afont, RGB) {
  35.   var factor = 256/(atext.length+1);
  36.   var i;
  37.   var c1,c2,c3;
  38.  
  39.   for (i=0;i<atext.length;i++)   {
  40.     ton=factor*i;
  41.     if (RGB == 0) {
  42.       c1 = 'FF'
  43.       c2 = conversion(ton);
  44.       c3 = c2;
  45.     }
  46.     else if (RGB == 1) {
  47.       c1 = conversion(ton);
  48.       c2 = 'FF'
  49.       c3 = c1;
  50.     }
  51.     else {
  52.       c1 = conversion(ton);
  53.       c2 = c1;
  54.       c3 = 'FF'
  55.     }
  56.    document.write ('<FONT SIZE=' + asize + ' FACE="' + afont + '" COLOR="#' + c1 + c2 + c3 + '">' + atext.substring (i,i+1) + '</FONT>');
  57.   } 
  58. }
  59. //  end script -->
  60. </SCRIPT>
  61.