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

Author Topic: scalePosition();  (Read 2939 times)

0 Members and 1 Guest are viewing this topic.

Doodlemeat

  • Guest
scalePosition();
« on: March 22, 2014, 12:04:41 pm »
Hello.

What if we could give sf::Transform a scalePosition() method. It could save a few more keytaps and I think it looks pretty neat?  It is not a big thing, but it really helps :)

mySprite->scalePosition(0.5, 1);
or
mySprite->scalePosition(sf::Vector(0.5, 1));

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: scalePosition();
« Reply #1 on: March 22, 2014, 12:14:36 pm »
And now to the explanation of what the function should actually do, would be kind of useful. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Doodlemeat

  • Guest
Re: scalePosition();
« Reply #2 on: March 22, 2014, 12:21:12 pm »
It would change the position of the transformable object.

sf::RectangleShape shape;
shape.setPosition(100, 100);

shape.scalePosition(0.5, 1);

// shape.position = 50, 100
 

I do not see any drawbacks of doing so, neither is it confusing I think. Altough, typing a few more characters can achieve this but hey, we are lazy
« Last Edit: March 22, 2014, 12:23:05 pm by Doodlemeat »

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: scalePosition();
« Reply #3 on: March 22, 2014, 12:30:22 pm »
I do not see any drawbacks of doing so
It clutters the API unnecessarily. Why not a scaleRotation() too?

I don't think that's an often needed functionality -- positions are mostly used as points (in absolute world coordinates) and not dimensions.

neither is it confusing I think.
It is obviously confusing because it includes both "scale" and "position" but only affects one of these properties. When even eXpl0it3r, a very experienced SFML user, asks what it can mean, what do you think that newcomers expect?

If that's really a function that you're missing, then write a global function for it. This functionality doesn't have to be part of the sf::Transformable class.
« Last Edit: March 22, 2014, 12:42:48 pm by Nexus »
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

therocode

  • Full Member
  • ***
  • Posts: 125
    • View Profile
    • Development blog
Re: scalePosition();
« Reply #4 on: March 23, 2014, 05:19:11 pm »

Doodlemeat

  • Guest
Re: scalePosition();
« Reply #5 on: March 25, 2014, 12:38:51 pm »
Yes, the human race are lazy ::)

But I totally agree with Nexus. But is there any easy way of extending any SFML class with some few methods that will be avaible anywhere where I type #include "SMFL/GFX/Sprite.hpp" ?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: scalePosition();
« Reply #6 on: March 25, 2014, 01:06:46 pm »
Quote
But is there any easy way of extending any SFML class with some few methods that will be avaible anywhere where I type #include "SMFL/GFX/Sprite.hpp" ?
No, you have to write your extensions in your own header, and include it instead of the SFML one.
Laurent Gomila - SFML developer