src/chroma

Search:
Group by:
Source   Edit  

Everything you want to do with colors.

Procs

proc `$`(c: Color): string {....raises: [], tags: [], forbids: [].}
Returns colors as "(r, g, b, a)". Source   Edit  
proc almostEqual(a, b: Color; ep = 0.01): bool {....raises: [], tags: [],
    forbids: [].}
Returns true if colors are close Source   Edit  
proc darken(color: Color; amount: float32): Color {....raises: [], tags: [],
    forbids: [].}
Darkens the color by amount 0-1. Source   Edit  
proc desaturate(color: Color; amount: float32): Color {....raises: [], tags: [],
    forbids: [].}
Desaturate (makes grayer) the color by amount 0-1. Source   Edit  
func distance(c1, c2: SomeColor): float32
A distance function based on CIEDE2000 color difference formula Source   Edit  
func hash(c: Color): Hash {....raises: [], tags: [], forbids: [].}
Hashes a Color - used in tables. Source   Edit  
func hash(c: ColorCMY): Hash {....raises: [], tags: [], forbids: [].}
Hashes a ColorCMY - used in tables. Source   Edit  
func hash(c: ColorCMYK): Hash {....raises: [], tags: [], forbids: [].}
Hashes a ColorCMYK - used in tables. Source   Edit  
func hash(c: ColorHSL): Hash {....raises: [], tags: [], forbids: [].}
Hashes a ColorHSL - used in tables. Source   Edit  
func hash(c: ColorHSV): Hash {....raises: [], tags: [], forbids: [].}
Hashes a ColorHSV - used in tables. Source   Edit  
func hash(c: ColorLAB): Hash {....raises: [], tags: [], forbids: [].}
Hashes a ColorLAB - used in tables. Source   Edit  
func hash(c: ColorLUV): Hash {....raises: [], tags: [], forbids: [].}
Hashes a ColorLUV - used in tables. Source   Edit  
func hash(c: ColorOklab): Hash {....raises: [], tags: [], forbids: [].}
Hashes a ColorOklab - used in tables. Source   Edit  
func hash(c: ColorPolarLAB): Hash {....raises: [], tags: [], forbids: [].}
Hashes a ColorPolarLAB - used in tables. Source   Edit  
func hash(c: ColorPolarLUV): Hash {....raises: [], tags: [], forbids: [].}
Hashes a ColorPolarLUV - used in tables. Source   Edit  
func hash(c: ColorPolarOklab): Hash {....raises: [], tags: [], forbids: [].}
Hashes a ColorOklab - used in tables. Source   Edit  
func hash(c: ColorRGB): Hash {....raises: [], tags: [], forbids: [].}
Hashes a ColorRGB - used in tables. Source   Edit  
func hash(c: ColorRGBA): Hash {....raises: [], tags: [], forbids: [].}
Hashes a ColorRGB - used in tables. Source   Edit  
func hash(c: ColorXYZ): Hash {....raises: [], tags: [], forbids: [].}
Hashes a ColorXYZ - used in tables. Source   Edit  
func hash(c: ColorYUV): Hash {....raises: [], tags: [], forbids: [].}
Hashes a ColorYUV - used in tables. Source   Edit  
proc lighten(color: Color; amount: float32): Color {....raises: [], tags: [],
    forbids: [].}
Lightens the color by amount 0-1. Source   Edit  
proc mix(a, b: Color): Color {....raises: [], tags: [], forbids: [].}
Mixes two Color colors together using simple average. Source   Edit  
proc mix(a, b: Color; v: float32): Color {....raises: [], tags: [], forbids: [].}
Mixes two Color colors together using simple lerp. Source   Edit  
proc mix(a, b: ColorRGB): ColorRGB {....raises: [], tags: [], forbids: [].}
Mixes two ColorRGB colors together using simple average. Source   Edit  
proc mix(a, b: ColorRGBA): ColorRGBA {....raises: [], tags: [], forbids: [].}
Mixes two ColorRGBA colors together using simple average. Source   Edit  
proc mixCMYK(colorA, colorB: Color): Color {....raises: [], tags: [], forbids: [].}
Mixes two colors together using CMYK. Source   Edit  
proc parseHex(hex: string): Color {....raises: [InvalidColor], tags: [],
                                    forbids: [].}
