Archived

This topic is now archived and is closed to further replies.

Chaucer

[java] drawing 2D lines with floating points

Recommended Posts

Chaucer    122
I''m creating a GUI where I need to draw a graph using floating point numbers. The problem is that the Graphics class in the awt package only has DrawLine(int,int,int,int) Does anyone know what I could use to get a more precise line?

Share this post


Link to post
Share on other sites
BlackArrow    122
Off the top of my head:

Perhaps you could increase the scale of the integers, such that "36" on the screen actually represents 3.6 logically.

Exactly how precise does the graph have to be? If you are simply drawing a line, find two points that correspond to integer positions and voila!

It might be worth trying to simply cast the values as ints and see if the results are any good - if the difference is not noticible, well hey! Problem solved!

Share this post


Link to post
Share on other sites
Petr Stedry    122
Hi,

IMO if the lines are to be drawn to a display that consists of a rectangular area filled with distinct light emitting dots, you''ll be forced to round your "floating point" lines into an integer space.


Petr Stedry

Share this post


Link to post
Share on other sites