[SOLVED] Is there a fast NSShadow alternative?
[SOLVED] Is there a fast NSShadow alternative?
- Subject: [SOLVED] Is there a fast NSShadow alternative?
- From: "Alan Smith" <email@hidden>
- Date: Wed, 11 Jul 2007 16:55:23 -0400
I have come up with a way to create an inner glow for a NSBezierPath,
it's not very pretty and doesn't work perfectly for all shapes but it
will do for now.
Here is the code:
[NSGraphicsContext saveGraphicsState];
NSBezierPath *shadowPath = [NSBezierPath bezierPathWithRect: rect];
NSAffineTransform *transform = [NSAffineTransform transform];
NSShadow *shadow = [[NSShadow alloc] init];
[shadow setShadowBlurRadius: 105.0];
[shadow setShadowColor: [NSColor greenColor]];
[shadow set];
float lineWidth = 50.0;
NSRect pathBounds = [shadowPath bounds];
NSSize pathSize = pathBounds.size;
NSSize scaledSize = NSMakeSize(pathSize.width + lineWidth,
pathSize.height + lineWidth);
NSPoint pathOrigin = pathBounds.origin;
NSPoint pathOffsetOrigin = NSMakePoint(pathOrigin.x - lineWidth / 2.0,
pathOrigin.y - lineWidth / 2.0);
[transform scaleSize: pathSize toSize: scaledSize];
[transform translatePoint: pathOrigin toPoint: pathOffsetOrigin];
[shadowPath addClip];
[shadowPath setLineWidth: lineWidth];
[shadowPath transformUsingAffineTransform: transform];
[[shadow shadowColor] set];
[shadowPath stroke];
[NSGraphicsContext restoreGraphicsState];
Have fun, Alan
--
// Quotes from Alan Smith -------------------------
"You don't forget, you just don't remember."
"Maturity resides in the mind."
"Silence is the Universe's greatest gift."
"When the World realizes that personal beliefs are not something to
argue or fight over, it shall evolve."
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden