Browse files

allow variable transparency

  • Loading branch information...
1 parent a176bcb commit 4e096527b2e6baf5a5f00f849eea160f94456d68 Zachary Schneirov committed Jan 31, 2010
Showing with 5 additions and 1 deletion.
  1. +1 −0 LinearDividerShader.h
  2. +4 −1 LinearDividerShader.m
View
1 LinearDividerShader.h
@@ -33,5 +33,6 @@ NSRect centeredRectInRect(NSRect rect, NSSize size);
@interface NSImage (CenteredDrawing)
- (void)drawCenteredInRect:(NSRect)aRect;
+- (void)drawCenteredInRect:(NSRect)aRect fraction:(float)aFraction;
@end
View
5 LinearDividerShader.m
@@ -76,9 +76,12 @@ void ColorBlendFunction(void *info, const CGFloat *in, CGFloat *out) {
@implementation NSImage (CenteredDrawing)
- (void)drawCenteredInRect:(NSRect)aRect {
+ [self drawCenteredInRect:aRect fraction:1.0];
+}
+- (void)drawCenteredInRect:(NSRect)aRect fraction:(float)aFraction {
NSRect cent = centeredRectInRect(aRect, [self size]);
cent = [[NSView focusView] centerScanRect:cent];
- [self compositeToPoint:NSMakePoint(cent.origin.x, cent.origin.y + cent.size.height) operation:NSCompositeSourceOver];
+ [self compositeToPoint:NSMakePoint(cent.origin.x, cent.origin.y + cent.size.height) operation:NSCompositeSourceOver fraction:aFraction];
}
@end

0 comments on commit 4e09652

Please sign in to comment.