Skip to content
Christopher Nikkel edited this page Dec 22, 2018 · 5 revisions

Color

Definition

type Color =
    | Name of Colors
    | SmallHex of int16
    | Hex of int
    | Values of byte * byte * byte
    | Percents of float * float * float

Description

Color is used to described a color. There are built in constant colors as well as ways to construct colors from numbers or percentages.

Constants

Constant Type Description
Colors.None Colors no color
Colors.AliceBlue Colors alice blue - rgb(240, 248, 255)
Colors.AntiqueWhite Colors antique white - rgb(250, 235, 215)
Colors.Aqua Colors aqua - rgb(0, 255,255)
... ... ...
Colors.Yellow Colors yellow - rgb(255, 255, 0)
Colors.YellowGreen Colors yellow green - rgb(154, 205, 50)

For a full list of colors refer to the SVG specification here

Functions

Function Signature Description
Color.ofName Colors -> Color creates a color from a named constant
Color.ofSmallHex int16 -> Color creates a color from an int16 encoded as rgb
Color.ofHex int -> Color creates a color from an int encoded as rrggbb
Color.ofValues byte * byte * byte -> Color creates a color from three bytes (red, green, blue)
Color.ofPercents float * float * float -> Color creates a color from three floats (red, green, blue)
Color.toString Color -> string converts a color to a string
Colors.toString Colors -> string converts a color name to a string

Usage

Example

let color1 = Color.ofName Colors.Aqua
let color2 = Color.ofValues (0uy, 125uy, 200uy)
let color3 = Color.ofPercents (100.0, 25.0, 15.0)

printfn "color1 = %s" <| Color.toString color1
printfn "color2 = %s" <| Color.toString color2
printfn "color3 = %s" <| Color.toString color3

Output

color1 = "aqua"
color2 = "(0,125,200)"
color33 = "(100%,25%,15%)"

Table of Contents

Getting Started

Fundamentals

Basic SVG Elements

Advanced Elements

Experimental

Clone this wiki locally