JuliaAttic / Color.jl

Basic color manipulation utilities.
Other
47 stars 21 forks source link

Added color swatches for color_names, sorted by luminance #97

Closed cormullion closed 9 years ago

cormullion commented 9 years ago

replacing PDF color chart (#92) with an SVG version.

jiahao commented 9 years ago

A belated thank you for doing this. I've found myself referring to the preview picture in #92 several times.

A small suggestion: would it be possible to detect colors with multiple names and use a single swatch for them? There are quite few such points, such as "grey50" and "gray50".

lobingera commented 9 years ago

You write .svg more or less hard coded. Are you interested in doing this via Compose.jl ?

cormullion commented 9 years ago

@jiahao That's a good idea - the layout would be a challenge, I suppose, for linking a set of names to a single swatch... Will have a cup of tea on it and think about it.

@lobingera Guilty as charged... :) I had a look at Compose.jl once but I confess I didn't 'get it' — too much recursion/compsci stuff for my small brain, I suppose.

(I once heard Stefan Karpinski talk about how his Dad didn't really like some of the fancier programming methodologies, but was perfectly happy to hack on PostScript. Sometimes you just want to put a rectangle on the page...!)

lobingera commented 9 years ago

@cormullion

I so understand Stefan's dad: I still have some tooling around (in python) to write and update (correct!) PDF with a text editor and i learned PS ~1994 ...

The color ranges put in #75 are Compose 4 liners:

julia> using Compose

julia> w = Compose.PNG("a5.png",400.0px,100.0px);

julia> n = 64;

julia> r = rectangle(linspace(0,1-(1/n),n),0.1*ones(n),ones(n)*(1.1/(n)),0.8*ones(n));

julia> cm = linspace(Color.HSV(0,1,0),Color.HSV(330,1,1),64);

julia> c = compose(context(),r,fill(cm));

julia> Compose.draw(w,c)

and these are all 35 color ranges in ColorBrewer at 8 steps.

a4


shell>  cat color_display.jl
using Compose
using Color
using ColorBrewer

w = Compose.PNG("a4.png",600.0px,800.0px);

nm = keys(ColorBrewer.colorSchemes)

l = length(nm)
c = Array(Compose.Context,l)
for k in enumerate(nm)

    n = 8

    cm = ColorBrewer.palette(k[2],n)
    r = rectangle(linspace(0,1-(1/n),n),0.1*ones(n),ones(n)*(1.1/(n)),0.8*ones(n));

    c[k[1]] = compose(context(),r,fill(cm));
end

c0 = compose(context(),vstack(c...))

Compose.draw(w,c0)

But i'm still struggling with text by Compose.

cormullion commented 9 years ago

Duplicate colors are now handled by showing their names under the swatch of other colors with the same names. Which makes me wonder, why are there duplicates such as:

julia> Color.color_names["honeydew"]
(240,255,240)

julia> Color.color_names["honeydew1"]
(240,255,240)
jiahao commented 9 years ago

This is a nice addition to the documentation. Thanks

jiahao commented 9 years ago

In general, it is good practice to check in the script and the generated output in separate commits.