@ -13,6 +13,7 @@ namespace massivedynamic {
class PixelRenderer : public Renderer {
protected :
size_t pixelSize ;
size_t border ;
std : : vector < Color > bitmap ;
void drawPixelScaled ( size_t x , size_t y , Color color ) {
@ -23,8 +24,8 @@ namespace massivedynamic {
exit ( 1 ) ;
}
size_t absoluteX = pixelSize * x + pixelSize ;
size_t absoluteY = pixelSize * y + pixelSize ;
size_t absoluteX = pixelSize * x + this - > border ;
size_t absoluteY = pixelSize * y + this - > border ;
for ( size_t localY = absoluteY ; localY < absoluteY + pixelSize ; localY + + ) {
for ( size_t localX = absoluteX ; localX < absoluteX + pixelSize ; localX + + ) {
@ -40,10 +41,8 @@ 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 ;
// here we make shure, `targetSize` will be a multiple of `sourceSize`
this - > pixelSize = round ( static_cast < float > ( this - > targetSize ) / static_cast < float > ( this - > sourceSize + 2 ) ) ;
this - > targetSize = ( this - > sourceSize + 2 ) * this - > pixelSize ;
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 - > bitmap = std : : vector < Color > ( this - > targetSize * this - > targetSize , Colors : : WHITE ) ;
}