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

Author Topic: Rotate a Image around its center/Axis  (Read 2995 times)

0 Members and 1 Guest are viewing this topic.

Ahmed5036

  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Email
Rotate a Image around its center/Axis
« on: December 28, 2020, 10:34:17 am »
Hi there, I'm new to SFML and a student and using SFML 2.4.2 version
I've selected a project on Music Player. I've completed it using Linked list but my teacher asked me to do some animation and I've searched and couldn't find any help.
I wanted to the following Disc image to rotate around its center.
« Last Edit: December 28, 2020, 10:38:13 am by Ahmed5036 »

Stauricus

  • Sr. Member
  • ****
  • Posts: 369
    • View Profile
    • A Mafia Graphic Novel
    • Email
Visit my game site (and hopefully help funding it? )
Website | IndieDB

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Rotate a Image around its center/Axis
« Reply #2 on: December 28, 2020, 07:29:08 pm »
Just as a general rule to remember, transformables always rotate around its origin.

So, yes, as said above, if you want to rotate around its centre, its origin must be at its centre.

Indeed, all transformations are based around the origin: scale will scale outwards from its origin and setting its position technically sets where its origin will be (this means that you will likely need to reposition it after changing its origin - set its new position to where you want its centre to be, for example).
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

calibru99

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Rotate a Image around its center/Axis
« Reply #3 on: January 05, 2021, 12:14:55 am »
Dunno if this helps but when I first had this problem my main issue was that i was drawing the certain piece and setting its position/origin inside a loop. this resulted in the fact that with every loop iteration the origin/position of it would shift, as i was setting the origin everytime.
long story short: set the origin in another part other than where you loop thru and draw the shape, this way the rotation will work 100%