In order to solve a scaling problem, I have the following question:
graphics.drawLine(x1,y1,x2,y2);
draws a line between 2 points.
Does it draw this Lines "on Top" of those points or is it drawn below them?
See my Image for clarification:
The upper example shows how an Oval is drawn with
graphics.fillOval(x,y,w,h);
where the black point is the x and y coordinate and the red circle is the actual oval...
Is it the same using graphics.drawLine()
when using a new BasicStroke(3.5f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)
like in the lower example?
Or is the line actually drawn centered to the coordinates?
Any help is appreciated.
Asked
Active
Viewed 480 times
-1

RoiEX
- 1,186
- 1
- 10
- 37
-
3I have no idea. But why don't you just test it and see? – JB Nizet Jun 22 '16 at 16:16
-
@JBNizet how could I test this? – RoiEX Jun 22 '16 at 16:17
-
To better understand the problem, you'll need to draw a grid to represent pixels, and then fill them in to show how the geometric primitives are rendered. – Jun 22 '16 at 16:17
-
1Draw a 1x1 rectangle to mark the point. – Jun 22 '16 at 16:18
1 Answers
1
For drawLine(), the beginning of the arc portion will be at x location, so your picture is wrong. The rounded cap will protrude to the left of the left dot, and to the right of the right dot.

FredK
- 4,094
- 1
- 9
- 11