Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Working out the four points of a sublayerTransform



Hello.

I'm wanting to draw a polygon around a layer. I want the polygon to be 1 pixel wide regardless of the transformations applied to the layer. As such a border/borderWidth solution won't work because it'll be scaled if the layer is scaled. So I've computed the scaled and rotated coordinates of said layer by walking up the layer tree and applying the affine transforms top-down to each of the four points making up the original rectangle of the layer. This gives me what I want - until I do rotation with sublayerTransforms.

In an ideal world I'd like to know if there is also a way to apply a CATransform3D to a point.

For example, in order to compute the translation, scale and rotation(z) of a given point from the original rectangle I need do only:

	point = CGPointApplyAffineTransform(point, [layer affineTransform]);

However there doesn't seem to be an equivalent function for CATransform3D transforms.

Any suggestions? I've spent the entire day reading about perspective transformations and projections (lots of matrix math). I'm happy (as happy as someone that's not done this stuff for many years can be) to go down this path if it's absolutely required, but was wondering if anyone knew of a simpler way (rather than reinventing the wheel) of applying the same (or close enough - similar) math that CA/OpenGL is applying to the sublayerTransform a matrix.

To be clear, I'm talking specifically about computing the final value of a point in a layer given that I've set the m34 field of the sublayerTransform in order to achieve a perspective effect (ala: CovertFlow).

--
Regards,
Neil Clayton,  http://shinywhitebox.com







_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartz-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartz-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.