diff --git a/kandinsky/Makefile b/kandinsky/Makefile index 9640ce7fa..70f5038a1 100644 --- a/kandinsky/Makefile +++ b/kandinsky/Makefile @@ -1,11 +1,13 @@ SFLAGS += -Ikandinsky/include objs += $(addprefix kandinsky/src/,\ - font.o\ - line.o\ - pixel.o\ - rect.o\ - text.o\ - types.o) + drawing_area.o\ + font.o\ + line.o\ + pixel.o\ + rect.o\ + text.o\ + types.o\ +) tests += $(addprefix kandinsky/test/, set_pixel.c) FREETYPE_PATH := /usr/local/Cellar/freetype/2.6.3 diff --git a/kandinsky/include/kandinsky.h b/kandinsky/include/kandinsky.h index 7f34c1825..2da081651 100644 --- a/kandinsky/include/kandinsky.h +++ b/kandinsky/include/kandinsky.h @@ -2,6 +2,7 @@ #define KANDINSKY_KANDINSKY_H #include +#include #include #include #include diff --git a/kandinsky/include/kandinsky/drawing_area.h b/kandinsky/include/kandinsky/drawing_area.h new file mode 100644 index 000000000..2c37e6926 --- /dev/null +++ b/kandinsky/include/kandinsky/drawing_area.h @@ -0,0 +1,12 @@ +#ifndef KANDINSKY_DRAWING_AREA +#define KANDINSKY_DRAWING_AREA 1 + +#include + +/* The drawing area is a very important yet simple concept. + * When you set a drawing area (using absolute coordinates), two things happen: + * - No drawing will ever happen outside of the specified rect + * - All coordinates will then be interpreted as relative to the rect origin */ +void KDSetDrawingArea(KDRect rect); + +#endif diff --git a/kandinsky/include/kandinsky/pixel.h b/kandinsky/include/kandinsky/pixel.h index b6c88435e..d3e3a045d 100644 --- a/kandinsky/include/kandinsky/pixel.h +++ b/kandinsky/include/kandinsky/pixel.h @@ -2,18 +2,8 @@ #define KANDINSKY_REFERENTIAL_H #include -#include #include -/* The drawing area is a very important yet simple concept. - * When you set a drawing area (using absolute coordinates), two things happen: - * - No drawing will ever happen outside of the specified rect - * - All coordinates will then be interpreted as relative to the rect origin */ -void KDSetDrawingArea(KDRect rect); - void KDSetPixel(KDPoint p, KDColor c); -//KDColor * KDPixelAddress(KDPoint p); -//#define COLOR(p) *KDPixelAddress(p) - #endif diff --git a/kandinsky/src/drawing_area.c b/kandinsky/src/drawing_area.c new file mode 100644 index 000000000..4f871ad66 --- /dev/null +++ b/kandinsky/src/drawing_area.c @@ -0,0 +1,12 @@ +#include + +KDRect KDDrawingArea = { + .x = 0, + .y = 0, + .width = KDCoordinateMax, + .height = KDCoordinateMax +}; + +void KDSetDrawingArea(KDRect rect) { + KDDrawingArea = rect; +} diff --git a/kandinsky/src/pixel.c b/kandinsky/src/pixel.c index 6467549e5..1d8189cee 100644 --- a/kandinsky/src/pixel.c +++ b/kandinsky/src/pixel.c @@ -1,21 +1,11 @@ #include #include #include - -static KDRect sDrawingArea = { - .x = 0, - .y = 0, - .width = KDCoordinateMax, - .height = KDCoordinateMax -}; - -void KDSetDrawingArea(KDRect rect) { - sDrawingArea = rect; -} +#include "private/drawing_area.h" void KDSetPixel(KDPoint p, KDColor c) { - if (p.x >= 0 && p.x < sDrawingArea.width && - p.y >= 0 && p.y < sDrawingArea.height) { - ion_set_pixel(p.x+sDrawingArea.x, p.y+sDrawingArea.y, c); + if (p.x >= 0 && p.x < KDDrawingArea.width && + p.y >= 0 && p.y < KDDrawingArea.height) { + ion_set_pixel(p.x+KDDrawingArea.x, p.y+KDDrawingArea.y, c); } } diff --git a/kandinsky/src/private/drawing_area.h b/kandinsky/src/private/drawing_area.h new file mode 100644 index 000000000..27aae1d6a --- /dev/null +++ b/kandinsky/src/private/drawing_area.h @@ -0,0 +1,8 @@ +#ifndef KANDINSKY_PRIVATE_DRAWING_AREA +#define KANDINSKY_PRIVATE_DRAWING_AREA 1 + +#include + +extern KDRect KDDrawingArea; + +#endif