有时候在缩放后,需要知道该次缩放是在哪个坐标开始缩放的。如上篇已知缩放的点,然后在该点对其缩放。本篇其实是逆运算
(x,y)就是当初在该点进行缩放
化简之后很简单,代码如下:
func getZoomPoint(fromRect:CGRect,toRect:CGRect)->CGPoint{
var scale = toRect.width / fromRect.width
var x = (toRect.origin.x - scale * fromRect.origin.x) / (1.0 - scale)
var y = (toRect.origin.y - scale * fromRect.origin.y) / (1.0 - scale)
return CGPoint(x: x, y: y)
}