Merge pull request #434 from Koerty/ninepatch-origin

NinePatch now position correctly when origin is different from 0 0
This commit is contained in:
John Rassa 2018-05-17 16:03:18 -07:00 committed by GitHub
commit ffe591e239
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View file

@ -144,7 +144,6 @@ void GridTileComponent::resize()
mImage->setMaxSize(currentProperties.mSize - currentProperties.mPadding); mImage->setMaxSize(currentProperties.mSize - currentProperties.mPadding);
mBackground.fitTo(currentProperties.mSize - Vector2f(32.0f, 32.0f)); // (32f, 32f) the NinePatchComponent natural padding mBackground.fitTo(currentProperties.mSize - Vector2f(32.0f, 32.0f)); // (32f, 32f) the NinePatchComponent natural padding
mBackground.setPosition(getSize().x() / 2, getSize().y() / 2);
} }
const GridTileProperties& GridTileComponent::getCurrentProperties() const const GridTileProperties& GridTileComponent::getCurrentProperties() const

View file

@ -160,7 +160,8 @@ void NinePatchComponent::fitTo(Vector2f size, Vector3f position, Vector2f paddin
position[1] -= padding.y() / 2; position[1] -= padding.y() / 2;
setSize(size + mCornerSize * 2); setSize(size + mCornerSize * 2);
setPosition(-mCornerSize.x() + position.x(), -mCornerSize.y() + position.y()); setPosition(position.x() + Math::lerp(-mCornerSize.x(), mCornerSize.x(), mOrigin.x()),
position.y() + Math::lerp(-mCornerSize.y(), mCornerSize.y(), mOrigin.y()));
} }
void NinePatchComponent::setImagePath(const std::string& path) void NinePatchComponent::setImagePath(const std::string& path)