1
Feature requests / Re: export vertexes from the Shape class
« on: May 09, 2024, 01:40:07 am »
You can use a sf::Transform (or better - sf::Transformable).
I have my own helper class (called maker in the code) that lets me format Text with bold, italics, color and outline changing per character, and in the end I use an sf::Transform like so:
You should look into how ::draw() is implemented in SFML drawables, it's almost always just doing
I have my own helper class (called maker in the code) that lets me format Text with bold, italics, color and outline changing per character, and in the end I use an sf::Transform like so:
sf::RenderStates states;
states.texture = &font->getTexture(charsize);
sf::Transformable trans;
const auto bounds = maker.getBounds();
trans.setPosition(kTileSize * sf::Vector2f(pos));
const float scale = std::min(kTileSize / right(bounds), kTileSize / bottom(bounds));
trans.setScale(scale, scale);
states.transform = trans.getTransform();
RENDERER_HISTORY(m_target->draw(maker.getTextVeritces(), states));
states.texture = &font->getTexture(charsize);
sf::Transformable trans;
const auto bounds = maker.getBounds();
trans.setPosition(kTileSize * sf::Vector2f(pos));
const float scale = std::min(kTileSize / right(bounds), kTileSize / bottom(bounds));
trans.setScale(scale, scale);
states.transform = trans.getTransform();
RENDERER_HISTORY(m_target->draw(maker.getTextVeritces(), states));
You should look into how ::draw() is implemented in SFML drawables, it's almost always just doing
states.transform *= getTransform();
since they derive from transformable (that's where setPosition, setRotation, etc. all come from). Some also add texture (sf::Sprite, sf::Text, even sf::Shape actually).