简单总结RectF、Rect 和Matrix ,还有Paint的使用方法

1、Rect类和RectF类 
参考资料:http://byandby.iteye.com/blog/826230 
管方文档:Rect 类: http://developer.android.com/reference/android/graphics/Rect.html 
RectF类:http://developer.android.com/reference/android/graphics/RectF.html

RectF和Rect都表示的是一个矩形的区域,他们的构造方法类似,详细请看官方文档,这里以RectF为例,如下: 
RectF() :构造一个无参的矩形;

RectF(float left,float top,float right,float bottom)构造一个指定了4个参数的矩形 ,这些参数都是坐标,即矩形的宽width = right - left ,高height = bottom - top;如下图所示 
RectF rectF = new RectF(150,75,260,120); 

150指的是矩形区域左上角的横坐标,即A; 
75指的是矩形区域左上角的纵坐标,即B; 
260指的是矩形区域右下角的横坐标,即C; 
120指的是矩形区域右下角的纵坐标,即D;

RectF(Rect F r)根据指定的RectF对象来构造一个RectF对象(对象的左边坐标不变) 。

RectF(Rect r)根据给定的Rect对象来构造一个RectF对象。

这就是RectF的功能了,Rect 也具有这个功能。两者的区别在于: 
RectF 中的参数是单精度浮点型的; 
Rect 中的参数是整形的。

2、Matrix 
参考资料:http://blog.163.com/lww2626@126/blog/static/27384067201192564628645

http://www.cnblogs.com/plokmju/p/android_Matrix.html#MatrixRotate

http://blog.csdn.net/programchangesworld/article/details/49078387

3、Paint 画笔

参考资料:http://www.cnblogs.com/-OYK/archive/2011/10/25/2223624.html

参数官方API解释:

public RectF (float left, float top, float right, float bottom)

Added in  API level 1

Create a new rectangle with the specified coordinates. Note: no range checking is performed, so the caller must ensure that left <= right and top <= bottom.

Parameters
left The X coordinate of the left side of the rectangle
top The Y coordinate of the top of the rectangle
right The X coordinate of the right side of the rectangle
bottom The Y coordinate of the bottom of the rectangle

百度翻译一下:

用指定坐标创建新矩形。注意:没有进行范围检查,所以调用者必须确保,左<=右和顶部<=底部。

左边矩形的x坐标
矩形顶部的y坐标
右边矩形的x坐标

矩形底部y坐标

你可能感兴趣的:(Android)