https://kotlinlang.org logo
#doodle
Title
# doodle
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:
Copy code
canvas.rect(bounds.atOrigin.inset(…), Stroke(…))
8 Views