micromenu/inc/gfx/canvas.h
2018-11-01 19:39:19 +01:00

48 lines
1 KiB
C++

//
// 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