SFML community forums

Help => Graphics => Topic started by: blueeyedlion on October 06, 2011, 03:56:15 am

Title: Some clarification please
Post by: blueeyedlion on October 06, 2011, 03:56:15 am
What is the correct way to create a green square that is 15 * 15 pixels, and rotate it 180 degrees around its exact centre pixel?

I seem to be getting something wrong.
Title: Some clarification please
Post by: Laurent on October 06, 2011, 07:49:51 am
Can you show us your code first? ;)
Title: Some clarification please
Post by: blueeyedlion on October 08, 2011, 07:08:13 pm
Code: [Select]
sf::Shape rect = sf::Shape::Rectangle (1, 1, 15, 15, sf::Color::Green);
rect.SetCenter (7, 7);
rect.Rotate (180);
Title: Some clarification please
Post by: Laurent on October 08, 2011, 10:07:42 pm
This is exactly what you described. So what's wrong?
Title: Some clarification please
Post by: Mikebissle on October 08, 2011, 10:41:37 pm
The code you posted is fine--it's just that since the shape is an equiangular square, turning it 180 degrees is not going to change how it looks.

If you want it to progressively rotate to 180 degrees, that's a different story. The simplest way I can think of would be:

Code: [Select]

//Drawing loop
if (rect.GetRotation() < 180) {
  rect.Rotate(1.f);
}
Title: Some clarification please
Post by: blueeyedlion on October 10, 2011, 08:46:02 pm
The problem is that the square from my code ends up to be 14x14 pixels.
I counted the pixels with my digital microscope to be sure.
Title: Some clarification please
Post by: Laurent on October 10, 2011, 10:18:23 pm
In SFML 1.6, the 3rd and 4th arguments of sf::Shape::Rectangle are the coordinates of the bottom-right corner, not the width/height.
Title: Some clarification please
Post by: blueeyedlion on October 10, 2011, 10:29:46 pm
Is that to say it's different in another version of SFML?
Title: Some clarification please
Post by: Laurent on October 10, 2011, 10:33:44 pm
In SFML 2 these arguments are width and height.
Title: Some clarification please
Post by: blueeyedlion on October 10, 2011, 11:52:57 pm
That sounds much better, when is it going to be released?
Title: Some clarification please
Post by: OniLinkPlus on October 11, 2011, 12:53:56 am
Quote from: "blueeyedlion"
That sounds much better, when is it going to be released?
SFML2 is already "out," but you need to get the source from github and compile it yourself.
Title: Some clarification please
Post by: blueeyedlion on October 11, 2011, 05:47:03 am
where can I find a step by step guide for doing that?
Title: Some clarification please
Post by: Haikarainen on October 11, 2011, 06:10:14 am
Well, anyone noticed he set the rect starting from 1x1, wich subtracts 1x1 from the resulting size.
Title: Some clarification please
Post by: blueeyedlion on October 11, 2011, 04:51:15 pm
THANK YOU!