.struct RGB {r,g,b} .var s_palette = List().add( RGB(0,0,0), // black 0 RGB(255,255,255), // white 1 RGB(104,55,43), // red 2 RGB(131,240,220), // cyan 3 RGB(111,61,134), // purple 4 RGB(89,205,54), // green 5 RGB(65,55,205), // blue 6 RGB(184,199,111), // yellow 7 RGB(209,127,48), // orange 8 RGB(67,57,0), // brown 9 RGB(154,103,89), // light_red 10 RGB(91,91,91), // dark_gray 11 RGB(142,142,142), // gray 12 RGB(157,255,157), // light_green 13 RGB(117,161,236), // light_blue 14 RGB(193,193,193) // light_gray 15 ); .function colorDistance(c1,c2) { .var cr = c1.r-c2.r .var cg = c1.g-c2.g .var cb = c1.b-c2.b .return sqrt([cr*cr] + [cg*cg] + [cb*cb]) } .function getClosestColorIndex(rgb) { .return getClosestColorIndex( rgb, s_palette ) } .function getClosestColorIndex(rgb, palette) { .var distance = colorDistance(rgb, palette.get(0)) .var closestColorIndex = 0 .for (var index = 1; index < palette.size(); index++) { .var d = colorDistance(rgb, palette.get(index)) .if (d < distance) { .eval distance = d .eval closestColorIndex = index } } .return closestColorIndex }
.const str = "TESTING" text: .fill str.size(), str.charAt(i) & $3f
.const str = "TESTING" .function to_scr(c) { .return c & $3f } text: .fill str.size(), to_scr(str.charAt(i))
.const str = "TESTING" text: .fill str.size(), $3f & str.charAt(i)
.var a = 'x' & 1
.var b = 1 & 'x'
.var a = [0+'x'] & 1