![]() |
Drawing a polygon using doubles
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 |
Re: Drawing a polygon using doubles
On Wed, 08 Oct 2003 08:35:09 +1000, Rick <rrquick@nospam-com> wrote or
quoted : >If I convert my double >values to integer, I get an incorrect figure. Thanks You are going to have to scale and round your doubles to int pixels. See http://mindprod.com/convert.html For another way to draw a polygon, see http://mindprod.com/jgloss/polygon.html -- Canadian Mind Products, Roedy Green. Coaching, problem solving, economical contract programming. See http://mindprod.com/jgloss/jgloss.html for The Java Glossary. |
Re: Drawing a polygon using doubles
Thanks Roedy, that helped. :)
Roedy Green wrote: > On Wed, 08 Oct 2003 08:35:09 +1000, Rick <rrquick@nospam-com> wrote or > quoted : > > >>If I convert my double >>values to integer, I get an incorrect figure. Thanks > > > You are going to have to scale and round your doubles to int pixels. > > See http://mindprod.com/convert.html > > For another way to draw a polygon, see > http://mindprod.com/jgloss/polygon.html > > -- > Canadian Mind Products, Roedy Green. > Coaching, problem solving, economical contract programming. > See http://mindprod.com/jgloss/jgloss.html for The Java Glossary. |
Re: Drawing a polygon using doubles
Rick wrote:
> 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 |
| All times are GMT. The time now is 10:45 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.