围绕外部点的CGAffineTransformMakeRotation

编程入门 行业动态 更新时间:2024-10-19 17:26:54
本文介绍了围绕外部点的CGAffineTransformMakeRotation的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有没有办法使用CGAffineTranformMAkeRotation围绕外部点旋转UIImage? tnx很多!

解决方案

这是一个使用与CoreGraphics CGAffineTransform API格式相同格式的函数。 / p>

这完全适用于其他RotateAt()API应该如何工作。

该操作代表相当于以下规范:translate(pt.x,pt.y);旋转(角度); translate(-pt.x,-pt.y);

CGAffineTransform CGAffineTransformMakeRotationAt(CGFloat angle,CGPoint pt){ const CGFloat fx = pt.x,fy = pt.y,fcos = cos(角度),fsin = sin(角度); 返回CGAffineTransformMake(fcos,fsin,-fsin,fcos,fx - fx * fcos + fy * fsin,fy - fx * fsin - fy * fcos); }

就像 CGAffineTransformMakeRotation(),角度是弧度,而不是度数。

are there a way for rotate UIImage around external point using CGAffineTranformMAkeRotation? tnx a lot!

解决方案

Here is a function that uses the same format as the CoreGraphics CGAffineTransform API format.

This works exactly how other "RotateAt()" APIs should work.

The operation represents the equivalent of the following specification: translate(pt.x, pt.y); rotate(angle); translate(-pt.x, -pt.y);

CGAffineTransform CGAffineTransformMakeRotationAt(CGFloat angle, CGPoint pt){ const CGFloat fx = pt.x, fy = pt.y, fcos = cos(angle), fsin = sin(angle); return CGAffineTransformMake(fcos, fsin, -fsin, fcos, fx - fx * fcos + fy * fsin, fy - fx * fsin - fy * fcos); }

Just like with CGAffineTransformMakeRotation(), angle is in radians, not degrees.

更多推荐

围绕外部点的CGAffineTransformMakeRotation

本文发布于:2023-11-30 19:48:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1651288.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:CGAffineTransformMakeRotation

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!