]> Pileus Git - aweather/blobdiff - src/plugins/radar-info.h
Convert GtkBox and GtkScale to GTK 3 version
[aweather] / src / plugins / radar-info.h
index e92dffc9a19ef903c78c83be3c0acf220e6c5395..8daf2b936d12a34accad88476289e6c0f968e21a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009-2010 Andy Spencer <andy753421@gmail.com>
+ * Copyright (C) 2009-2011 Andy Spencer <andy753421@gmail.com>
  *
  * 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
 #include <rsl.h>
 
 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