Inner Stroke Question

I often hit this issue when created a rounded button:

Steps:

  1. Created a rounded rectangle using getLocalBounds() as the bounds of the rect.
  2. Fill the path
  3. Stroke the path

Because JUCE uses centered stroking with no option for inner strokes, this leads to some really crumby code requiring reducing the rectangle as a function of the stroke size, I’ve also tried affine transforms on the stroke function – generally all off these lead to really strange and irritating issues.

Is anyone aware of a safe / easy method to stroke a path with an inner stroke instead of centered?

1 Like

@GarrettBurnett ?

You can call reduced() on the rectangle and pass half the width of the stroke size as the amount to reduce it by, if you find this is something you often want to do just create a function that does this for you.

additionally, if you’re stroking a path object you can apply an AffineTransform to perform that reduction (specifically scale(), but the X and Y scaling need to be calculated as factors rather than as pixel values).

I got nothin :confused: It’s an annoying problem that I’ve always dealt with the way others have mentioned.