Color.ToHtmlColor
Converts a Color object to a string suitable for including in HTML or CSS.
Source
namespace Foo
open System
open System.Drawing
[<AutoOpen>]
module FsExtensions =
let private hexColor = sprintf "#%02x%02x%02x"
type Color with
/// Converts the color to an html #RRGGBB string, or a name.
member this.ToHtmlColor() =
if this.IsNamedColor then
this.Name
else
hexColor this.R this.G this.B
Example
let htmlColor = someColor.ToHtmlColor()