Procs
proc Color(r, g, b, a: float): ColorRef {...}{.raises: [], tags: [].}
- Creates a new Color from RGBA. r, g, b and a is a numbers ranges 0.0..1.0.
proc Color(r, g, b: float): ColorRef {...}{.inline, raises: [], tags: [].}
- Creates a new Color from RGB. r, g and b is a numbers ranges 0.0..1.0.
proc Color(r, g, b, a: uint8): ColorRef {...}{.raises: [], tags: [].}
- Creates a new Color from RGBA. r, g, b and a is a numbers ranges 0..255.
proc Color(r, g, b: uint8): ColorRef {...}{.inline, raises: [], tags: [].}
- Creates a new Color from RGB. r, g and b is a numbers ranges 0..255.
proc Color(src: string): ColorRef {...}{.raises: [ValueError], tags: [].}
-
Parses color from string. src should be a string, begins with "#", "0x" or "0X" and have a RRGGBBAA color value.
Examples:
var clr1 = Color("#FFCCAAFF") clr2 = Color("0xFFAACCFF") clr3 = Color("0XAACCFFFF") clr4 = Color("#AAFFCCFF") echo clr1 echo clr2 echo clr3 echo clr4
proc Color(src: uint32): ColorRef {...}{.raises: [], tags: [].}
-
Translate uint32 color to the Color object.
Examples:
var clr1 = Color(0xFFCCAAFF'u32) clr2 = Color(0xFFAACCFF'u32) clr3 = Color(0xAACCFFFF'u32) clr4 = Color(0xAAFFCCFF'u32) echo clr1 echo clr2 echo clr3 echo clr4
proc Color(): ColorRef {...}{.inline, raises: [], tags: [].}
- Creates a new Color object with RGBA value (0, 0, 0, 0)
proc normalize(n: float): uint32 {...}{.inline, raises: [], tags: [].}
proc normalize(n, min, max: float): float {...}{.inline, raises: [], tags: [].}
- Returns number in range 0.0..1.0.
proc normalizeColor(color: float): float {...}{.inline, raises: [], tags: [].}
- Returns number in range 0..255.
proc toUint32BE(color: ColorRef): uint32 {...}{.raises: [], tags: [].}
- Converts Color object to uint32 with big endian.
proc toUint32LE(color: ColorRef): uint32 {...}{.raises: [], tags: [].}
- Converts Color object to uint32 with little endian.
proc toFloatTuple(color: ColorRef): tuple[r, g, b, a: float] {...}{.raises: [], tags: [].}
- Converts Color object to the tuple.
proc toUint32Tuple(color: ColorRef): tuple[r, g, b, a: uint32] {...}{.raises: [], tags: [].}
- Converts Color object to the tuple.
proc toUint32BEWithoutAlpha(color: ColorRef): uint32 {...}{.raises: [], tags: [].}
- Converts Color object to uint32 without alpha-channel with big endian.
proc toUint32LEWithoutAlpha(color: ColorRef): uint32 {...}{.raises: [], tags: [].}
- Converts Color object to uint32 without alpha-channel with little endian.
proc lerp(self, other: ColorRef; lerpv: float): uint32 {...}{.raises: [], tags: [].}
-
linear interpolate color.
Arguments:
- self and other - Color objects.
- lerpv - linear interpolate value
proc lerp(r1, g1, b1, a1, r2, g2, b2, a2: uint32; lerpv: float): uint32 {...}{.raises: [], tags: [].}
proc `$`(color: ColorRef): string {...}{.raises: [], tags: [].}