mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
Displaying a fraction
This commit is contained in:
17
kandinsky/fonts/Makefile
Normal file
17
kandinsky/fonts/Makefile
Normal 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
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
#ifndef KANDINSKY_POINT_H
|
||||
#define KANDINSKY_POINT_H
|
||||
|
||||
#include <kandinsky/coordinate.h>
|
||||
|
||||
typedef struct {
|
||||
KDCoordinate x;
|
||||
KDCoordinate y;
|
||||
} KDPoint;
|
||||
|
||||
#endif
|
||||
26
kandinsky/include/kandinsky/rect.h
Normal file
26
kandinsky/include/kandinsky/rect.h
Normal 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
|
||||
@@ -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);
|
||||
|
||||
18
kandinsky/include/kandinsky/types.h
Normal file
18
kandinsky/include/kandinsky/types.h
Normal 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
|
||||
@@ -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
9
kandinsky/src/rect.c
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user