• Post Reply Bookmark Topic Watch Topic
  • New Topic
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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to draw a circle using 2d arrays

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

any help please.
 
Campbell Ritchie
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am getting really confused. The moveTo method has nothing to do with AffineTransforms.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic