imccrum / canviz

Automatically exported from code.google.com/p/canviz
0 stars 0 forks source link

Special-case colors black, white and lightgrey #34

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
If you draw a graph with default colors, like this:

digraph one { node [style=filled]; a }

and render it to xdot, you get _*draw_ commands that use the color names 
"white" (for the graph 
background), "black" (for the node outline and label) and "lightgrey" (for the 
node fill). A mini X11 
color scheme with just these three colors was added to Canviz in issue #14 so 
that you can use 
Canviz without loading x11colors.js.

A problem arises if you specify a different color scheme but still want those 
default colors, like this:

digraph two { graph [colorscheme=reds4]; node [colorscheme=reds4, 
style=filled]; a }

Graphviz still expresses the colors as "white", "black" and "lightgrey", though 
there are no colors by 
those names in the reds4 color scheme.

I proposed that the default colors used by Graphviz should really be "/white", 
"/black" and 
"/lightgrey" (the preceding slash means the color should be looked up in the 
X11 color scheme, 
irrespective of what color scheme has otherwise been selected):

https://mailman.research.att.com/pipermail/graphviz-interest/2008q4/005772.html

In a response that didn't go to the list, Emden revealed that Graphviz actually 
has a special case 
internally for ensuring that the color "black" always resolves regardless of 
color scheme, but that 
special cases for the other two default colors were forgotten. This explains 
why "digraph two" above 
produces the errors "Warning: lightgrey is not a known color" and "Warning: 
white is not a known 
color" but no complaint about the color black.

In Canviz, we should have a similar fallback. If looking up a named color in 
the selected color 
scheme fails, look it up in the internal fallback color scheme. I'm inclined to 
provide the fallback for 
all three colors, not just black. We can change the mini X11 color scheme added 
in issue #14 into 
the fallback color scheme.

Original issue reported on code.google.com by ryandesi...@gmail.com on 2 Nov 2008 at 7:57

GoogleCodeExporter commented 9 years ago
Fixed in r210.

Original comment by ryandesi...@gmail.com on 3 Nov 2008 at 1:26