Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: How to draw a circle with different colours. PLEASE HELP

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to draw a circle with different colours. PLEASE HELP

    Hello

    I need help with this exercise. I hope someone can help me.

    I need to create a program that draws circles in the middle of a DrawingPanel and draw them in different colors from red to blue via green. The program will ask the user how many circles to be drawn out and then plot them. Part of the program should be a method drawColoredCircles that draws circles, another part asks the user how many people will be drawn out. The circles should be drawn up from the inside out, they should be completely symmetrical circles and not ovals, and they should be drawn up for each other delays. Each circle should be larger than the previous one and the circles color codes will vary so that the transitions between the three primary colors are as soft as possible.
    Use it properly documented version of DrawingPanel.java for this task.

    I allready have this code but I don't know how to continue from it.

    public static void main(String[] args) {
    DrawingPanel panel = new DrawingPanel(500, 400);
    Graphics2D g = panel.getGraphics();
    int distance = 10;
    int max = 16;
    for (int i = 0; i < max; i++) {
    g.setColor(new Color(255 - i, 0, i));
    g.setStroke(new BasicStroke(2));
    int width = 10 + i * distance;
    g.drawOval(0, 0, width, width);
    }
    }

    These are the steps i need to do after:
    Step 2 I need to extend the code so it just don't make circles that goes from red to blue but it goes also from red to blue via green. "Use a for loop and an if statement in the loop to determine if one is to mix red and green or green and blue."

    Step 3 I need a delay between each circle so that i can see when they are drawn up. And the program should also ask the user how many circles to be plotted

    This is how it is supposed to look like after all is done.



    thanks in advance.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,334
    Thanks
    181
    Thanked 830 Times in 773 Posts
    Blog Entries
    5

    Default Re: How to draw a circle with different colours. PLEASE HELP

    This thread has been cross posted here:

    http://www.java-forums.org/new-java/53467-how-draw-circle-different-colours-please-help.html

    Although cross posting is allowed, for everyone's benefit, please read:

    Java Programming Forums Cross Posting Rules

    The Problems With Cross Posting


Similar Threads

  1. trying to draw a circle at the location of every mouse click
    By jopeters in forum AWT / Java Swing
    Replies: 0
    Last Post: October 18th, 2011, 05:24 PM
  2. java (circle)
    By coder.freak in forum Member Introductions
    Replies: 3
    Last Post: March 26th, 2011, 12:01 PM
  3. Replies: 4
    Last Post: March 2nd, 2011, 10:30 AM
  4. Change the random draw line here for a mouseListener draw
    By Panda23 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 10th, 2011, 02:29 AM
  5. Implement dragging a circle
    By jolly in forum AWT / Java Swing
    Replies: 0
    Last Post: August 19th, 2009, 02:48 PM