JuliaGraphics / ColorSchemes.jl

colorschemes, colormaps, gradients, and palettes
http://juliagraphics.github.io/ColorSchemes.jl/
Other
187 stars 33 forks source link

Feature request: Include the web-safe color palette #79

Closed adrhill closed 2 years ago

adrhill commented 3 years ago

For some legacy fun, it would be nice to have access to the web-safe color palette. The full color table can be found here.

cormullion commented 3 years ago

Well, why not! 😃

using Colors, ColorSchemes

ColorScheme([parse(RGB, "#$(string(r, base=16))$(string(g, base=16))$(string(b, base=16))") 
        for r in 0x0:3:0xf for g in 0x0:3:0xf for b in 0x0:3:0xf])
Screenshot 2021-09-14 at 11 25 02

Is this a useful order, or would another order be better?

adrhill commented 3 years ago

That's a cool one-liner! The ordering looks good to me too. :)

adrhill commented 3 years ago

You could code-golf this even further as

ColorScheme([parse(RGB, "#$(string.([r,g,b], base=16)...)") for r in 0x0:3:0xf for g in 0x0:3:0xf for b in 0x0:3:0xf])

at a small loss of performance.

cormullion commented 2 years ago

Cool. Fortunately this package isn't smart enough to generate the schemes in code 😄

cormullion commented 2 years ago

added in https://github.com/JuliaGraphics/ColorSchemes.jl/commit/f7d43feee83df88af4b66e3c1ac159d44b604b65

adrhill commented 2 years ago

Thanks a lot!