Android游戏编程之从零开始
②第二种是利用Regin来对画布设置可视区域。
canvas.clipRegion(region) 过时。
canvas.clipPath(region.getBoundaryPath()) 利用
private void T3(Canvas canvas) {
canvas.save();
canvas.drawColor(Color.WHITE);
Region region = new Region();
region.op(new Rect(200, 200, 1000, 1000), Region.Op.UNION);
region.op(new Rect(400, 300, 900, 900), Region.Op.REVERSE_DIFFERENCE);
region.op(new Rect(500, 200, 800, 800), Region.Op.XOR);
canvas.clipPath(region.getBoundaryPath());
canvas.drawBitmap(bitmapC, 0, 0, paint);
canvas.restore();
}