SFML community forums
Help => Graphics => Topic started by: farnoy on August 17, 2011, 10:13:03 pm
-
Hi,
How to draw a http://en.wikipedia.org/wiki/Circular_sector using generic SFML shape? I haven't seen any Arc functions in Shape class and drawing lines also doesn't cover angles.
-
You can't technically render arcs or perfect circles, you split your arc / circle / sector up into as many triangles or straight lines as you require to get your desired level of detail.
For a perfect circle and circular sectors <= 180 degrees, a convex n-gon portion will work, but circular sectors with an angle between 180 and 360 degrees could only be represented by a concave polygon, which is why you'll probably have to go the multi-triangle way.
-
Thanks for your response.
What do you think about finding points by this equation: http://en.wikipedia.org/wiki/Circle#Cartesian_coordinates
x = a + r cos(t)
y = b + r sin(t)
Wouldn't this give me a good level of detail?
-
Thanks for your response.
What do you think about finding points by this equation: http://en.wikipedia.org/wiki/Circle#Cartesian_coordinates
x = a + r cos(t)
y = b + r sin(t)
Wouldn't this give me a good level of detail?
That's the exact equation you need to use.
-
By the way, in case you use Thor, there is a Shapes::Pie() (http://www.bromeon.ch/thor/v1.1/doc/namespacethor_1_1_shapes.html) function that creates circular sectors.
You can't use a single sf::Shape reliably, since the sector may be concave and sf::Shape only supports convex shapes. That's why the Pie() function returns thor::ConcaveShape instead.