Link to home
Start Free TrialLog in
Avatar of Coconut77840
Coconut77840

asked on

Need help overlapping circles - Olympic Logo -

I am asked to draw the Olympic logo, I 've drawn the the 5 circles, and cannot get the drawArc function to work- to interlock the 5 circles.

This is what I have gotten so far:

<code>

import java.applet.Applet;
import java.awt.*;

public class Hw5Pr1 extends Applet {
  public void paint(Graphics g) {
        // Blue Ring
    g.setColor(new Color(5, 120, 182));
    g.drawOval(0, 0, 100, 100);
    g.fillOval(0,0, 100, 100);
   
   // Rectangle rect = new Rectangle( 30, 30, 100, 100);
   // Color pn = new Color(5, 120, 182);
   // g.drawArc(pn, rect, 50, 100);
   
    g.setColor(new Color(255, 255, 255));
    g.drawOval(5, 5, 90, 90);
    g.fillOval(5, 5, 90, 90);
    // Black Ring
    g.setColor(new Color(0, 0, 0));
    g.drawOval(110, 0, 100, 100);
    g.fillOval(110, 0, 100, 100);
    g.setColor(new Color(255, 255, 255));
    g.drawOval(115, 5, 90, 90);
    g.fillOval(115, 5, 90, 90);    
    // Red Ring
    g.setColor(new Color(251, 24, 51));
    g.drawOval(220, 0, 100, 100);
    g.fillOval(220, 0, 100, 100);
    g.setColor(new Color(255, 255, 255));
    g.drawOval(225, 5, 90, 90);
    g.fillOval(225, 5, 90, 90);      
    // Yellow Ring
    g.setColor(new Color(255, 173, 26));
    g.drawOval(50, 50, 100, 100);
    g.fillOval(50, 50, 100, 100);
    g.setColor(new Color(255, 255, 255));
    g.drawOval(55, 55, 90, 90);
    g.fillOval(55, 55, 90, 90);      
    // Green Ring
    g.setColor(new Color(12, 137, 73));
    g.drawOval(160, 50, 100, 100);
    g.fillOval(160, 50, 100, 100);
    g.setColor(new Color(255, 255, 255));
    g.drawOval(165, 55, 90, 90);
    g.fillOval(165, 55, 90, 90);  
  }
}

</code>

Could someone please help me draw one arc and I 'll hopefully do the rest.

Thanks
Avatar of Coconut77840
Coconut77840

ASKER

I've been able to figure out how to draw the arc

<code>
    g.setColor(new Color(0, 0, 0));
    g.drawArc(110, 5, 95, 95, 185, 70);
</code>

Now, I need to know how to increase the number of pixels of that Arc, It can be done by drawing 10 arcs, but I guess this is not efficient as it would me quite a while.

Please advice
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It's outputting a white page.

g.setStroke(new BasicStroke(5.0))   <-- isn't supposed to be g2d.setStroke ?
Got it to work.

Thank you
> g.setStroke(new BasicStroke(5.0))   <-- isn't supposed to be g2d.setStroke ?

oops, yes :)
It looks very odd.
I took a snapshop of my desktop so you can get the feeling.

http://lobnan.net/Olympic.gif

Any suggestions?
your filling the middle with white which is overwriting anything under the fill.
That's how I am asked to do it.

<quote>
Each ring can be drawn by filling a circle in color and then drawing a smaller white circle over it.
</quote>

Thanks
hmm, can't think how you avoid that affect using that approach.
I would have thought you'd just use drawArc()

maybe ask your lecturer for a clarification.
I am re-doing this problem using only drawArc function. Hopefully it will clean up the mess in that logo.