Skip to content

Instantly share code, notes, and snippets.

@ohlawdie
Last active February 11, 2020 22:40
Show Gist options
  • Save ohlawdie/e44272c388d68a0c3458400279265b77 to your computer and use it in GitHub Desktop.
Save ohlawdie/e44272c388d68a0c3458400279265b77 to your computer and use it in GitHub Desktop.
Active Pattern Decomp #F
open System.Drawing
let (|RGB|) (col : System.Drawing.Color) =
( col.R, col.G, col.B )
let (|HSB|) (col : System.Drawing.Color) =
( col.GetHue(), col.GetSaturation(), col.GetBrightness() )
let printRGB (col: System.Drawing.Color) =
match col with
| RGB(r, g, b) -> printfn " Red: %d Green: %d Blue: %d" r g b
let printHSB (col: System.Drawing.Color) =
match col with
| HSB(h, s, b) -> printfn " Hue: %f Saturation: %f Brightness: %f" h s b
let printAll col colorString =
printfn "%s" colorString
printRGB col
printHSB col
printAll Color.Red "Red"
printAll Color.Black "Black"
printAll Color.White "White"
printAll Color.Gray "Gray"
printAll Color.BlanchedAlmond "BlanchedAlmond"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment