Win a copy of Python Continuous Integration and Delivery this week in the Python forum!
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
• Campbell Ritchie
• Liutauras Vilda
• Bear Bibeault
• Paul Clapham
• Jeanne Boyarsky
Sheriffs:
• Devaka Cooray
• Junilu Lacar
• Tim Cooke
Saloon Keepers:
• Tim Moores
• Ron McLeod
• Tim Holloway
• Claude Moore
• Stephan van Hulst
Bartenders:
• Winston Gutkowski
• Carey Brown
• Frits Walraven

# How to draw a circle using 2d arrays

Greenhorn
Posts: 6
Hello ,

I am trying to draw some objects using 2d arrays and animate them with AffineTransform class, I drawed the rectangle using 4 points and I had no problem but I dont know how to draw a circle using the same method, is it possible? because if I use points the circle wont be a curve. any ideas please.

here is the code

Moudy

Marshal
Posts: 63373
205
Try an SSCCE to draw the circle on its own. It is actually quite easy to draw a circle, using the drawEllipse or similarly-named method of the Graphics class. Imagine a square 99×99px, then you can draw a circle inside that with whatever method I sent the link to.

Moving to our Swing forum where we usually discuss such questions.

Moud Elma
Greenhorn
Posts: 6
Thank you for the idea, I was thinking about that but the problem how can I draw a circle with the method you said and animate it with AffineTransform, because I have to use the AffineTransform (given by the Prof.) to animae the oject, is it possible to use drawoval() witth AffineTransform considering that arrays are needed with it ?.

see the code :

p and pa are 2d arrays

Campbell Ritchie
Marshal
Posts: 63373
205
Yes, it is. What sort of transformation are you doing? What are you applying it to?

We can't do anything useful with one line.

Moud Elma
Greenhorn
Posts: 6
I used the AffineTransform and exactly the moveTo and lineTo, here is the code:

the problem is that this transform should be applied to the circle by using the moveTo and lineTo methods from the GeneralPath for the points which I defined :

like that I have an object that is simmilar to a circle but I need curves between the points and not lines.

Campbell Ritchie
Marshal
Posts: 63373
205
I am getting really confused. The moveTo method has nothing to do with AffineTransforms.

 Consider Paul's rocket mass heater.