Re: Rotating a CALayer more than once is not working [Solved: now contents of the layer not being rotated]
Re: Rotating a CALayer more than once is not working [Solved: now contents of the layer not being rotated]
- Subject: Re: Rotating a CALayer more than once is not working [Solved: now contents of the layer not being rotated]
- From: Gustavo Pizano <email@hidden>
- Date: Sat, 13 Dec 2008 21:25:35 +0100
Aha... I was making that mistake. Thanks for the advice, but now I
have another problem, and its that the layer its rotating good, but
the contents of the layer stay untouched, I dunno if I explain
myself, I see the layer rotating, but then if I want to drag the
layer with the new position (after rotating) I realize that when I
get the contents of the layer to set the image that will be dragged,
the contents of the layer which is a CGImageRef its still in
horizontal position, allowing me to see only on portion of the image
that its in the layer (this portion is the one that is inside the
layer which in fact was successfully rotated, I tried the following
without success.
-(void)mouseDown:(NSEvent *)event
{
[event retain];
[mouseDownEvent release];
mouseDownEvent = event;
NSPoint p2 = [event locationInWindow];
NSPoint p3 = [self convertPoint:p2 fromView:nil];
CGPoint p = NSPointToCGPoint(p3);
CALayer * nLayer = [_gameboardLayer hitTest:p];
unsigned int flags;
flags = [event modifierFlags];
if ( (nLayer.name != nil) && (flags & NSControlKeyMask)) {
NSNumber* value = [NSNumber numberWithFloat:PERP()];
value = [NSNumber numberWithFloat:[value floatValue] + [[nLayer
valueForKeyPath:@"transform.rotation.z"] floatValue]];
[nLayer setValue:value forKeyPath:@"transform.rotation.z"];
CGContextRef ctx = (CGContextRef)[[NSGraphicsContext currentContext]
graphicsPort];
CGContextSaveGState(ctx);
CGContextRotateCTM(ctx,[value floatValue]);
CGContextDrawImage(ctx, [nLayer frame], (CGImageRef)nLayer.contents);
CGContextRestoreGState(ctx);
}
}
I wrote that after reading how to rotate CGImages, but nothing
happens, when trying to drag I see only one portion of the image.
... any advice on this one... I guess because of the contents are not
being rotated also is why im seeing the image of the layer blurred, as
I post in a message before this one.
Thanks for your help
G
_______________________________________________
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