Jochen,

The behavioral differences you're observing is the result of NSCompositingOperation setting.

NSRectFill() uses NSCompositeCopy whereas NSBezierPath does not modify the current setting that is accessible via -[NSGraphicsContext compositingOperation].

Aki

On 2008/10/15, at 4:56, Jochen Moeller wrote:

Hello List,

in the sample code Movie_Overlay (here with Xcode 3.1.1)
<http://developer.apple.com/samplecode/Movie_Overlay/index.html>
both subviews (AnimationView and ImageView) are filled with - whiteColor in -drawRect:.

- (void)drawRect:(NSRect)rect { // original AnimationView.m
 [[NSColor whiteColor] set];
 NSRectFill(rect);
 [self doStarAnimation];
}

This is not what I want because the movie is dimmed with increasing alpha values in the overlay. So I replaced the -whiteColor by - clearColor in both -drawRect: and used bounds instead of rect. Additionally I set the alpha value to 0.5 (instead 0.3) in MyDocument.

- (void)drawRect:(NSRect)rect { // 1st modification
 [[NSColor clearColor] set];   // in AnimationView.m
 NSRectFill([self bounds]);
 [self doStarAnimation];
}

1st Issue:
This worked fine in ImageView but in AnimationView remained a light grey shape of the animation figure which was not erased by NSRectFill(). Therefore I replaced NSRectFill() by -fillRect: in the next step.

- (void)drawRect:(NSRect)rect { // 2nd modification
 [[NSColor clearColor] set];   // in AnimationView.m
 [NSBezierPath fillRect:[self bounds]];
 [self doStarAnimation];
}

2nd Issue:
The remaining shape had gone but the movie was dimmed under the AnimationView. So -fillRect: seems not to be able to handle alpha values correct. Next I tried to fill once with -whiteColor to erase the remaining shape.

- (void)drawRect:(NSRect)rect { // 3rd modification
 static int counter = 0;       // in AnimationView.m
 if ( counter == 0 ) {
   [[NSColor whiteColor] set];
   counter++ ;
 }
 else  [[NSColor clearColor] set];
 NSRectFill([self bounds]);
 [self doStarAnimation];
}

That almost worked. The shape had gone but a line between the views appeared. I have the suspicion that the first call to NSBezierPath "stamps" the path in the background which is somewhere buffered and the rectangle is then always replaced by that buffer. So I tried a first call with an empty bezierpath object:

- (void)drawRect:(NSRect)rect { // 4th modification
 static int counter = 0;       // in AnimationView.m
 [[NSColor clearColor] set];
 NSRectFill([self bounds]);
 if ( counter == 0 ) {
   NSBezierPath *bezierPath = [NSBezierPath bezierPath];
   [bezierPath stroke]; // empty bezierpath
   counter++;
 }
 else  [self doStarAnimation];
}

And that worked !! A clear underlaying movie.

So my questions. Are that known issues of NSBezierPath?
1. -fillRect: cannot handle alpha values correct,
2. The "stamp" in the background by the first call to NSBezierPath.

And is there another workaround, e.g. to clear the buffer which is used by NSRectFill() ?

Regards
Jochen Moeller

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/aki%40apple.com

This email sent to [EMAIL PROTECTED]

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to