Reputation: 711
For a project I'm trying to draw Bézier curves. Now, I created my own BezierCurve
class that calculates points via forward differencing. I'm currently drawing the curve by drawing a Line2D.Double
between each two points. This is my current output;
The upper curve (1) is the one I drew with my BezierCurve
class. The lower curve (2) is the same Bézier curve shifted downwards and drawn by a GeneralPath
object (using the curveTo
method).
Now, I can't help but notice that (2) looks alot smoother than (1) Of course I could use GeneralPath
(or CubicCurve2D.Double
) myself, but as this is for a project that's not an option.
Now, my question is, is there anything I can do to make the curve look smoother? I tried simply increasing the number of points and using fillRect() but they show no improvement.
Upvotes: 1
Views: 1626
Reputation: 101
You could try to set antialiasing on :
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
Upvotes: 2