<commit_before>#include "foundation/spritecomponent.hpp"

#include <SFML/Graphics/RectangleShape.hpp>
#include <SFML/Graphics/RenderTarget.hpp>
#include <SFML/Graphics/Texture.hpp>

#include "rendering/rendersystem.hpp"

namespace qrw
{

SpriteComponent::SpriteComponent(Layer layer)
	: Renderable(layer)
{
	_rectangle = new sf::RectangleShape();
}

SpriteComponent::~SpriteComponent()
{
	delete _rectangle;
}

void SpriteComponent::setTexture(const sf::Texture* texture)
{
	_rectangle->setTexture(texture);
}

void SpriteComponent::setRepeateTexture(bool repeate, float scale)
{
	const sf::Vector2f& size = repeate ? _rectangle->getSize() / scale : static_cast<sf::Vector2f>(_rectangle->getTexture()->getSize());
	_rectangle->setTextureRect(sf::IntRect(0, 0, size.x, size.y));
}

void SpriteComponent::setSize(const sf::Vector2f& size)
{
	_rectangle->setSize(size);
}

const sf::Vector2f &SpriteComponent::getSize()
{
	return _rectangle->getSize();
}

void SpriteComponent::setPosition(const sf::Vector2f& position)
{
	_rectangle->setPosition(position);
}

const sf::Vector2f& SpriteComponent::getPosition() const
{
	return _rectangle->getPosition();
}
<commit_msg>Scale texture to fit SpriteComponent size<commit_after>#include "foundation/spritecomponent.hpp"

#include <SFML/Graphics/RectangleShape.hpp>
#include <SFML/Graphics/RenderTarget.hpp>
#include <SFML/Graphics/Texture.hpp>

#include "rendering/rendersystem.hpp"

namespace qrw
{

SpriteComponent::SpriteComponent(Layer layer)
	: Renderable(layer)
{
	_rectangle = new sf::RectangleShape();
}

SpriteComponent::~SpriteComponent()
{
	delete _rectangle;
}

void SpriteComponent::setTexture(const sf::Texture* texture)
{
	_rectangle->setTexture(texture);
	_rectangle->setTextureRect(sf::IntRect(0, 0, texture->getSize().x, texture->getSize().y));
}

void SpriteComponent::setRepeateTexture(bool repeate, float scale)
{
	const sf::Vector2f& size = repeate ? _rectangle->getSize() / scale : static_cast<sf::Vector2f>(_rectangle->getTexture()->getSize());
	_rectangle->setTextureRect(sf::IntRect(0, 0, size.x, size.y));
}

void SpriteComponent::setSize(const sf::Vector2f& size)
{
	_rectangle->setSize(size);
}

const sf::Vector2f &SpriteComponent::getSize()
{
	return _rectangle->getSize();
}

void SpriteComponent::setPosition(const sf::Vector2f& position)
{
	_rectangle->setPosition(position);
}

const sf::Vector2f& SpriteComponent::getPosition() const
{
	return _rectangle->getPosition();
}

{'fraction_non_alphanumeric': 0.14926590538336051, 'fraction_numerical': 0.00734094616639478, 'mean_word_length': 7.760714285714286, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7640459', 'n_tokens_mistral': 834, 'n_tokens_neox': 844, 'n_words': 135}