This module implements color handling for Nim. It is used by the graphics module.
Consts
colAliceBlue = 0x00F0F8FF
- Source Edit
colAntiqueWhite = 0x00FAEBD7
- Source Edit
colAqua = 0x0000FFFF
- Source Edit
colAquamarine = 0x007FFFD4
- Source Edit
colAzure = 0x00F0FFFF
- Source Edit
colBeige = 0x00F5F5DC
- Source Edit
colBisque = 0x00FFE4C4
- Source Edit
colBlack = 0x00000000
- Source Edit
colBlanchedAlmond = 0x00FFEBCD
- Source Edit
colBlue = 0x000000FF
- Source Edit
colBlueViolet = 0x008A2BE2
- Source Edit
colBrown = 0x00A52A2A
- Source Edit
colBurlyWood = 0x00DEB887
- Source Edit
colCadetBlue = 0x005F9EA0
- Source Edit
colChartreuse = 0x007FFF00
- Source Edit
colChocolate = 0x00D2691E
- Source Edit
colCoral = 0x00FF7F50
- Source Edit
colCornflowerBlue = 0x006495ED
- Source Edit
colCornsilk = 0x00FFF8DC
- Source Edit
colCrimson = 0x00DC143C
- Source Edit
colCyan = 0x0000FFFF
- Source Edit
colDarkBlue = 0x0000008B
- Source Edit
colDarkCyan = 0x00008B8B
- Source Edit
colDarkGoldenRod = 0x00B8860B
- Source Edit
colDarkGray = 0x00A9A9A9
- Source Edit
colDarkGreen = 0x00006400
- Source Edit
colDarkKhaki = 0x00BDB76B
- Source Edit
colDarkMagenta = 0x008B008B
- Source Edit
colDarkOliveGreen = 0x00556B2F
- Source Edit
colDarkorange = 0x00FF8C00
- Source Edit
colDarkOrchid = 0x009932CC
- Source Edit
colDarkRed = 0x008B0000
- Source Edit
colDarkSalmon = 0x00E9967A
- Source Edit
colDarkSeaGreen = 0x008FBC8F
- Source Edit
colDarkSlateBlue = 0x00483D8B
- Source Edit
colDarkSlateGray = 0x002F4F4F
- Source Edit
colDarkTurquoise = 0x0000CED1
- Source Edit
colDarkViolet = 0x009400D3
- Source Edit
colDeepPink = 0x00FF1493
- Source Edit
colDeepSkyBlue = 0x0000BFFF
- Source Edit
colDimGray = 0x00696969
- Source Edit
colDodgerBlue = 0x001E90FF
- Source Edit
colFireBrick = 0x00B22222
- Source Edit
colFloralWhite = 0x00FFFAF0
- Source Edit
colForestGreen = 0x00228B22
- Source Edit
colFuchsia = 0x00FF00FF
- Source Edit
colGainsboro = 0x00DCDCDC
- Source Edit
colGhostWhite = 0x00F8F8FF
- Source Edit
colGold = 0x00FFD700
- Source Edit
colGoldenRod = 0x00DAA520
- Source Edit
colGray = 0x00808080
- Source Edit
colGreen = 0x00008000
- Source Edit
colGreenYellow = 0x00ADFF2F
- Source Edit
colHoneyDew = 0x00F0FFF0
- Source Edit
colHotPink = 0x00FF69B4
- Source Edit
colIndianRed = 0x00CD5C5C
- Source Edit
colIndigo = 0x004B0082
- Source Edit
colIvory = 0x00FFFFF0
- Source Edit
colKhaki = 0x00F0E68C
- Source Edit
colLavender = 0x00E6E6FA
- Source Edit
colLavenderBlush = 0x00FFF0F5
- Source Edit
colLawnGreen = 0x007CFC00
- Source Edit
colLemonChiffon = 0x00FFFACD
- Source Edit
colLightBlue = 0x00ADD8E6
- Source Edit
colLightCoral = 0x00F08080
- Source Edit
colLightCyan = 0x00E0FFFF
- Source Edit
colLightGoldenRodYellow = 0x00FAFAD2
- Source Edit
colLightGrey = 0x00D3D3D3
- Source Edit
colLightGreen = 0x0090EE90
- Source Edit
colLightPink = 0x00FFB6C1
- Source Edit
colLightSalmon = 0x00FFA07A
- Source Edit
colLightSeaGreen = 0x0020B2AA
- Source Edit
colLightSkyBlue = 0x0087CEFA
- Source Edit
colLightSlateGray = 0x00778899
- Source Edit
colLightSteelBlue = 0x00B0C4DE
- Source Edit
colLightYellow = 0x00FFFFE0
- Source Edit
colLime = 0x0000FF00
- Source Edit
colLimeGreen = 0x0032CD32
- Source Edit
colLinen = 0x00FAF0E6
- Source Edit
colMagenta = 0x00FF00FF
- Source Edit
colMaroon = 0x00800000
- Source Edit
colMediumAquaMarine = 0x0066CDAA
- Source Edit
colMediumBlue = 0x000000CD
- Source Edit
colMediumOrchid = 0x00BA55D3
- Source Edit
colMediumPurple = 0x009370D8
- Source Edit
colMediumSeaGreen = 0x003CB371
- Source Edit
colMediumSlateBlue = 0x007B68EE
- Source Edit
colMediumSpringGreen = 0x0000FA9A
- Source Edit
colMediumTurquoise = 0x0048D1CC
- Source Edit
colMediumVioletRed = 0x00C71585
- Source Edit
colMidnightBlue = 0x00191970
- Source Edit
colMintCream = 0x00F5FFFA
- Source Edit
colMistyRose = 0x00FFE4E1
- Source Edit
colMoccasin = 0x00FFE4B5
- Source Edit
- Source Edit
- Source Edit
colOldLace = 0x00FDF5E6
- Source Edit
colOlive = 0x00808000
- Source Edit
colOliveDrab = 0x006B8E23
- Source Edit
colOrange = 0x00FFA500
- Source Edit
colOrangeRed = 0x00FF4500
- Source Edit
colOrchid = 0x00DA70D6
- Source Edit
colPaleGoldenRod = 0x00EEE8AA
- Source Edit
colPaleGreen = 0x0098FB98
- Source Edit
colPaleTurquoise = 0x00AFEEEE
- Source Edit
colPaleVioletRed = 0x00D87093
- Source Edit
colPapayaWhip = 0x00FFEFD5
- Source Edit
colPeachPuff = 0x00FFDAB9
- Source Edit
colPeru = 0x00CD853F
- Source Edit
colPink = 0x00FFC0CB
- Source Edit
colPlum = 0x00DDA0DD
- Source Edit
colPowderBlue = 0x00B0E0E6
- Source Edit
colPurple = 0x00800080
- Source Edit
colRed = 0x00FF0000
- Source Edit
colRosyBrown = 0x00BC8F8F
- Source Edit
colRoyalBlue = 0x004169E1
- Source Edit
colSaddleBrown = 0x008B4513
- Source Edit
colSalmon = 0x00FA8072
- Source Edit
colSandyBrown = 0x00F4A460
- Source Edit
colSeaGreen = 0x002E8B57
- Source Edit
colSeaShell = 0x00FFF5EE
- Source Edit
colSienna = 0x00A0522D
- Source Edit
colSilver = 0x00C0C0C0
- Source Edit
colSkyBlue = 0x0087CEEB
- Source Edit
colSlateBlue = 0x006A5ACD
- Source Edit
colSlateGray = 0x00708090
- Source Edit
colSnow = 0x00FFFAFA
- Source Edit
colSpringGreen = 0x0000FF7F
- Source Edit
colSteelBlue = 0x004682B4
- Source Edit
colTan = 0x00D2B48C
- Source Edit
colTeal = 0x00008080
- Source Edit
colThistle = 0x00D8BFD8
- Source Edit
colTomato = 0x00FF6347
- Source Edit
colTurquoise = 0x0040E0D0
- Source Edit
colViolet = 0x00EE82EE
- Source Edit
colWheat = 0x00F5DEB3
- Source Edit
colWhite = 0x00FFFFFF
- Source Edit
colWhiteSmoke = 0x00F5F5F5
- Source Edit
colYellow = 0x00FFFF00
- Source Edit
colYellowGreen = 0x009ACD32
- Source Edit
Procs
proc `==`(a, b: Color): bool {.
borrow.}- compares two colors. Source Edit
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 Edit
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 Edit
proc extractRGB(a: Color): tuple[r, g, b: range[0 .. 255]] {.
raises: [], tags: [].}- extracts the red/green/blue components of the color a. Source Edit
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 Edit
proc `$`(c: Color): string {.
raises: [], tags: [].}- converts a color into its textual representation. Example: #00FF00. Source Edit
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 Edit
proc isColor(name: string): bool {.
raises: [], tags: [].}- returns true if name is a known color name or a hexadecimal color prefixed with #. Source Edit
proc rgb(r, g, b: range[0 .. 255]): Color {.
raises: [], tags: [].}- constructs a color from RGB values. Source Edit
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 Edit