Re: Affine Transform
Re: Affine Transform
- Subject: Re: Affine Transform
- From: Ian was here <email@hidden>
- Date: Sat, 11 Feb 2006 18:41:44 -0800 (PST)
Here is some sample code that demonstrates image
rotation, amongst other things...
http://www.howleware.com/apps/simple_sprite_engine.hqx
--- Terry Heaford <email@hidden>
wrote:
> A newbie question:
>
> I am really struggling with affine transforms to
> rotate an image
> contained in an NSView which is a subview of a
> scrollview.
>
> The image is larger than than the visible size of
> the scrollview.
>
> The code I have from drawRect is below:
>
> if (image)
> {
> deg = 45;
>
> NSRect imageRect = NSMakeRect(0,0,[image
> size].width,[image
> size].height);
>
> NSPoint imageDrawPoint = NSMakePoint([self
> visibleRect].size.width/
> 2, [self visibleRect].size.height/2);
>
> NSAffineTransform *trans = [NSAffineTransform
> transform];
> [trans translateXBy:imageDrawPoint.x
> yBy:imageDrawPoint.y];
> [trans rotateByDegrees:deg];
> [trans translateXBy:-imageDrawPoint.x
> yBy:-imageDrawPoint.y];
> [trans concat];
>
> [image drawAtPoint:NSZeroPoint fromRect:imageRect
>
> operation:NSCompositeCopy fraction:opacity];
>
> }
>
> This seems to rotate the image correctly but how do
> I size the frame
> or the bounds (not sure which or both) to the
> correct size for the
> rotated image allowing it to be scrolled within the
> scrollview and
> how do I locate the image within the frame
> correctly.
>
> Thanks in advance
>
> Terry
>
>
> _______________________________________________
> 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
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
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