package com.mrdoob.utils { public class ColorUtils { static public function getHex(cr:Number,cg:Number,cb:Number):Number { var cr:Number = ( cr > 1 ) ? 1 : cr; var cg:Number = ( cg > 1 ) ? 1 : cg; var cb:Number = ( cb > 1 ) ? 1 : cb; return Math.round(cr*255) << 16 ^ Math.round(cg*255) << 8 ^ Math.round(cb*255); } /** * Returns an Object with the r, g and b values from 0 to 1 * @param hexColor Hexadecimal value */ static public function getRGB(hexColor:Number):Object { var rgbColor:Object = new Object(); rgbColor.r = ( ( 0xFF0000 & hexColor ) >> 16 ) / 0xff; rgbColor.g = ( ( 0x00FF00 & hexColor ) >> 8 ) / 0xff; rgbColor.b = ( 0x0000FF & hexColor ) / 0xff; return rgbColor; } } }