Solved

Need help overlapping circles - Olympic Logo -

Posted on 2004-10-26
1,703 Views
Last Modified: 2012-06-27
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
0
Question by:Coconut77840
    10 Comments
     

    Author Comment

    by:Coconut77840
    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
    0
     
    LVL 92

    Accepted Solution

    by:
    You'll need to use Swing to achieve that (without drawing 5 arcs).

    Graphics2D g2d = (Graphics2D) g;
    g.setStroke(new BasicStroke(5.0));
    0
     

    Author Comment

    by:Coconut77840
    It's outputting a white page.

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

    Author Comment

    by:Coconut77840
    Got it to work.

    Thank you
    0
     
    LVL 92

    Expert Comment

    by:objects
    > g.setStroke(new BasicStroke(5.0))   <-- isn't supposed to be g2d.setStroke ?

    oops, yes :)
    0
     

    Author Comment

    by:Coconut77840
    It looks very odd.
    I took a snapshop of my desktop so you can get the feeling.

    http://lobnan.net/Olympic.gif

    Any suggestions?
    0
     
    LVL 92

    Expert Comment

    by:objects
    your filling the middle with white which is overwriting anything under the fill.
    0
     

    Author Comment

    by:Coconut77840
    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
    0
     
    LVL 92

    Expert Comment

    by:objects
    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.
    0
     

    Author Comment

    by:Coconut77840
    I am re-doing this problem using only drawArc function. Hopefully it will clean up the mess in that logo.
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Prepare to Pass the CompTIA A+ 900 Series Exam

    CompTIA aims to adapt its A+ Certification to reflect the most current knowledge and skills needed by today's IT professionals--and this year's 2016 exam is harder than ever. This certification is one of the most highly-respected and sought after in IT.

    Suggested Solutions

    Title # Comments Views Activity
    Automated mobile software testing 8 75
    factorial example challenge 10 31
    array6 challenfge 6 30
    stringclean challenge 26 16
    For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
    Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
    Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
    Video by: Michael
    Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

    910 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now