Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Why doesn't Transformable contain size?  (Read 3370 times)

0 Members and 1 Guest are viewing this topic.

Vassal

  • Newbie
  • *
  • Posts: 1
    • View Profile
Why doesn't Transformable contain size?
« on: June 30, 2021, 11:54:20 am »
I'm trying to create a simple layout helper class, which would be static, so that for example I would be able to call something like Layout.Align() and pass to it the element(s) I want to be aligned relatively to some bounds. According to the documentation, sprites, shapes and text are inherited from Transformable. This is awesome, I thought, because I don't have to implement separate methods for sprites and shapes for example. I can just upcast them to Transformable and pass these instead. But the problem is that Transformable doesn't contain the size of the element. Of course I can pass the size of the elements along with the elements themselves using GetGlobalBounds method. But I'm just curious why Transformable doesn't contain size, or why sprites, text, etc. don't implement some interface, like Bounded idk, because all of them have GetGlobalBounds method. Oh, and by the way I use SFML.NET 2.5.0 in case it is important.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Why doesn't Transformable contain size?
« Reply #1 on: June 30, 2021, 03:32:10 pm »
A transformable/transform is essentially just a 4x4 transformation matrix (math term) which encodes the movement, scaling and rotation but knows nothing about the original state.

Basically: original state * transformable = new state
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/