+ fillValue in Font
This commit is contained in:
parent
7da7d96b17
commit
d95f142d0f
|
@ -16,18 +16,15 @@ int main() {
|
||||||
|
|
||||||
std::string str;
|
std::string str;
|
||||||
std::cout << "string to draw: ";
|
std::cout << "string to draw: ";
|
||||||
std::cin >> str;
|
std::getline(std::cin, str);
|
||||||
|
|
||||||
for (int i = 0; i < font.height(); i++) {
|
for (int i = 0; i < font.height(); i++) {
|
||||||
for (char c : str) {
|
for (char c : str) {
|
||||||
for (int j = 0; j < font.width(); j++) {
|
for (int j = 0; j < font.width(); j++) {
|
||||||
|
if (font.getPixel(c,j,i)) {
|
||||||
unsigned int pixel = font.getPixel(c,j,i);
|
std::cout << "█";
|
||||||
|
|
||||||
if (pixel == 0) {
|
|
||||||
std::cout << " ";
|
|
||||||
} else {
|
} else {
|
||||||
std::cout << "1";
|
std::cout << " ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::cout << " ";
|
std::cout << " ";
|
||||||
|
|
|
@ -13,6 +13,7 @@ Font::Font() {
|
||||||
yCount = 4;
|
yCount = 4;
|
||||||
xStart = 1;
|
xStart = 1;
|
||||||
yStart = 2;
|
yStart = 2;
|
||||||
|
fillValue = 0xffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
Font::Font(const std::string &file) : Font() {
|
Font::Font(const std::string &file) : Font() {
|
||||||
|
@ -31,7 +32,7 @@ int Font::height() {
|
||||||
return ySize;
|
return ySize;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int Font::getPixel(char character, int x, int y) {
|
bool Font::getPixel(char character, int x, int y) {
|
||||||
//index of character(x and y)
|
//index of character(x and y)
|
||||||
int index = (character - ' ');
|
int index = (character - ' ');
|
||||||
int xIndex = index % xCount;
|
int xIndex = index % xCount;
|
||||||
|
@ -41,6 +42,6 @@ unsigned int Font::getPixel(char character, int x, int y) {
|
||||||
int xPos = xIndex * (xSize + xOffset) + xStart;
|
int xPos = xIndex * (xSize + xOffset) + xStart;
|
||||||
int yPos = yIndex * (ySize + yOffset) + yStart;
|
int yPos = yIndex * (ySize + yOffset) + yStart;
|
||||||
|
|
||||||
return bitmap.getPixel(xPos + x, yPos + y);
|
return bitmap.getPixel(xPos + x, yPos + y) == fillValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,13 +28,15 @@ public:
|
||||||
int xStart;
|
int xStart;
|
||||||
int yStart;
|
int yStart;
|
||||||
|
|
||||||
|
unsigned int fillValue;
|
||||||
|
|
||||||
Font();
|
Font();
|
||||||
explicit Font(const std::string &file);
|
explicit Font(const std::string &file);
|
||||||
void load(const std::string &file);
|
void load(const std::string &file);
|
||||||
|
|
||||||
int width();
|
int width();
|
||||||
int height();
|
int height();
|
||||||
unsigned int getPixel(char character, int x, int y);
|
bool getPixel(char character, int x, int y);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue