现在的位置: 首页 > 综合 > 正文

Matrix使用简介

2013年08月02日 ⁄ 综合 ⁄ 共 1047字 ⁄ 字号 评论关闭
void setRotate(float degrees)

Set the matrix to rotate about (0,0) by the specified number of degrees.
void setRotate(float degrees, float px, float
py)

Set the matrix to rotate by the specified number of degrees, with a pivot point at (px, py).

围绕点px, py 旋转 degrees度, 如果没设置坐标,默认以0,0点旋转.

缩放,翻转

 

void setScale(float sx, float sy)

Set the matrix to scale by sx and sy.
void setScale(float sx, float sy, float
px, float py)

Set the matrix to scale by sx and sy, with a pivot point at (px, py).

以点px,py为原点缩放 >=0   1为正常大小  

如果是负数,图形就会翻转

如果没设置原点坐标,默认以0,0点缩放(如果发现图片不见了,检查一下是不是翻转出了屏幕)

例子:setScale(-0.5f, 1,180, 120);  //左右翻转并缩放到一半大小

倾斜

 

void setSkew(float kx, float ky, float
px, float py)

Set the matrix to skew by sx and sy, with a pivot point at (px, py).
void setSkew(float kx, float ky)

Set the matrix to skew by sx and sy.

以点px,py为原点倾斜如果没有设置原点,则以0,0点为原点.

坐标

void setTranslate(float dx, float dy)

Set the matrix to translate by (dx, dy).

是图片移动到某一个位置

注意

Matrix中带有pre, post的函数需要考虑先后顺序

例如:想要旋转45度,然后平移到100,100的位置需要

 

 

Java代码  收藏代码
  1. Matrix matrix = new Matrix();  
  2. matrix.postRotate(45);  
  3. matrix.postTranslate(100100);    

 

或者

 

Java代码  收藏代码
  1. Matrix matrix = new Matrix();  
  2. matrix.setTranslate(100100);  
  3. matrix.preRotate(45); 

抱歉!评论已关闭.