Module colors

This module implements color handling for Nim. It is used by the graphics module.

Types

Color = distinct int
a color stored as RGB   Source

Consts

colAliceBlue = 0x00F0F8FF
  Source
colAntiqueWhite = 0x00FAEBD7
  Source
colAqua = 0x0000FFFF
  Source
colAquamarine = 0x007FFFD4
  Source
colAzure = 0x00F0FFFF
  Source
colBeige = 0x00F5F5DC
  Source
colBisque = 0x00FFE4C4
  Source
colBlack = 0x00000000
  Source
colBlanchedAlmond = 0x00FFEBCD
  Source
colBlue = 0x000000FF
  Source
colBlueViolet = 0x008A2BE2
  Source
colBrown = 0x00A52A2A
  Source
colBurlyWood = 0x00DEB887
  Source
colCadetBlue = 0x005F9EA0
  Source
colChartreuse = 0x007FFF00
  Source
colChocolate = 0x00D2691E
  Source
colCoral = 0x00FF7F50
  Source
colCornflowerBlue = 0x006495ED
  Source
colCornsilk = 0x00FFF8DC
  Source
colCrimson = 0x00DC143C
  Source
colCyan = 0x0000FFFF
  Source
colDarkBlue = 0x0000008B
  Source
colDarkCyan = 0x00008B8B
  Source
colDarkGoldenRod = 0x00B8860B
  Source
colDarkGray = 0x00A9A9A9
  Source
colDarkGreen = 0x00006400
  Source
colDarkKhaki = 0x00BDB76B
  Source
colDarkMagenta = 0x008B008B
  Source
colDarkOliveGreen = 0x00556B2F
  Source
colDarkorange = 0x00FF8C00
  Source
colDarkOrchid = 0x009932CC
  Source
colDarkRed = 0x008B0000
  Source
colDarkSalmon = 0x00E9967A
  Source
colDarkSeaGreen = 0x008FBC8F
  Source
colDarkSlateBlue = 0x00483D8B
  Source
colDarkSlateGray = 0x002F4F4F
  Source
colDarkTurquoise = 0x0000CED1
  Source
colDarkViolet = 0x009400D3
  Source
colDeepPink = 0x00FF1493
  Source
colDeepSkyBlue = 0x0000BFFF
  Source
colDimGray = 0x00696969
  Source
colDodgerBlue = 0x001E90FF
  Source
colFireBrick = 0x00B22222
  Source
colFloralWhite = 0x00FFFAF0
  Source
colForestGreen = 0x00228B22
  Source
colFuchsia = 0x00FF00FF
  Source
colGainsboro = 0x00DCDCDC
  Source
colGhostWhite = 0x00F8F8FF
  Source
colGold = 0x00FFD700
  Source
colGoldenRod = 0x00DAA520
  Source
colGray = 0x00808080
  Source
colGreen = 0x00008000
  Source
colGreenYellow = 0x00ADFF2F
  Source
colHoneyDew = 0x00F0FFF0
  Source
colHotPink = 0x00FF69B4
  Source
colIndianRed = 0x00CD5C5C
  Source
colIndigo = 0x004B0082
  Source
colIvory = 0x00FFFFF0
  Source
colKhaki = 0x00F0E68C
  Source
colLavender = 0x00E6E6FA
  Source
colLavenderBlush = 0x00FFF0F5
  Source
colLawnGreen = 0x007CFC00
  Source
colLemonChiffon = 0x00FFFACD
  Source
colLightBlue = 0x00ADD8E6
  Source
colLightCoral = 0x00F08080
  Source
colLightCyan = 0x00E0FFFF
  Source
colLightGoldenRodYellow = 0x00FAFAD2
  Source
colLightGrey = 0x00D3D3D3
  Source
colLightGreen = 0x0090EE90
  Source
colLightPink = 0x00FFB6C1
  Source
colLightSalmon = 0x00FFA07A
  Source
colLightSeaGreen = 0x0020B2AA
  Source
colLightSkyBlue = 0x0087CEFA
  Source
colLightSlateGray = 0x00778899
  Source
colLightSteelBlue = 0x00B0C4DE
  Source
colLightYellow = 0x00FFFFE0
  Source
colLime = 0x0000FF00
  Source
colLimeGreen = 0x0032CD32
  Source
colLinen = 0x00FAF0E6
  Source
colMagenta = 0x00FF00FF
  Source
colMaroon = 0x00800000
  Source
colMediumAquaMarine = 0x0066CDAA
  Source
colMediumBlue = 0x000000CD
  Source
colMediumOrchid = 0x00BA55D3
  Source
