Search code examples
javagraphicsacm-java-libraries

How can I create rounded diagonal lines in Java using the ACM library?


I am trying to draw rounded diagonal lines in Java using the ACM library.

A very complicated method would involve drawing a diagonal line, scaling it up to increase its width, drawing an arc on the top of that line with respect to the angles it is rounded.


Solution

  • From the picture you linked to, it looks like you want lines with round end-caps, sometimes called line-joins. I don't know the ACM library too well, but looking at the docs for it, it seems like you could achieve that look by using a GPen with an image that is just a filled-in circle. You could call the setLocation(x,y) and then drawLine(dx, dy) methods on it.