diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2012-03-14 18:34:03 +0100 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2012-03-14 18:34:03 +0100 |
commit | 7f9b9b0ec979c9f35c1b922412c7b2731a3a6c66 (patch) | |
tree | 96bc15a3c45881d80c05034e6f424f90ef0979a4 /util.h | |
download | cv-7f9b9b0ec979c9f35c1b922412c7b2731a3a6c66.tar.gz cv-7f9b9b0ec979c9f35c1b922412c7b2731a3a6c66.tar.bz2 cv-7f9b9b0ec979c9f35c1b922412c7b2731a3a6c66.zip |
Add initial wimmel program
Diffstat (limited to 'util.h')
-rw-r--r-- | util.h | 58 |
1 files changed, 58 insertions, 0 deletions
@@ -0,0 +1,58 @@ +#ifndef _UTIL_H_ +#define _UTIL_H_ + +#include <glib.h> +#include <gtk/gtk.h> + +#include <string.h> + +typedef struct _point { + gint16 x, y; +} point_t; +#define POINT(_x, _y) ((point_t){.x=(_x), .y=(_y)}) + +/* a vector is the same as a point */ +typedef point_t vector_t; +#define VECTOR(_x, _y) POINT(_x, _y) + +static inline vector_t vector(point_t p1, point_t p2) { + return VECTOR(p2.x - p1.x, p2.y - p1.y); +} + +typedef struct _color { + guint8 r, g, b, a; +} color_t; +#define COLOR(_r, _g, _b, _a) ((color_t){.r=(_r), .g=(_g), .b=(_b), .a=(_a)}) +#define COL_MAX G_MAXUINT8 + +typedef struct _color32 { + gint32 r, g, b; +} color32_t; + +#define COLOR32(_r, _g, _b) ((color32_t){.r=(_r), .g=(_g), .b=(_b)}) +#define COL32_MAX G_MAXINT32 + +color32_t color32_add(color32_t, color32_t); +color32_t color32_mult(color32_t, gint); +color32_t to_color32(color_t); + +typedef struct _colord { + gdouble r, g, b, a; +} colord_t; +colord_t colord_add(colord_t, colord_t); +colord_t colord_mult(colord_t, gdouble); +colord_t to_colord(color_t); +#define COLORD(_r, _g, _b, _a) ((colord_t){.r=(_r), .g=(_g), .b=(_b), .a=(_a)}) +#define COLORD_MAX G_MAXDOUBLE + +void put_pixel(GdkPixbuf *pixbuf, point_t point, color_t color); + +color_t get_pixel(GdkPixbuf *pixbuf, point_t point); + +void color_to_yiq(color_t color, guint8 *y, guint8 *i, guint8 *q); + +color_t tint(color_t src, color_t tint_color); + +void ring_shift(void *_pntr, gint num, size_t size); + +#endif /* _UTIL_H_ */ |