canvas 中的一些方法
在canvas中一般使用的方法为
drawXXX(): 绘制的方法
clipXXX(): 裁剪的方法
clipRect
裁剪画布,clipRect(int left, top, right, bottom);
clipRectF(float left, top, right, bottom)
当执行了该方法,如clipRect(0,0,500,500);
则后面都只能在(0,0,500,500)区域绘制
用Rect实现多区域裁剪
intersect 交集】
1 2 3 4 5 6 7 8
   |  Rect rect = new Rect(0, 0, 500, 500);              rect.intersect(250, 250, 750, 750);           canvas.clipRect(rect);
  // 取到区域(250, 250, 500, 500)
 
  | 
 
绘制多个区域相交的区域
union 合集
1 2 3 4 5 6 7 8
   |  Rect rect = new Rect(0, 0, 500, 500);          rect.union(250, 250, 750, 750);        canvas.clipRect(rect);
  // 取到的区域为(0, 0, 750, 750)
 
  | 
 
绘制多个区域之和
clipPath 取出某个区域
1 2 3 4 5 6 7 8 9 10 11 12 13
   |  // 实例化路径 mPath = new Path(); // 移动起点至[50,50] mPath.moveTo(50, 50);   mPath.lineTo(75, 23);   mPath.lineTo(150, 100);   mPath.lineTo(80, 110);   // 闭合路径 mPath.close();
  // 按照路径进行裁剪 canvas.clipPath(mPath);
 
  | 
 
即是将path区域裁剪出来
同样后面在能在该path区域绘制图形
Region.Op
canvas.drawRect