X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=src%2Fplugins%2Fradar-info.h;h=8daf2b936d12a34accad88476289e6c0f968e21a;hb=9e734911e96ae83b0f41afa5073d5313bc197d96;hp=e92dffc9a19ef903c78c83be3c0acf220e6c5395;hpb=84c9924553482ded8566105d4559088a6ab543ac;p=aweather diff --git a/src/plugins/radar-info.h b/src/plugins/radar-info.h index e92dffc..8daf2b9 100644 --- a/src/plugins/radar-info.h +++ b/src/plugins/radar-info.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2010 Andy Spencer + * Copyright (C) 2009-2011 Andy Spencer * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,11 +22,21 @@ #include typedef struct { - int type; - const char *name; - guint8 data[256][4]; + gint type; // From RSL e.g. DZ_INDEX + gchar *file; // Basename of the colors file + gchar name[64]; // Name of the colormap (line 1) + gfloat scale; // Map values to color table idx (line 2) + gfloat shift; // index = value*scale + shift (line 3) + gint len; // Length of data + guint8 (*data)[4]; // The actual colormap (line 4..) } AWeatherColormap; extern AWeatherColormap colormaps[]; +static inline guint8 *colormap_get(AWeatherColormap *colormap, float value) +{ + int idx = value * colormap->scale + colormap->shift; + return colormap->data[CLAMP(idx, 0, colormap->len)]; +} + #endif