cligen/colorScl

Types

Scale = enum
  sGray = "gray",           ## Grey scale black -> white
  sHue = "hue",             ## Ancient HSV system "everyone" knows
  sWLen = "wLen",           ## Close to a physical spectrum/rainbow
  sPm3D = "pm3d",           ## Popularized by OS/2PresMgr | Gnuplot
  sViridis = "viridis"       ## Very popular, maps well to gray outs
UnitR = range[0.0 .. 1.0]

Consts

helpColorScl = "{fbu}sNAME<0.-1>[,..]: element of NAME: viridis hue[,s,v] wLen[,s,v] gray pm3d"

Procs

proc hex(rgb: Color3; lim: range[5 .. 1024] = 256): string {....raises: [],
    tags: [], forbids: [].}
Produce a string RGB RRGGBB or RRRGGGBBB of hex RedGreenBlue as needed. This is useful for HTML|X11 color specification even w/10-bit HDR color.
proc hsv2rgb(hsv: Color3): Color3 {....raises: [], tags: [], forbids: [].}
Convert from hue-saturation-value to red-green-blue color system.
proc parseColorScl(s: MSlice | openArray[char] | string;
                   nParsed: var int = doNotUse): Color3
Parse color scale like <sclNmPfx>FLOAT[,..] where <sclNmPfx> is the first letter of a scale name, FLOAT is 0..1 scale, & [,..] are optional params. nParse gets number of chars handled. An eg. good spec is: "w.3,.7,.65" for 30% wLen at 70% saturation, 65% value. { Yes, this could be fancier. }
proc rgb(x: UnitR; scale = sWLen; sat = UnitR(0.7); val = UnitR(0.9)): Color3 {.
    ...raises: [], tags: [], forbids: [].}
Map x to RGB for a variety of false color scales as specified by scale. Parameters sat & val may be ignored depending upon scale.
proc scaledCompon(x: float; lim: range[4 .. 1024] = 256): int {....raises: [],
    tags: [], forbids: [].}
proc ttc(rgb: Color3; lim: range[5 .. 1024] = 256): string {....raises: [],
    tags: [], forbids: [].}
Produce decimal R;G;B string for a Terminal True Color specification.
proc xt256(rgb: Color3; lim: range[5 .. 1024] = 256): string {....raises: [],
    tags: [], forbids: [].}
Produce decimal string for xterm-256 666 color cube specification.