home *** CD-ROM | disk | FTP | other *** search
/ Champak 48 / cdrom_image.iso / Games / bobsleddin.swf / scripts / __Packages / RGB.as < prev    next >
Encoding:
Text File  |  2007-09-28  |  1.0 KB  |  50 lines

  1. class RGB
  2. {
  3.    var r = 0;
  4.    var g = 0;
  5.    var b = 0;
  6.    function RGB(r, g, b)
  7.    {
  8.       switch(arguments.length)
  9.       {
  10.          case 3:
  11.             this.r = r;
  12.             this.g = g;
  13.             this.b = b;
  14.             break;
  15.          case 0:
  16.             break;
  17.          case 1:
  18.             this.hex(r);
  19.       }
  20.    }
  21.    function hex(i)
  22.    {
  23.       this.r = i >>> 16;
  24.       this.g = i - (this.r << 16) >>> 8;
  25.       this.b = i % 256;
  26.    }
  27.    function toHex()
  28.    {
  29.       var _loc4_ = (this.r << 16) + (this.g << 8) + this.b;
  30.       var _loc5_ = "";
  31.       var _loc3_ = 20;
  32.       while(_loc3_ > -1)
  33.       {
  34.          var _loc2_ = _loc4_ >>> _loc3_;
  35.          _loc5_ += _loc2_ <= 9 ? _loc2_ : chr(55 + _loc2_);
  36.          _loc4_ -= _loc2_ << _loc3_;
  37.          _loc3_ -= 4;
  38.       }
  39.       return "0x" + _loc5_;
  40.    }
  41.    function valueOf()
  42.    {
  43.       return (this.r << 16) + (this.g << 8) + this.b;
  44.    }
  45.    function toString()
  46.    {
  47.       return "RGB(" + this.r + "," + this.g + "," + this.b + ")";
  48.    }
  49. }
  50.