View Single Post
  #1 (permalink)  
Old 09-12-2008, 12:42 PM
GenkiSudo GenkiSudo is offline
Member
 
Join Date: Sep 2008
Posts: 6
GenkiSudo is on a distinguished road
Beginner Java graphics - filling concentric circles with color
Hello everyone.

I have to do an exercise in which I'm supposed to draw olympic circles and color them in olympic color.
I don't have a problem with drawing them (I drew them as concentric circles).
My problem is coloring them.

I have 3 classes:

1.OlympicRing - it draws the outer and the inner circle

2.OlympicComponent - extends JComponent, creates 5 OlympicRing objects with different positions and colors

3.OlympicRingViewer (main method that creates a frame and adds the olympic component to it)

Now, I tried filling the outer ring with olympic color and inner ring with frame background color (code is from OlympicRing class):
Code:
g2.draw(outerRing); g2.setColor(ringColor); g2.fill(outerRing); g2.draw(innerRing); g2.setColor(g2.getBackground()); g2.fill(innerRing);
This works with one ring. But if there's more of them and they intersect, their intersection areas get covered with background color.

Is there a way to give boundaries to the fill method ? Am I making any sense?
Any suggestions?
Reply With Quote
Sponsored Links