module Werk::Utils::Colors

Defined in:

werk/utils/colors.cr

Constant Summary

PALETTE = begin colors = Array(Colorize::Color256).new 6.times do |red| 6.times do |green| 6.times do |blue| brightness = (red + green) + blue saturation = [red, green, blue].max - [red, green, blue].min if (brightness < 4 || brightness > 11) || saturation < 2 next end colors << (Colorize::Color256.new((((16 + (36 * red)) + (6 * green)) + blue).to_u8)) end end end n = colors.size step = (n * 0.618).to_i.clamp(1, n - 1) while (n.gcd(step)) != 1 step = step + 1 end spaced = Array(Colorize::Color256).new(n) idx = 0 n.times do spaced << colors[idx] idx = (idx + step) % n end spaced end

Generated from the 6×6×6 color cube (codes 16–231). Filtered for visibility on dark and light terminals: brightness (r+g+b) in [4, 11], saturation (max-min) >= 2

Class Method Summary

Class Method Detail

def self.next_color : Colorize::Color #

[View source]