Parses colors like:
  • FF0000 -> red
  • 0000FF -> blue
  • FFFFFF -> white
Source   Edit  
proc parseHexAlpha(hex: string): Color {....raises: [InvalidColor], tags: [],
    forbids: [].}
Parses colors like:
  • FF0000FF -> red
  • 0000FFFF -> blue
  • FFFFFFFF -> white
  • 000000FF -> opaque black
  • 00000000 -> transparent black
Source   Edit  
proc parseHtmlColor(colorText: string): Color {.
    ...raises: [InvalidColor, ValueError, KeyError], tags: [], forbids: [].}
Parses HTML color any any of the formats:
  • #FFF
  • #FFFFFF
  • rgb(255, 255, 255)
  • rgba(255, 255, 255, 1.0)
  • white
Source   Edit  
proc parseHtmlHex(hex: string): Color {....raises: [InvalidColor], tags: [],
                                        forbids: [].}
Parses colors with leading '#' like::
  • #FF0000 -> red
  • #0000ff -> blue
  • #ffffff -> white
Source   Edit  
proc parseHtmlHexTiny(hex: string): Color {....raises: [InvalidColor], tags: [],
    forbids: [].}
Parses colors with leading '#' and 3 hex numbers like::
  • #F00 -> red
  • #0ff -> blue
  • #fff -> white
Source   Edit  
proc parseHtmlName(text: string): Color {....raises: [InvalidColor, KeyError],
    tags: [], forbids: [].}
Parses HTML color as as a name:
  • "red"
  • "blue"
  • "white"
  • "amber"
  • "Lavender Gray"
Source   Edit  
proc parseHtmlRgb(text: string): Color {....raises: [InvalidColor, ValueError],
    tags: [], forbids: [].}
Parses colors in html's rgb format:
  • rgb(255, 0, 0) -> red
  • rgb(0,0,255) -> blue
  • rgb(255,255,255) -> white
Source   Edit  
proc parseHtmlRgba(text: string): Color {....raises: [InvalidColor, ValueError],
    tags: [], forbids: [].}
Parses colors in html's rgba format:
  • rgba(255, 0, 0, 1.0) -> red
  • rgba(0,0,255, 1.0) -> blue
  • rgba(255,255,255, 1.0) -> white
  • rgba(0,0,0,1.0) -> opaque black
  • rgba(0,0,0,0.0) -> transparent black

Note: rgb is 0-255, while alpha is 0 to 1.

Source   Edit  
proc saturate(color: Color; amount: float32): Color {....raises: [], tags: [],
    forbids: [].}
Saturates (makes brighter) the color by amount 0-1. Source   Edit  
proc spin(color: Color; degrees: float32): Color {....raises: [], tags: [],
    forbids: [].}
Rotates the hue of the color by degrees (0-360). Source   Edit  
proc toHex(c: Color): string {....raises: [], tags: [], forbids: [].}
Formats color as hex (upper case):
  • red -> FF0000
  • blue -> 0000FF
  • white -> FFFFFF
Source   Edit  
proc toHexAlpha(c: Color): string {....raises: [], tags: [], forbids: [].}
Formats color as hex (upper case):
  • red -> FF0000FF
  • blue -> 0000FFFF
  • white -> FFFFFFFF
  • opaque black -> 000000FF
  • transparent black -> 00000000
Source   Edit  
proc toHtmlHex(c: Color): string {....raises: [], tags: [], forbids: [].}
Formats color as HTML hex (upper case):
  • red -> #FF0000
  • blue -> #0000FF
  • white -> #FFFFFF
Source   Edit  
proc toHtmlHexTiny(c: Color): string {....raises: [], tags: [], forbids: [].}
Formats color as HTML 3 hex numbers (upper case):
  • red -> #F00
  • blue -> #00F
  • white -> #FFF
Source   Edit  
proc toHtmlRgb(c: Color): string {....raises: [], tags: [], forbids: [].}
Parses colors in html's rgb format:
  • red -> rgb(255, 0, 0)
  • blue -> rgb(0,0,255)
  • white -> rgb(255,255,255)
Source   Edit  
proc toHtmlRgba(c: Color): string {....raises: [], tags: [], forbids: [].}
Parses colors in html's rgb format:
  • red -> rgb(255, 0, 0)
  • blue -> rgb(0,0,255)
  • white -> rgb(255,255,255)
Source   Edit