SFML community forums

General => Feature requests => Topic started by: Mr. X on October 18, 2008, 07:04:31 pm

Title: Drawing an Ellipse
Post by: Mr. X on October 18, 2008, 07:04:31 pm
Hello,
Is it possible to Add a method to the sf::Shape class for drawing an ellipse, or change the circle function, so that it could draw ellipses?
Title: Drawing an Ellipse
Post by: bullno1 on October 19, 2008, 07:27:21 am
Isn't an ellipse just a scaled circle?
Title: Drawing an Ellipse
Post by: Mr. X on October 19, 2008, 10:47:09 am
Yes,
but if I try to scale it, it is just moved by that factor...
Title: Drawing an Ellipse
Post by: gsaurus on October 25, 2008, 07:02:31 pm
Quote from: "Mr. X"
Yes,
but if I try to scale it, it is just moved by that factor...

Use setCenter to center in the circle center before scale
Title: Drawing an Ellipse
Post by: Mr. X on October 26, 2008, 09:54:03 am
Hello,
it doesn't work. Also when I center the circle before scaling, it is only moved by this factor.
Title: Drawing an Ellipse
Post by: Noegddgeon on December 21, 2010, 09:51:45 am
When setting the center of the circle, it's relative to the top left coordinates of the circle, not the whole window. I was trying to figure this out and made the mistake of assuming otherwise, but I was able to figure out, in case anyone else looks at this thread in the future and wonders the same thing.

Code: [Select]

sf::Shape myEllipse = sf::Shape::Circle(200, 200, 60, sf::Color(255, 0, 0));
myEllipse.SetCenter(30, 30);
myEllipse.SetScale(2, 1);


Instead of writing the SetCenter function like...
Code: [Select]

myEllipse.SetCenter(230, 230);


Solves the problem for me when scaling the circle.