Color

The Color namespace contains a handful of helpful functions related to parsing and converting colors.
 
ParseHex
// Parse HEX color string into RGB object
Fit.Color.ParseHex("#C9802A"); // Returns {Red: 201, Green: 128, Blue: 42}


ParseRgb
// Parse RGB(A) color string into RGBA object
Fit.Color.ParseRgb("rgb(201, 128, 42)"); // Returns {Red: 201, Green: 128, Blue: 42, Alpha: 1}
Fit.Color.ParseRgb("201, 128, 42"); // Returns {Red: 201, Green: 128, Blue: 42, Alpha: 1}
Fit.Color.ParseRgb("rgba(201, 128, 42, 0.75)"); // Returns {Red: 201, Green: 128, Blue: 42, Alpha: 0.75}


HexToRgb
// Convert HEX color string to RGB color string
Fit.Color.HexToRgb("#C9802A"); // Returns "rgb(201, 128, 42)"


RgbToHex
// Convert RGB color values to HEX color string
// Argument list: Fit.Color.RgbToHex(red, green, blue);
Fit.Color.RgbToHex(201, 128, 42); // Returns "#C9802A"
Fit.UI is open source (LGPL) - download or fork it on GitHub - website powered by Sitemagic CMS