I am trying to create an effect on a CALayer such that when the user touches and holds on a given point, the entire layer deforms in such a way that it creates the illusion of that point being pushed "down" (the view is 2D). The mathematics seem relatively simple to me: each point on the CALayer will undergo a translation towards the pressure point inverse its distance from the point (at this stage I am ignoring the effect the frame would have on this deformation). Think of the classic models showing General Relativity on a 2D plane with mass causing the plane to deform into a 3rd spatial dimension, only viewed from above the plane.
At this point I have determined that I cannot do this with an affine transformation since parallel lines in the original layer will no longer be so in the transformed one.
Assuming that is correct, is there a way to do this? It doesn't strike me that CATransform3D could do it either, as simply changing the perspective within a 3D space doesn't seem like it could accomplish this effect either.
I am quite new to transformation matrices, so I may be missing something basic. Or this might simply be beyond what you can do with the built in options in Core Animation or Core Graphics (perhaps it requires OpenGL?).
You’re right that an affine transform won’t do what you want here. OpenGL would work, but you might be able to use something simpler—SpriteKit provides an SKEffectNode class, which lets you use a Core Image filter to render its children (which should include the image you want to distort). The set of filters available on iOS varies from version to version, and doesn’t completely overlap with the set of filters available on OS X, but CIPinchDistortion looks like it might do what you’re after.