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

Author Topic: Shape with a hole  (Read 3420 times)

0 Members and 1 Guest are viewing this topic.

TobiasW

  • Newbie
  • *
  • Posts: 10
    • View Profile
Shape with a hole
« on: April 11, 2010, 05:43:16 am »
Hello everyone,

I want to draw a circle with a circle-shaped hole - and I want to fill only the grey marked area:



Any idea how I could do this?

Thanks in advance,
Tobias

Sivak

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Shape with a hole
« Reply #1 on: April 11, 2010, 05:52:46 am »
You might be able to draw a circle shape that has 0 alpha and an outline.

Try:  SHP_Whatever = sf::Shape::Circle(MidPointX, MidPointY, Radius, sf::Color(0,0,0,0), 1.f, sf::Color(0,0,255));

Where the last color is your desired colors.  I just picked blue to demo.

TobiasW

  • Newbie
  • *
  • Posts: 10
    • View Profile
Shape with a hole
« Reply #2 on: April 11, 2010, 06:00:32 am »
Thanks for the fast answer!

Hmm... but when I fill the outer circle with a color, won't the inner circle be filled too? Drawing just the outlines is no problem as you can see in the screenshot.


edit: I just realised that what I want to draw is a circle with a bigger outline. Maybe that's what you meant, too?

But just out of curiousity: Would it be possible to draw (or better "to not draw") shapes with holes? For example, a rectangle with a circle-shaped hole?

Spodi

  • Full Member
  • ***
  • Posts: 150
    • View Profile
    • http://www.netgore.com/
Shape with a hole
« Reply #3 on: April 11, 2010, 06:08:59 am »
Since it looks like this is for a tower-defense game, I assume you won't have many different sizes. In which case, just create an image by drawing the whole circle, than drawing over the inner area with another circle the same color as the background. Save that to a new image, then simply draw it like you would any other sprite.

 

anything