[Drawkit] Transforms / ScaleBy
Graham Cox
graham.cox at bigpond.com
Tue Apr 7 22:25:19 PDT 2009
On 08/04/2009, at 10:35 AM, Michael Caron wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hm. Seems like doing it that way yields the same second bounding
> box. Doesn't matter if I'm using the origin or not:
>
> NSRect boundingBox = [currentLayer unionOfAllObjectBounds];
> // x=16.0239811, y=15.9680157
> // h=18.1520519, w=18.1520519
>
>
> // Get the identity transform
> NSAffineTransform* txfm = [NSAffineTransform transform];
>
> // translate to origin
> [txfm translateXBy:-(boundingBox.origin.x) yBy:-
> (boundingBox.origin.y)];
>
> // scale by 1000
> [txfm scaleBy: [[self metadataObjectForKey:@"scaleFactor"]
> doubleValue]];
>
> [currentLayer applyTransformToObjects:txfm];
>
> NSRect boundingBox2 = [currentLayer unionOfAllObjectBounds];
> // x=25086.7695, y=25030.8047
> // h=26.4765625, w=26.4765625
>
> Any thoughts?
Hmm, well I'm not sure.
It might turn out that the method is buggy - it hasn't been used very
much. That said, the width/height results you're getting really don't
make much sense. You could try tracing through the loop within -
applyTransformToObjects: in the debugger and just verifying that each
individual value is doing the expected thing.
--Graham
More information about the Drawkit
mailing list