# Alternative way to create a circle propagation?

• 05-26-2011, 12:43 AM
Kratos321
Alternative way to create a circle propagation?
I've written the following code for the propagation of a circle. Is there an alternative or more efficient way to do this other than increasing the length by 2 for ever 1 decrease of the x and y values of the top left corner?

btw c.maxx and c.maxy calculates the maximum pixels for the width and length of output screen on my ide.

Im using HSA console on "Ready to Program with Java IDE".

thanks for any suggestions.

Code:

```// The "CircleProjection" class. import java.awt.*; import hsa.Console; public class CircleProjection {     static Console c;          // The output console     public static void main (String[] args)     {         c = new Console ();         int r = 0;         int i = 0, a, b;         a = (c.maxx ()) / 2;         b = (c.maxy ()) / 2;         while (i == 0)         {             c.setColor (new Color (0, 0, 255));             c.drawOval (a, b, r, r);             try             {                 Thread.currentThread ().sleep (1);             } //end of try             catch (Exception e)             {             } //end of catch             c.setColor (new Color (255, 255, 255));             c.drawOval (a, b, r, r);             a--;             b--;             r = r + 2;             if (b == 0)             {                 a = (c.maxx ()) / 2;                 b = (c.maxy ()) / 2;                 r = 0;             }         } //end of while loop     } // main method } // CircleProjection class```
• 05-26-2011, 01:55 AM
Norm
Quote:

increasing the length by 2 for ever 1 decrease of the x and y values
Have you taken a piece of paper and drawn a grid and drawn the circles? What do you have to do to keep the circles centered on the same point?
• 05-26-2011, 03:28 AM
Kratos321
I'm not entirely sure.....well i know i have to make the radius originate from the center and constant throughout. Other than that...?
• 05-26-2011, 03:33 AM
Norm
Quote:

I'm not entirely sure.
Have you taken a piece of paper and drawn a grid and drawn the circles?
• 05-26-2011, 03:51 AM
Kratos321
yes i just did, and i still can't figure out another method. any hints on what i should be looking for?
• 05-26-2011, 04:04 AM
Norm
I don't know if there is another method.

Wait till JosAH takes a look.
• 05-26-2011, 04:12 AM
Kratos321
yeah ok sure. who is that btw?
• 05-26-2011, 04:19 AM
Norm
Scan thru some of the forums and you should see where he has answered some questions.
• 05-26-2011, 05:23 AM
Kratos321
Is it likely for him to visit my post?