Question

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.

Was it helpful?

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.

OTHER TIPS

I've never used ACM but looking at the javadoc you might want to consider using shapes rather then lines. So for example, you can draw a rectangle of width using GPolygon then draw circles on the ends using GOval

So something like: draw a polygon around the points [100,0],[0,100],[10,110],[110,10], then draw two circles of size 10 at 0,110 and 110,0. If those shapes are all filled with the same color, they should look like one solid.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top