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

Author Topic: Drawing a circle with part of it missing?  (Read 4243 times)

0 Members and 1 Guest are viewing this topic.

Sivak

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Drawing a circle with part of it missing?
« on: April 25, 2010, 06:19:51 am »
Basically, would a circle like the below image be possible to draw out of an SF shape?



What I want to do is have a sort of "clock" animation where the circle becomes more and more white as it winds down.

Possible?  Thanks.[/img]

Ashenwraith

  • Sr. Member
  • ****
  • Posts: 270
    • View Profile
Drawing a circle with part of it missing?
« Reply #1 on: April 25, 2010, 06:33:13 am »
You can do this with compositing shapes or images. Or even just a series of images if you want it to be easy.

If you want it to be transparent you can use alpha blendmode.

You basically put a triangle on top of a circle and widden the base of the triangle. You want the triangle to be longer than the radius of the circle so the circle does not clip the base.

Or you can draw multiple triangles and the size/position depends on time and the last triangle.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Drawing a circle with part of it missing?
« Reply #2 on: April 25, 2010, 10:56:51 am »
This is not directly possible with sf::Shape, because sf::Shape can handle only convex shapes. However, you can split the pie into two convex pieces and manually form sf::Shapes by using AddPoint().
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Drawing a circle with part of it missing?
« Reply #3 on: April 25, 2010, 12:50:55 pm »
Quote
This is not directly possible with sf::Shape, because sf::Shape can handle only convex shapes

Well, this is not  exactly true actually ;)
SFML decomposes the shape into triangles made of an edge and the center point. So it can handle non-convex shapes as long as none of these triangles overlap.

Creating such a shape should be possible with sf::Shape, if you add the center as a point of the shape.
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Drawing a circle with part of it missing?
« Reply #4 on: April 25, 2010, 01:23:51 pm »
Ah, I didn't know that. I have always underestimated sf::Shape... :D
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Drawing a circle with part of it missing?
« Reply #5 on: April 25, 2010, 04:16:15 pm »
Quote
Ah, I didn't know that. I have always underestimated sf::Shape... :D

Me too, until I recently realized that the implementation allowed more than convex shapes :D
Laurent Gomila - SFML developer