Loading ...
Sorry, an error occurred while loading the content.

function color_tint- ie. highlighting alternate table rows

Expand Messages
  • hans
    Well, I m sure this will come in handy for someone, its quick and dirty but working. I was tired of scripts that use css to make a shade darker or some crap
    Message 1 of 1 , May 4 12:13 AM
    • 0 Attachment
      Well, I'm sure this will come in handy for someone, its quick and
      dirty but working. I was tired of scripts that use css to make a
      shade darker or some crap css thing :) It'd be nice to see a real
      good one of these.

      // function color_tint
      // richard maloney 2006 code for engineX
      // Send in a color (in #ff00ff format) and a v value +- 0-255 (better
      with small values)
      // this v value works on the r,g,b eg v =-10 so r -10 g -10 b -10
      // returns new color value in #ff00ff format
      function color_tint(color, v) {
      Input = color.toLowerCase();
      function GiveDec(Hex) {
      switch(Hex){ case "a": return 10; case "b": return
      11; case "c": return 12;
      case "d": return 13; case "e": return 14; case "f": return
      15;}return eval(Hex);}
      function GiveHex(Dec) {
      switch(Dec){ case 10: return "a"; case 11:
      return "b"; case 12: return "c";
      case 13: return "d"; case 14: return "e"; case 15:
      return "f"; }return "" + Dec;}
      var colorArr=Input.split("");
      var x = (GiveDec(colorArr[1]) * 16) + GiveDec(colorArr[2]);
      var y = (GiveDec(colorArr[3]) * 16) + GiveDec(colorArr[4]);
      var z = (GiveDec(colorArr[5]) * 16) + GiveDec(colorArr[6]);
      x+=v; if (x <0) {x=0;} if (x>255) {x=255;}
      y+=v; if (y <0) {y=0;} if (y>255) {y=255;}
      z+=v; if (z <0) {z=0;} if (z>255) {z=255;}
      var result = "#" + GiveHex(Math.floor(x / 16)) + GiveHex(x %
      16) + GiveHex(Math.floor(y / 16));
      result += + GiveHex(y % 16) + GiveHex(Math.floor(z / 16)) +
      GiveHex(z % 16);
      return result;
      }
    Your message has been successfully submitted and would be delivered to recipients shortly.