Hello,
I paint a rounded rectangle with a spezified stroke and then i try to paint a single line around this rectangle. But at the edges it never really matches each other.
g.setStroke(new BasicStroke(radius + .5f));
g.drawRoundRect(x + radius/2, y + radius/2, width - radius, height - radius, radius, radius);
// Outer border
g.setColor(outer);
g.setStroke(new BasicStroke(1));
g.drawRoundRect(x, y, width - 1, height - 1, radius, radius);
Do you know how to calculate the outer border radius?
OK I tried a little bit and I got a better one, but still not perfekt;
float scale = radius / 2.0f;
g.setPaint( p );
g.setStroke(new BasicStroke(2 * scale ));
g.drawRoundRect(x + radius/2, y + radius/2, width - radius, height - radius, radius, radius);
// Outer border
g.setColor(outer);
g.setStroke(new BasicStroke(1));
g.drawRoundRect(x, y, width - 1, height - 1, Math.round(4*scale), Math.round(4*scale) );
Does anybody have a better one?