Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Need help overlapping circles - Olympic Logo -

Posted on 2004-10-26
10
Medium Priority
?
1,809 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
Comment
Question by:Coconut77840
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
10 Comments
 

Author Comment

by:Coconut77840
ID: 12416125
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:
objects earned 500 total points
ID: 12416548
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
ID: 12416597
It's outputting a white page.

g.setStroke(new BasicStroke(5.0))   <-- isn't supposed to be g2d.setStroke ?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:Coconut77840
ID: 12416611
Got it to work.

Thank you
0
 
LVL 92

Expert Comment

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

oops, yes :)
0
 

Author Comment

by:Coconut77840
ID: 12416730
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
ID: 12416748
your filling the middle with white which is overwriting anything under the fill.
0
 

Author Comment

by:Coconut77840
ID: 12416770
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
ID: 12416816
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
ID: 12418101
I am re-doing this problem using only drawArc function. Hopefully it will clean up the mess in that logo.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

596 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