colMediumPurple = 0x009370D8
  Source
colMediumSeaGreen = 0x003CB371
  Source
colMediumSlateBlue = 0x007B68EE
  Source
colMediumSpringGreen = 0x0000FA9A
  Source
colMediumTurquoise = 0x0048D1CC
  Source
colMediumVioletRed = 0x00C71585
  Source
colMidnightBlue = 0x00191970
  Source
colMintCream = 0x00F5FFFA
  Source
colMistyRose = 0x00FFE4E1
  Source
colMoccasin = 0x00FFE4B5
  Source
colNavajoWhite = 0x00FFDEAD
  Source
colNavy = 0x00000080
  Source
colOldLace = 0x00FDF5E6
  Source
colOlive = 0x00808000
  Source
colOliveDrab = 0x006B8E23
  Source
colOrange = 0x00FFA500
  Source
colOrangeRed = 0x00FF4500
  Source
colOrchid = 0x00DA70D6
  Source
colPaleGoldenRod = 0x00EEE8AA
  Source
colPaleGreen = 0x0098FB98
  Source
colPaleTurquoise = 0x00AFEEEE
  Source
colPaleVioletRed = 0x00D87093
  Source
colPapayaWhip = 0x00FFEFD5
  Source
colPeachPuff = 0x00FFDAB9
  Source
colPeru = 0x00CD853F
  Source
colPink = 0x00FFC0CB
  Source
colPlum = 0x00DDA0DD
  Source
colPowderBlue = 0x00B0E0E6
  Source
colPurple = 0x00800080
  Source
colRed = 0x00FF0000
  Source
colRosyBrown = 0x00BC8F8F
  Source
colRoyalBlue = 0x004169E1
  Source
colSaddleBrown = 0x008B4513
  Source
colSalmon = 0x00FA8072
  Source
colSandyBrown = 0x00F4A460
  Source
colSeaGreen = 0x002E8B57
  Source
colSeaShell = 0x00FFF5EE
  Source
colSienna = 0x00A0522D
  Source
colSilver = 0x00C0C0C0
  Source
colSkyBlue = 0x0087CEEB
  Source
colSlateBlue = 0x006A5ACD
  Source
colSlateGray = 0x00708090
  Source
colSnow = 0x00FFFAFA
  Source
colSpringGreen = 0x0000FF7F
  Source
colSteelBlue = 0x004682B4
  Source
colTan = 0x00D2B48C
  Source
colTeal = 0x00008080
  Source
colThistle = 0x00D8BFD8
  Source
colTomato = 0x00FF6347
  Source
colTurquoise = 0x0040E0D0
  Source
colViolet = 0x00EE82EE
  Source
colWheat = 0x00F5DEB3
  Source
colWhite = 0x00FFFFFF
  Source
colWhiteSmoke = 0x00F5F5F5
  Source
colYellow = 0x00FFFF00
  Source
colYellowGreen = 0x009ACD32
  Source

Procs

proc `==`(a, b: Color): bool {.borrow.}
compares two colors.   Source
proc `+`(a, b: Color): Color {.raises: [], tags: [].}
adds two colors: This uses saturated artithmetic, so that each color component cannot overflow (255 is used as a maximum).   Source
proc `-`(a, b: Color): Color {.raises: [], tags: [].}
subtracts two colors: This uses saturated artithmetic, so that each color component cannot overflow (255 is used as a maximum).   Source
proc extractRGB(a: Color): tuple[r, g, b: range[0 .. 255]] {.raises: [], tags: [].}
extracts the red/green/blue components of the color a.   Source
proc intensity(a: Color; f: float): Color {.raises: [], tags: [].}
returns a with intensity f. f should be a float from 0.0 (completely dark) to 1.0 (full color intensity).   Source
proc `$`(c: Color): string {.raises: [], tags: [].}
converts a color into its textual representation. Example: #00FF00.   Source
proc parseColor(name: string): Color {.raises: [ValueError], tags: [].}
parses name to a color value. If no valid color could be parsed EInvalidValue is raised.   Source
proc isColor(name: string): bool {.raises: [], tags: [].}
returns true if name is a known color name or a hexadecimal color prefixed with #.   Source
proc rgb(r, g, b: range[0 .. 255]): Color {.raises: [], tags: [].}
constructs a color from RGB values.   Source

Templates

template mix(a, b: Color; fn: expr): expr
uses fn to mix the colors a and b. fn is invoked for each component R, G, and B. This is a template because fn should be inlined and the compiler cannot inline proc pointers yet. If fn's result is not in the range[0..255], it will be saturated to be so.   Source