[GRASSLIST:5512] Re: hexadecimal color codes

Moritz Lennert mlennert at club.worldonline.be
Tue Jan 25 05:04:34 EST 2005


On Fri, 21 Jan 2005 10:00:06 -0600, Kirk R. Wythers wrote:
> Can anyone tell me if GRASS can deal with hexadecimal color codes
> (something like 0100FFAA)? I have a ascii vector file that contains
> hexadecimal color codes for the lines and polygons. I am writing a
> small program that converts that ascii vector file (which was output
> from another gis package) into the v.in.ascii format, and I wonder if
> I can retain that information.

On Mon, 24 Jan 2005 14:08:57 +1300, Hamish wrote:
>maybe an awk expert can give a shell script version of this C code to do
>the translation:
>
>int r,g,b;
>sscanf(color, "0x%02x%02x%02x", &r, &g, &b);
>printf("%03d:%03d":%03d\n", r, g, b);

I'm no awk expert, but there does not seem to exist an easy way to do this in
awk. But you can find a possible solution here:
http://www.cs.ucsb.edu/~sherwood/awk/hexstuff.awk.txt

Moritz




More information about the grass-user mailing list