https://kotlinlang.org logo
Title
c

Cherrio LLC

03/21/2023, 2:32 PM
Hello, I added stroke to a rounded corner path, but the result is not expected. The outer edges are not rounded. Is that intended?
n

Nick

03/21/2023, 3:38 PM
This is expected since SVGs will stroke on the line of a shape, which means half of your stroke will be inside and half outside. You can fix this by insetting the shape by 1/2 your stoke thickness. So you can do
val insetRect = rect.inset(thickness / 2)
then create your path from
insetRect
instead. Same goes for drawing a rect directly:
canvas.rect(bounds.atOrigin.inset(…), Stroke(…))