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
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
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?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...