SFML community forums
Help => Graphics => Topic started by: Tigre Pablito on August 20, 2017, 01:30:33 am
-
Hi Ladies and Guys
Could you tell me how to slant a Sprite? I suppose it should be something related to the Transform class, but I googled and there's no info. I don't even know if it's possible. If it is, could you give me an example?
Thanks
-
sf::Transformables don't allow for slant/skew transformations.
Two options here:
1) use a vertex array and place the corners where you want them. However, be careful to make sure that the quad is not distorted. Which brings me to...
2) use Selba Ward (https://github.com/Hapaxia/SelbaWard/wiki)'s Elastic Sprite 8)
(http://i.imgur.com/zodshBH.png)
(http://i.imgur.com/gcg39PI.png)
(Selba Ward forum thread (https://en.sfml-dev.org/forums/index.php?topic=19496.0))
-
Hi Hapax
The problem is that I have a sprite that contains a Texture (graphic) that I need to slant, so a VertexArray won't solve it.
Selba Ward, I didn't finish to see the demo, and already realise that it's wonderful. Actually I regret that there is not a translation to C#. (Wouldn't you do it? ;D)
But it occurred to me to move the pixel lines to get the effect.
Thank you very much, anyway. (and hope to see the binding :)))
-
You can use an sf::VertexArray instead of the sf::Sprite...
That Selba Ward demo video is already a little bit old; there are numerous additions/improvements since then 8)
I have very little experience with C# so I couldn't port/bind Selba Ward to/for it. If anyone else is interested in doing that, let me know ;)
If the task you want to achieve is image manipulation - directly affect the image pixels - then you will need to do that manually; this is not something SFML does. However, you can use a render texture to draw the skewed object and then create an image from the render texture...