[Drawkit] Transforms / ScaleBy

Mike Caron michael.r.caron at gmail.com
Wed Apr 8 05:41:39 PDT 2009


Roger that, huston!
Just to test that I was in fact doing the right thing, I whipped up a custom
view cocoa app that draws some lines on initialization, saved as a Bezier
path. Two buttons, rescale and translate take inputs from text boxes and
allow transforms to happen. Using those I was able to see transforms happen
as expected.

Cheers,
Mike


On Wed, Apr 8, 2009 at 12:25 AM, Graham Cox <graham.cox at bigpond.com> wrote:

>
> 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
>
>
> _______________________________________________
> Drawkit mailing list
> Drawkit at lists.apptree.net
> http://lists.apptree.net/listinfo.cgi/drawkit-apptree.net
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.apptree.net/pipermail/drawkit-apptree.net/attachments/20090408/e52b95a2/attachment.htm>


More information about the Drawkit mailing list