What settings am i supposed to make at function g.drawline() in order to accept real numbers, for example i want to draw a line g.drawline(15.8,7.2,6.4,1225) ) using real numbers
Printable View
What settings am i supposed to make at function g.drawline() in order to accept real numbers, for example i want to draw a line g.drawline(15.8,7.2,6.4,1225) ) using real numbers
Look at the Line2D (Java Platform SE 6) class. It is abstract, but you can retrieve an instance through one of the Line2D.Float or Line2D.Double child classes. They implement the Shape interface, so you can call the g.draw(Shape s) function to draw it (I believe this function only resides in the Graphics2D class, so you must cast your graphics object to a Graphics2D to call it).
Interesting concept: partial pixels: .8 of a pixel. How would the hardware handle that?Quote:
draw a line g.drawline(15.8, 7.2, 6.4, 1225) ) using real numbers
Can a pixel only show part of itself? What are the subparts of a pixel?
The simple solution is to do all your calculations using floats/doubles, then when you're actually drawing cast them to ints.
For what its worth, despite being a partial pixel, floating points graphics become quite useful when you need to do more complex drawing such as transforms, bezier curves, etc...