SFML/imgui-sfml

Add tinting and relative sprite window placement

Ober3550 opened this issue · 0 comments

Heyo. Great library and just wanted to contribute something I found useful. I was using sprites that were tinted and positioned according to some crafting window layout and came up with this. Also I want rotatable sprites but haven't yet sat down and figured out how to do it.
https://gyazo.com/2b7504390a91837b6323b29d36d8b69a
Thanks again for your great work!

void Image(const sf::Sprite& sprite) {
    sf::FloatRect bounds = sprite.getLocalBounds();
    sf::Vector2f scale = sprite.getScale();
    sf::Color tintColor = sprite.getColor();
    sf::Color borderColor = sf::Color::Transparent;
    ImGui::SetCursorPos(ImVec2(sprite.getPosition().x - sprite.getOrigin().x * sprite.getScale().x, sprite.getPosition().y - sprite.getOrigin().y * sprite.getScale().y));
    Image(sprite, sf::Vector2f(bounds.width * scale.x, bounds.height * scale.y), tintColor,
        borderColor);
}