|
|
|
@ -2,6 +2,7 @@ |
|
|
|
|
|
|
|
|
|
#include <math.h> |
|
|
|
|
#include <iostream> |
|
|
|
|
#include <cassert> |
|
|
|
|
|
|
|
|
|
#include "Renderer.hpp" |
|
|
|
|
#define STB_IMAGE_WRITE_IMPLEMENTATION |
|
|
|
@ -19,10 +20,7 @@ namespace massivedynamic { |
|
|
|
|
void drawPixelScaled(size_t x, size_t y, Color color) { |
|
|
|
|
size_t pixelSize = this->pixelSize; |
|
|
|
|
|
|
|
|
|
if (pixelSize < 1) { |
|
|
|
|
std::cerr << "ERROR: output file size is too small" << std::endl; |
|
|
|
|
exit(1); |
|
|
|
|
} |
|
|
|
|
assert(pixelSize > 1 && "ERROR: output file size is too small"); |
|
|
|
|
|
|
|
|
|
size_t absoluteX = pixelSize * x + this->border; |
|
|
|
|
size_t absoluteY = pixelSize * y + this->border; |
|
|
|
@ -42,12 +40,12 @@ namespace massivedynamic { |
|
|
|
|
PixelRenderer(const std::vector<bool>& pixels, size_t sourceSize, size_t targetSize) : Renderer(pixels, sourceSize, targetSize), pixelSize(0) { |
|
|
|
|
this->targetSize = this->targetSize == 0 ? (sourceSize + 2) * 2 : this->targetSize; |
|
|
|
|
this->pixelSize = round(static_cast<float>(this->targetSize) / static_cast<float>(this->sourceSize + 2)); |
|
|
|
|
this->border = round((this->targetSize - this->pixelSize * this->sourceSize) / 2); |
|
|
|
|
this->border = round(static_cast<float>(this->targetSize - this->pixelSize * this->sourceSize) / 2.0f); |
|
|
|
|
|
|
|
|
|
this->bitmap = std::vector<Color>(this->targetSize * this->targetSize, Colors::WHITE); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void generateBuffer() { |
|
|
|
|
virtual void generateBuffer() { |
|
|
|
|
for (size_t y = 0; y < sourceSize; y++) { |
|
|
|
|
for (size_t x = 0; x < sourceSize; x++) { |
|
|
|
|
if (!pixels.at(y * sourceSize + x)) |
|
|
|
|