static Uint32 color_function(int tile_x, int tile_y, channel_t* temperature_channel, channel_t* humidity_channel, channel_t* spirit_channel) { float temperature = channel_get(temperature_channel, tile_x, tile_y); float humidity = channel_get(humidity_channel, tile_x, tile_y); float spirit = channel_get(spirit_channel, tile_x, tile_y); float tdev = fabs(0.5f - temperature / (float)TEMPERATURE_RANGE) / 3.0f; float hdev = fabs(0.5f - humidity / (float)HUMIDITY_RANGE) / 3.0f; float sdev = fabs(0.5f - spirit / (float)SPIRIT_RANGE) / 3.0f; Uint8 R = (Uint8)((sdev * 0.5f + tdev + hdev * 1.5f) * 256); Uint8 G = (Uint8)((0.95f - (sdev + tdev + hdev)) * 256); Uint8 B = (Uint8)((sdev * 1.5f + tdev + hdev * 0.5f) * 256); return SDL_MapRGBA(screen->format, R, G, B, 0xFF); }
static char *script_schan_get(char *chan_name, char *setting) { channel_t *chan = channel_probe(chan_name, 0); char *value; if (!chan) return(NULL); channel_get(chan, &value, setting, 0, NULL); return(value); }