2019-11-19 13:27:18 +01:00
|
|
|
//
|
|
|
|
// Created by my on 2019/11/16.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef TEXTRENDERER_TEXTRENDERER_H
|
|
|
|
#define TEXTRENDERER_TEXTRENDERER_H
|
|
|
|
|
|
|
|
#define BOLD 0b001
|
|
|
|
#define ITALICS 0b010
|
|
|
|
#define UNDERLINE 0b100
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <Color.hpp>
|
|
|
|
#include <vkvm.hpp>
|
|
|
|
#include <iostream>
|
|
|
|
#include "Font.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author: Yajie Qi, Shaohua Tong
|
|
|
|
* @since: v0.0.0
|
|
|
|
* @brief: gets a string from the Shared Memory and converts the text into a bitmap-array.
|
|
|
|
*/
|
|
|
|
class TextRenderer {
|
|
|
|
public:
|
2019-11-20 15:51:01 +01:00
|
|
|
TextRenderer(int windowWidth, int windowHeight, vkvm::Color defaultBackgroundColor, vkvm::Color fontColor, Font font);
|
2019-11-19 13:27:18 +01:00
|
|
|
|
|
|
|
void update(std::string text);
|
|
|
|
void setOldText(std::string text);
|
2019-11-20 15:51:01 +01:00
|
|
|
std::vector<std::vector<bool>> getCharacter(unsigned char character, Font font);
|
|
|
|
void setLeftMargin(int margin);
|
|
|
|
void setBottomMargin(int margin);
|
|
|
|
void clear();
|
2019-11-19 13:27:18 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::string oldText;
|
|
|
|
vkvm::Color backgroundColor;
|
|
|
|
vkvm::Color fontColor;
|
2019-11-20 12:50:32 +01:00
|
|
|
Font font;
|
2019-11-20 15:51:01 +01:00
|
|
|
int left_margin = 1;
|
|
|
|
int bottom_margin = 1;
|
2019-11-19 13:27:18 +01:00
|
|
|
int type;
|
|
|
|
int windowWidth;
|
2019-11-20 15:51:01 +01:00
|
|
|
int windowHeight;
|
2019-11-19 13:27:18 +01:00
|
|
|
int fontWidth;
|
|
|
|
int fontHeight;
|
|
|
|
bool isBold();
|
|
|
|
bool isItalics();
|
|
|
|
bool isUnderline();
|
2019-11-20 15:51:01 +01:00
|
|
|
void fontProcessing(std::vector<std::vector<bool>> characterBitmap);
|
|
|
|
void translateToSharedMemory(std::vector<std::vector<bool>> characterBitmap, int startX, int startY);
|
2019-11-19 13:27:18 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif //TEXTRENDERER_TEXTRENDERER_H
|