SDLPP: add option to specify render object alignment
This commit is contained in:
@@ -158,10 +158,6 @@ void RectangleRender::updateSizeAndPosition() {
|
||||
SDL_Rect RectangleRender::getRect() {
|
||||
return rect;
|
||||
}
|
||||
void RectangleRender::centerX() {
|
||||
centerx = true;
|
||||
updateSizeAndPosition();
|
||||
}
|
||||
std::shared_ptr< RenderObject > RectangleRender::copySelf() {
|
||||
auto ret = std::make_shared< RectangleRender >( *this );
|
||||
copyTo( ret );
|
||||
@@ -173,23 +169,4 @@ void RectangleRender::copyTo( std::shared_ptr< RenderObject > other ) {
|
||||
std::string RectangleRender::getColor() const {
|
||||
return color;
|
||||
}
|
||||
|
||||
void RectangleRender::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
|
||||
|
||||
Reference in New Issue
Block a user