add 5x4 Font

This commit is contained in:
j3d1 2018-11-01 19:39:19 +01:00
parent 987aa92a23
commit 1009d689bc
15 changed files with 346 additions and 25 deletions

48
inc/gfx/canvas.h Normal file
View file

@ -0,0 +1,48 @@
//
// Created by jedi on 11/1/18.
//
#ifndef MGL_DMXMENU_CANVAS_H
#define MGL_DMXMENU_CANVAS_H
#include "hal.h"
#include "gfx/font.h"
class canvas {
private:
const int width_;
const int height_;
public:
canvas(int w, int h) : width_(w), height_(h) {
}
void draw(int x, int y) {
hal_draw(x, y);
}
void print(int x, int y, const char *str) {
for (int i = 0; str[i]; i++) {
int j = (str[i] - ' ') % 32;
for (int x_ = 0; x_ < 4; x_++)
for (int y_ = 0; y_ < 5; y_++)
if (testFont[j][x_ + 4 * y_])
draw(x + i * 5 + x_, y + y_);
}
}
void print(int x, int y, char *str) {
for (int i = 0; str[i]; i++) {
int j = (str[i] - ' ') % 32;
for (int x_ = 0; x_ < 4; x_++)
for (int y_ = 0; y_ < 5; y_++)
if (testFont[j][x_ + 4 * y_])
draw(x + i * 5 + x_, y + y_);
}
}
};
#endif //MGL_DMXMENU_CANVAS_H

16
inc/gfx/font.h Normal file
View file

@ -0,0 +1,16 @@
//
// Created by jedi on 11/1/18.
//
#ifndef MGL_DMXMENU_FONT_H
#define MGL_DMXMENU_FONT_H
class font {
};
extern bool testFont[32][20];
#endif //MGL_DMXMENU_FONT_H

32
inc/gfx/screen.h Normal file
View file

@ -0,0 +1,32 @@
//
// Created by jedi on 11/1/18.
//
#ifndef MGL_DMXMENU_SCREEN_H
#define MGL_DMXMENU_SCREEN_H
#include "hal.h"
//template <int WIDTH, int HEIGHT>
class screen {
private:
const int width_;
const int height_;
public:
screen(int w, int h): width_(w), height_(h){
}
void draw(int x, int y){
hal_draw(x,y);
}
void print(int x, int y, char* str){
}
};
#endif //MGL_DMXMENU_SCREEN_H

View file

@ -11,9 +11,9 @@
void debug(const char* str);
void setup();
void draw(int x, int y);
void print(int x, int y, const char* str);
void hal_init();
void hal_draw(int x, int y);
void hal_print(int x, int y, const char* str);
void render(Layout&);
void quit();