Displaying a fraction

This commit is contained in:
Romain Goyet
2015-05-19 11:13:31 +02:00
parent f487d775ff
commit 96aaccaa62
17 changed files with 161 additions and 20 deletions

17
kandinsky/fonts/Makefile Normal file
View File

@@ -0,0 +1,17 @@
FREETYPE_PATH := /usr/local/Cellar/freetype/2.5.5
LIBPNG_PATH = /usr/local/Cellar/libpng/1.6.17
#LIBPNG_PATH is optional, PNGs won't be generated
CC := clang
CFLAGS := -I$(FREETYPE_PATH)/include/freetype2
LDFLAGS := -L$(FREETYPE_PATH)/lib -lfreetype
ifdef LIBPNG_PATH
CFLAGS += -I$(LIBPNG_PATH)/include -DGENERATE_PNG=1
LDFLAGS += -L$(LIBPNG_PATH)/lib -lpng
endif
default:
$(CC) $(CFLAGS) $(LDFLAGS) rasterizer.c -o rasterizer
clean:
rm rasterizer

View File

@@ -3,8 +3,8 @@
#include <kandinsky/color.h>
#include <kandinsky/line.h>
#include <kandinsky/point.h>
#include <kandinsky/rect.h>
#include <kandinsky/text.h>
#include <kandinsky/types.h>
#endif

View File

@@ -1,7 +1,7 @@
#ifndef KANDINSKY_LINE_H
#define KANDINSKY_LINE_H
#include <kandinsky/point.h>
#include <kandinsky/types.h>
void KDDrawLine(KDPoint p1, KDPoint p2);

View File

@@ -1,11 +0,0 @@
#ifndef KANDINSKY_POINT_H
#define KANDINSKY_POINT_H
#include <kandinsky/coordinate.h>
typedef struct {
KDCoordinate x;
KDCoordinate y;
} KDPoint;
#endif

View File

@@ -0,0 +1,26 @@
#ifndef KANDINSKY_RECT_H
#define KANDINSKY_RECT_H
#include <kandinsky/color.h>
#include <kandinsky/types.h>
typedef struct {
union {
struct {
KDCoordinate x;
KDCoordinate y;
};
KDPoint origin;
};
union {
struct {
KDCoordinate width;
KDCoordinate height;
};
KDPoint size;
};
} KDRect;
void KDFillRect(KDRect rect, KDColor color);
#endif

View File

@@ -1,7 +1,7 @@
#ifndef KANDINSKY_TEXT_H
#define KANDINSKY_TEXT_H
#include <kandinsky/point.h>
#include <kandinsky/types.h>
void KDDrawChar(char character, KDPoint p);
void KDDrawString(char * text, KDPoint p);

View File

@@ -0,0 +1,18 @@
#ifndef KANDINSKY_TYPES_H
#define KANDINSKY_TYPES_H
#include <stdint.h>
typedef uint16_t KDCoordinate;
typedef struct {
KDCoordinate x;
KDCoordinate y;
} KDPoint;
typedef struct {
KDCoordinate width;
KDCoordinate height;
} KDSize;
#endif

View File

@@ -1,6 +1,8 @@
#include <kandinsky/line.h>
#include <framebuffer.h>
void KDDrawLine(KDPoint p1, KDPoint p2) {
for (KDCoordinate x = p1.x; x<p2.x; x++) {
PIXEL(x, p1.y) = 0xC7;
}
}

9
kandinsky/src/rect.c Normal file
View File

@@ -0,0 +1,9 @@
#include <kandinsky/rect.h>
#include <framebuffer.h>
#include <string.h>
void KDFillRect(KDRect rect, KDColor color) {
for (KDCoordinate y = rect.y ; y < (rect.y + rect.height); y++) {
memset(PIXEL_ADDRESS(rect.x, y), color, rect.width);
}
}