2

I have an NSBezierPath that I'm filling and stroking. I'd like to add some inner glow to the path (a light stroke, just inside of the outer stroke), and the thing that comes to mind is to use the same path shrunk by 1 pixel (the size of the line that is already )stroked. Is there a way to do this?

Alternatively, is there some sort of pattern I can use when applying both a border (stroke) and a glow to a bezier path?

Example, the (extremely subtle) inner glow on the Google Chrome tabs:

Chrome Tab

d11wtq
  • 34,788
  • 19
  • 120
  • 195

2 Answers2

3

You know what, you actually DON'T have to resize the bezier...all you have to do is change the stroke width:

  1. make a duplicate of the bezier
  2. on the new one, make the stroke width narrower. (So, maybe 30 on your original, try 26 on this duplicate.)

Put the new smaller one on top of the larger one.

I hope that works for you (hopefully I understood what you were getting at).

Fattie
  • 27,874
  • 70
  • 431
  • 719
3

You can resize a NSBezierPath quite easily using an NSAffineTransform.

Nick Moore
  • 15,547
  • 6
  • 61
  • 83
  • This works better, thank you. Changing the line width actually places the thinner line inside (as in equally centered) the thicker line, making it look like it's got the glow on both edges. It gives a bit of a "sketched" feel, but it's not the clean look I was going for. Adjusting the path using NSAffineTransform cleans things up. – d11wtq Dec 26 '10 at 18:17
  • Cool. By the way, if you did want to do the thick/thin lines thing without resizing the path, you could set the path as a clipping region using `[path addClip]` before drawing the lines. Then it will only draw the parts of the lines that lie *inside* the path. – Nick Moore Dec 26 '10 at 19:00