[metapost] Color brewer for Metapost

Stephan Hennig sh-list at posteo.net
Mon Nov 30 19:30:53 CET 2015


Am 30.11.2015 um 00:07 schrieb Toby Thurston:

> I've prepared a small file that defines all the colorbrewer.org
> colours as RGB colours for MP.  Is this of general interest?

Definitely!  Blending colours in graphic design is as important a design
decision as blending fonts in text design (typography).  I'm not aware
of any solution for MetaPost (or LaTeX) that provides easy access to any
colour schemes.

 > If so I'd welcome feedback on my design

> % Metapost version adapdted from CSS specs by Toby Thurston.

Regarding CSS specs, did you export those by hand?  On
<URL:http://www.personal.psu.edu/cab38/ColorBrewer/ColorBrewer_updates.html>,
I find references to Excel files (sic!) containing colour
specifications.  For package mpcolornames, I've written script files
(AWK, I think) that convert xcolor colour definition files to MetaPost.
 That way, MetaPost colour definition files can easily be re-created
from the "original" source files.  I didn't have a look at the color
brewer Excel files.  But my recommendation is to explore an
automatic conversion path from some input format to MetaPost files for
easier maintenance.

As far as I see, colorbrewer.mp only contains RGB colours.  But on
<URL:http://colorbrewer.org/>, I also find CMYK colour specifications.
It would be nice to have CMYK colour specifications available in
MetaPost, too.


> % Six of the qualititative colour sets have numbers in their names at colorbrewer.org
> % MP doesn't allow this, so they are renamed here as follows:

While this statement is no exactly wrong, an expression "var1" is not
invalid either.  It just doesn't refer to a variable named var1, but to
an array variable var[1]:

  rgbcolor Red[][][];
  Red[1][1][1] := (0.2, 0.2, 0.5);
  show Red1[1][1];
  end

That way, I think one can do with the original color brewer names.  I
make use of this syntax for colour names from X11 specification in
package mpcolornames.


> and whether I should submit it to CTAN.

Alternatively, it could be merged into package mpcolornames.  (Will have
to check licence compatibility, though.  Color brewer colour
specifications seem to be Apache 2.0 licensed.  Package mpcolornames is
LPPL.)

Or more generally, I think it would make sense to also have those colour
schemes available in LaTeX.  So, perhaps approach the author of package
xcolor?  Colour definitions could then be easily grabbed from that
package so that xcolor and mpcolornames are in sync and colour names
always refer to the same colour values.

Best regards,
Stephan Hennig



More information about the metapost mailing list