Color.ToHtmlColor

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()

Description

Converts a Color object to a string suitable for including in HTML or CSS.

Details

Double click on the code to select all.

 

;