From 7f9b9b0ec979c9f35c1b922412c7b2731a3a6c66 Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Wed, 14 Mar 2012 18:34:03 +0100 Subject: Add initial wimmel program --- util.h | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 util.h (limited to 'util.h') diff --git a/util.h b/util.h new file mode 100644 index 0000000..e0833cf --- /dev/null +++ b/util.h @@ -0,0 +1,58 @@ +#ifndef _UTIL_H_ +#define _UTIL_H_ + +#include +#include + +#include + +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_ */ -- cgit