Re: NSAffineTransform scaleBy not scaling
Re: NSAffineTransform scaleBy not scaling
- Subject: Re: NSAffineTransform scaleBy not scaling
- From: Greg Guerin <email@hidden>
- Date: Fri, 4 Dec 2009 17:33:16 -0700
Shane wrote:
So my thought is that somehow the transformations are not resetting to
the identity matrix, but they are as far as I can tell. Maybe, I'm
thinking, that the transforms are being added on top of each other as
the view resizes.
That's a fair description of what your code is doing.
NSAffineTransform *xform = [NSAffineTransform transform];
// curve starts off translated up 2 and over 2, correct.
// resizing view seems like x and y incr by 1 as view resizes.
[xform translateXBy:2.0 yBy:2.0];
//[xform scaleXBy:xFactor yBy:yFactor];
[pointsPath transformUsingAffineTransform:xform];
You create a transform.
You set it to translate by 2.
You apply the transform to the existing pointsPath. (Each point in
the path has the transform applied to it, modifying the point
according to the transform.)
The above occurs each time drawRect: is called. So after 10 calls to
drawRect:, the points in the path have been translated a total of 10
times.
You need to rethink things so the transforms aren't cumulative.
The way I'd approach this is to keep an original untransformed path,
to which points are added. This is copied to a drawable path, and
that is the path that gets transformed and drawn. Cache the drawable
path in its transformed state. Recompute the drawable path when a
point is added, or when the transform changes.
-- GG
_______________________________________________
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