Drawing a polygon using doubles

R

Rick

Hi,

There's a method called drawPolygon in the java.awt.Graphics class which
takes in two integer arrays for drawing a polygon. Is there someway I
could draw a polygon using two arrays of doubles? If I convert my double
values to integer, I get an incorrect figure. Thanks


Rick
 
C

Chris Smith

Rick said:
There's a method called drawPolygon in the java.awt.Graphics class which
takes in two integer arrays for drawing a polygon. Is there someway I
could draw a polygon using two arrays of doubles? If I convert my double
values to integer, I get an incorrect figure. Thanks

You could cast your Graphics to a Graphics2D, then use draw(Shape)
providing a GeneralPath constructed of Line2D.Double objects. That
would definitely do it.

On the other hand, when you say "If I convert my double values to
integer, I get an incorrect figure", I start to wonder. Double values
would be useful for anti-aliasing to get the appearance of a better
polygon, but beyond that, the greatest precision that the screen has is
a pixel anyway, so you'd better not be getting anything too awfully
"incorrect", or a double version isn't going to fix it.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top