matrix基本使用方法(1)

matrix基本使用方法(1)

ID:11730612

大小:218.00 KB

页数:7页

时间:2018-07-13

matrix基本使用方法(1)_第1页
matrix基本使用方法(1)_第2页
matrix基本使用方法(1)_第3页
matrix基本使用方法(1)_第4页
matrix基本使用方法(1)_第5页
资源描述:

《matrix基本使用方法(1)》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、PublicConstructorsMatrix()CreateanidentitymatrixMatrix(Matrix src)Createamatrixthatisa(deep)copyofsrc 旋转voidsetRotate(floatdegrees)Setthematrixtorotateabout(0,0)bythespecifiednumberofdegrees.voidsetRotate(floatdegrees,floatpx,floatpy)Setthematrixtorotatebythespecifiednumberofdegrees,withap

2、ivotpointat(px,py).围绕点px,py旋转degrees度,如果没设置坐标,默认以0,0点旋转.例子:setRotate(45,180,120);缩放,翻转voidsetScale(floatsx,floatsy)Setthematrixtoscalebysxandsy.voidsetScale(floatsx,floatsy,floatpx,floatpy)Setthematrixtoscalebysxandsy,withapivotpointat(px,py).以点px,py为原点缩放>=0 1为正常大小 如果是负数,图形就会翻转如果没设置原点坐标,默认

3、以0,0点缩放(如果发现图片不见了,检查一下是不是翻转出了屏幕)例子:setScale(-0.5f,1,180,120); //左右翻转并缩放到一半大小倾斜voidsetSkew(floatkx,floatky,floatpx,floatpy)Setthematrixtoskewbysxandsy,withapivotpointat(px,py).voidsetSkew(floatkx,floatky)Setthematrixtoskewbysxandsy.以点px,py为原点倾斜如果没有设置原点,则以0,0点为原点.例子:setSkew(0,1,180,120);//Y方

4、向拉伸坐标voidsetTranslate(floatdx,floatdy)Setthematrixtotranslateby(dx,dy).是图片移动到某一个位置 注意Matrix中带有pre,post的函数需要考虑先后顺序例如:想要旋转45度,然后平移到100,100的位置需要  Java代码1.Matrix matrix = new Matrix();  2.matrix.postRotate(45);  3.matrix.postTranslate(100, 100);    Matrixmatrix=newMatrix();matrix.postRotate(45

5、);matrix.postTranslate(100,100); 或者 Java代码1.Matrix matrix = new Matrix();  2.matrix.setTranslate(100, 100);  3.matrix.preRotate(45);  Matrixmatrix=newMatrix();matrix.setTranslate(100,100);matrix.preRotate(45); 这就要考虑到矩阵的前乘和后乘了,不然的话你会发现可能坐标位置不是你想要的,可能图像都不见了.如果在复杂一些,需要选择,缩放,倾斜同时起作用,并且还要设置坐标到屏

6、幕指定位置你会发现很麻烦,需要自己计算出各个方法的参数,然后考虑调用的先后顺序. 但这里有一种更简便的方法,叫系统帮我们计算 booleansetConcat(Matrix a, Matrix b)Setthematrixtotheconcatenationofthetwospecifiedmatrices,returningtrueifthetheresultcanberepresented.这个方法的意思是帮我们把两个Matrix对象计算并连接起来.这样的话我们就可以这样使用了  Java代码1.Matrix mRotateMatrix = new Matrix(); 

7、   //控制旋转  2.Matrix mScaleMatrix = new Matrix(); //控制缩放  3.Matrix mSkewMatrix = new Matrix();  //控制倾斜  4.Matrix mPosMatrix = new Matrix();       //控制坐标  5.Matrix mMatrix = new Matrix();      //合并  6.      7.mMatrix.setConcat(mRotateMatrix, mScaleMatrix);  8.mM

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。