Quartz

Transforms CTM, 转换矩阵
Quartz转换实现的原理:Quartz把绘图分成两个部分, 用户空间,即和设备无关, 设备空间,用户空间和设备空间中间存在一个转换矩阵 : CTM本章实质是讲解CTM
Quartz提供的3大功能移动,旋转,缩放
演示如下,首先加载一张图片
void CGContextDrawImage ( CGContextRef c, CGRect rect, CGImageRef image);
移动函数CGContextTranslateCTM (myContext, 100, 50);


旋转函数
include <math.h>static inline double radians (double degrees) {return degrees * M_PI/180;}

CGContextRotateCTM (myContext, radians(–45.));缩放
CGContextScaleCTM (myContext, .5, .75);翻转, 两种转换合成后的效果,先把图片移动到右上角,然后旋转180度
CGContextTranslateCTM (myContext, w,h);
CGContextRotateCTM (myContext, radians(-180.));组合几个动作CGContextTranslateCTM (myContext, w/4, 0);
CGContextScaleCTM (myContext, .25, .5);
CGContextRotateCTM (myContext, radians ( 22.));
CGContextRotateCTM (myContext, radians ( 22.));
CGContextScaleCTM (myContext, .25, .5);
CGContextTranslateCTM (myContext, w/4, 0);
上面是通过直接修改当前的ctm实现3大效果,下面是通过创建Affine Transforms,然后连接ctm实现同样的3种效果这样做的好处是可以重用这个Affine Transforms应用Affine Transforms 到ctm的函数
void CGContextConcatCTM ( CGContextRef c, CGAffineTransform transform);
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值