1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | package com.rblab.framework.utils { /** * @author Riccardo Bartoli */ public class ColorUtil { public static function rgb2hex(r : uint, g : uint, b : uint, a : uint = 255) : uint { return (a << 24) | (r << 16) | (g << 8) | b; } public static function hex2rgb(color : uint) : Object { var c : Object = {}; c.r = color >> 16 & 0xFF; c.g = color >> 8 & 0xFF; c.b = color & 0xFF; return c; } public static function hex2css( color : int ) : String { return "#" + color.toString(16); } } } |