summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 425fad0)
raw | patch | inline | side by side (parent: 425fad0)
author | Florian Forster <ff@octo.it> | |
Fri, 2 Jul 2010 18:27:17 +0000 (20:27 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Fri, 2 Jul 2010 18:27:17 +0000 (20:27 +0200) |
src/common.c | patch | blob | history | |
src/common.h | patch | blob | history |
diff --git a/src/common.c b/src/common.c
index d6047c43ca75f64578c9fc60c4c3c06654be3af1..0df85ebbfd4adf5803ca5740a82efd215c16509d 100644 (file)
--- a/src/common.c
+++ b/src/common.c
| ((uint32_t) b));
} /* }}} uint32_t rgb_to_uint32 */
+static int uint32_to_rgb (uint32_t color, double *rgb)
+{
+ uint8_t r;
+ uint8_t g;
+ uint8_t b;
+
+ r = (uint8_t) ((color >> 16) & 0x00ff);
+ g = (uint8_t) ((color >> 8) & 0x00ff);
+ b = (uint8_t) ((color >> 0) & 0x00ff);
+
+ rgb[0] = ((double) r) / 255.0;
+ rgb[1] = ((double) g) / 255.0;
+ rgb[2] = ((double) b) / 255.0;
+
+ return (0);
+} /* }}} int uint32_to_rgb */
+
uint32_t get_random_color (void) /* {{{ */
{
double hsv[3] = { 0.0, 1.0, 1.0 };
return (rgb_to_uint32 (rgb));
} /* }}} uint32_t get_random_color */
+uint32_t fade_color (uint32_t color) /* {{{ */
+{
+ double rgb[3];
+
+ uint32_to_rgb (color, rgb);
+ rgb[0] = 1.0 - ((1.0 - rgb[0]) * 0.1);
+ rgb[1] = 1.0 - ((1.0 - rgb[1]) * 0.1);
+ rgb[2] = 1.0 - ((1.0 - rgb[2]) * 0.1);
+
+ return (rgb_to_uint32 (rgb));
+} /* }}} uint32_t fade_color */
+
int print_debug (const char *format, ...) /* {{{ */
{
static _Bool have_header = 0;
diff --git a/src/common.h b/src/common.h
index ad589e7bfd717bf786cf32fd5bbc12895255d6e8..e08c455d884a6f1b7396cdf7b5a2b6be751c732e 100644 (file)
--- a/src/common.h
+++ b/src/common.h
size_t *ret_dses_num, char ***ret_dses);
uint32_t get_random_color (void);
+uint32_t fade_color (uint32_t color);
char *strtolower (char *str);
char *strtolower_copy (const char *str);