adding transformations

This commit is contained in:
Kbz-8
2024-11-13 12:17:59 +01:00
parent 71d1c20a27
commit 35b7408eab
18 changed files with 141 additions and 130 deletions

View File

@@ -54,15 +54,16 @@ namespace mlx
Text& new_text = p_scene->CreateText(str);
new_text.SetPosition(Vec2f{ static_cast<float>(x), static_cast<float>(y) });
new_text.SetColor(std::move(vec_color));
new_text.SetCenter(Vec2f{ 0.0f, 0.0f });
}
else if(!p_scene->IsTextAtGivenDrawLayer(str, m_draw_layer))
p_scene->BringToDrawLayer(text.Get(), m_draw_layer);
}
void GraphicsSupport::TexturePut(NonOwningPtr<Texture> texture, int x, int y)
void GraphicsSupport::TexturePut(NonOwningPtr<Texture> texture, int x, int y, float scale, float angle)
{
MLX_PROFILE_FUNCTION();
NonOwningPtr<Sprite> sprite = p_scene->GetSpriteFromTextureAndPosition(texture, Vec2f{ static_cast<float>(x), static_cast<float>(y) });
NonOwningPtr<Sprite> sprite = p_scene->GetSpriteFromTexturePositionScaleRotation(texture, Vec2f{ static_cast<float>(x), static_cast<float>(y) }, scale, angle);
if(!sprite)
{
if(m_pixelput_called)
@@ -72,7 +73,9 @@ namespace mlx
}
Sprite& new_sprite = p_scene->CreateSprite(texture);
new_sprite.SetPosition(Vec2f{ static_cast<float>(x), static_cast<float>(y) });
new_sprite.SetScale(Vec2f{ scale, scale });
new_sprite.SetRotation(angle);
new_sprite.SetCenter(Vec2f{ texture->GetWidth() / 2.0f, texture->GetHeight() / 2.0f });
}
else if(!p_scene->IsTextureAtGivenDrawLayer(texture, m_draw_layer))
p_scene->BringToDrawLayer(sprite.Get(), m_draw_layer);