Re: Rotating an object
Re: Rotating an object
- Subject: Re: Rotating an object
- From: "Dan Rodricks" <email@hidden>
- Date: Tue, 22 Aug 2006 10:21:50 +0530
Hi All,
I am trying to rotate objects with a given angle. I have been
experimenting with sketch sample.
I have modified drawInView function of its graphic class. I can see
the object gets rotated with below code,
but it becomes partially visible (drawing out of bounds).
Below is the code snippet.
(void)drawInView:(SKTGraphicView *)view isSelected:(BOOL)flag
fAngle:(float) fAngle
{
NSBezierPath *path = [self bezierPath];
if (path)
{
if ([self drawsFill])
{
[[self fillColor] set];
[path fill];
}
if ([self drawsStroke])
{
[[self strokeColor] set];
if(fAngle == 45)
{
NSAffineTransform *rotation =
[NSAffineTransform transform];
[rotation rotateByDegrees:fAngle];
[rotation concat];
}
[path stroke];
}
}
if (flag)
{
[self drawHandlesInView:view];
}
}
Any idea on this would be appreciated.
Best Regards.
Tom Wenger.
On 8/17/06, Tom Wenger <email@hidden> wrote:
> Hi All,
>
> I am trying to rotate objects with a given angle. I have been
> experimenting with sketch sample.
> I have modified drawInView function of its graphic class. I can see
> the object gets rotated with below code,
> but it becomes partially visible (drawing out of bounds).
>
> Below is the code snippet.
> [snip]
> Any idea on this would be appreciated.
The rotation is happening relative to the lower left corner. You need
to translate to the center of what you are rotating (assuming that is
what you want) and then rotate.
Review...
<http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaDrawingGuide/Transforms/chapter_4_section_3.html#//apple_ref/doc/uid/TP40003290-CH204-BCICHEAF>
-Shawn
Shawn,
Thank you very much for you help.
I tried to translate an object to the center and rotate it and also
did the rotation against lower left corner. In both the cases I can
see the rotation is applied. But My point is when rotation is done,
object just becomes out of bound, so is partially visible. I guess I
need to calculate here new bounds of the object and then apply those.
But how can I calculate new bounds.
any idea.
Thanks in advance.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden