SDLPP: add option to specify render object alignment

This commit is contained in:
2021-04-27 15:54:30 +02:00
parent fc1d06a2b8
commit e5d0610f6d
11 changed files with 66 additions and 83 deletions
-24
View File
@@ -124,11 +124,6 @@ SDL_Rect CircleRender::getRect() {
return rect;
}
void CircleRender::centerX() {
centerx = true;
updateSizeAndPosition();
}
std::shared_ptr< RenderObject > CircleRender::copySelf() {
auto ret = std::make_shared< CircleRender >( *this );
copyTo( ret );
@@ -142,23 +137,4 @@ void CircleRender::copyTo( std::shared_ptr< RenderObject > other ) {
std::string CircleRender::getColor() const {
return color;
}
void CircleRender::updateXY() {
if ( !centerx ) {
current = original;
return;
}
auto width = renderer->getWidth();
auto height = renderer->getHeight();
double x_, y_;
if ( width > height ) {
auto multiplier =
static_cast< double >( width ) / static_cast< double >( height );
x_ = original.getX() + static_cast< double >( multiplier - 1 ) / 2;
} else {
x_ = original.getX();
}
y_ = original.getY();
current = { x_, y_ };
}
} // namespace SDLPP