• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Now contents of the layer not being rotated [was Re: Rotating a CALayer more than once is not working ]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Now contents of the layer not being rotated [was Re: Rotating a CALayer more than once is not working ]


  • Subject: Now contents of the layer not being rotated [was Re: Rotating a CALayer more than once is not working ]
  • From: Gustavo Pizano <email@hidden>
  • Date: Sun, 14 Dec 2008 11:07:15 +0100

I was thinking if I should have different images facing north, south, east and west, and once the layer is rotated I should assign the new image to the layer contents.??

I came up to this conclusion because, last night while trying to sleep, that due that the contents of the layer is a ref to the image then the contents are not being rotated while the layer itself it is. What it seems to me weird, is why when I rotate the layer I see the image being rotated, but when I get the content of the layer, which is a ImageRef, then the ImageRef its still in horizontal position, this kept me away from sleep.


So, having different images facing different coordinates is the real fix to this issue,? Im starting to believe that it is.



Gustavo



On 13.12.2008, at 21:25, Gustavo Pizano wrote:

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


  • Follow-Ups:
    • Re: Now contents of the layer not being rotated [was Re: Rotating a CALayer more than once is not working ]
      • From: "Michael Ash" <email@hidden>
References: 
 >Rotating a CALayer more than once is not working (From: Gustavo Pizano <email@hidden>)
 >Re: Rotating a CALayer more than once is not working (From: Steve Bird <email@hidden>)
 >Re: Rotating a CALayer more than once is not working [Solved: now contents of the layer not being rotated] (From: Gustavo Pizano <email@hidden>)

  • Prev by Date: Re: Encoding a Custom Object which has a CALayer instance Variable (newbie Question)
  • Next by Date: Re: Using NSWorkspace's launchedApplication to detect running App
  • Previous by thread: Re: Rotating a CALayer more than once is not working [Solved: now contents of the layer not being rotated]
  • Next by thread: Re: Now contents of the layer not being rotated [was Re: Rotating a CALayer more than once is not working ]
  • Index(es):
    • Date
    • Thread