本文整理匯總了Java中android.graphics.Region.setPath方法的典型用法代碼示例。如果您正苦於以下問題:Java Region.setPath方法的具體用法?Java Region.setPath怎麽用?Java Region.setPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.graphics.Region
的用法示例。
在下文中一共展示了Region.setPath方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: clippedRotatedOval
import android.graphics.Region; //導入方法依賴的package包/類
private Bitmap clippedRotatedOval(Bitmap bitmap) {
Bitmap bmp;
float width = bitmap.getWidth();
float height = bitmap.getHeight();
bmp = Bitmap.createBitmap((int) width, (int) height, Bitmap.Config.ARGB_8888);
BitmapShader shader = new BitmapShader(bitmap, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP);
Canvas canvas = new Canvas(bmp);
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setShader(shader);
Path oval = new Path();
Matrix matrix = new Matrix();
Region region = new Region();
RectF ovalRect = new RectF(width / OVAL_FACTOR, 0, width - (width / OVAL_FACTOR), height);
oval.addOval(ovalRect, Path.Direction.CW);
matrix.postRotate(ROTATION, width / 2, height / 2);
oval.transform(matrix, oval);
region.setPath(oval, new Region((int) width / 2, 0, (int) width, (int) height));
canvas.drawPath(region.getBoundaryPath(), paint);
return bmp;
}
示例2: isTouch
import android.graphics.Region; //導入方法依賴的package包/類
/**
* 是否點擊的省份
* 點擊時間
* @param x
* @param y
*/
public boolean isTouch(int x,int y){
RectF rectF = new RectF();
path.computeBounds(rectF,true);
Region region = new Region();
region.setPath(path,new Region((int)rectF.left,(int)rectF.top,(int)rectF.right,(int)rectF.bottom));
return region.contains(x,y);
}
示例3: heart
import android.graphics.Region; //導入方法依賴的package包/類
private Bitmap heart(Bitmap bitmap) {
Bitmap bmp;
float width = bitmap.getWidth();
float height = bitmap.getHeight();
bmp = Bitmap.createBitmap((int) width, (int) height, Bitmap.Config.ARGB_8888);
BitmapShader shader = new BitmapShader(bitmap, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP);
Canvas canvas = new Canvas(bmp);
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setShader(shader);
Path oval = new Path();
Matrix matrix = new Matrix();
Region region = new Region();
RectF ovalRect = new RectF(width / OVAL_FACTOR, 0, width - (width / OVAL_FACTOR), height);
oval.addOval(ovalRect, Path.Direction.CW);
matrix.postRotate(ROTATION, width / 2, height / 2);
oval.transform(matrix, oval);
region.setPath(oval, new Region((int) width / 2, 0, (int) width, (int) height));
canvas.drawPath(region.getBoundaryPath(), paint);
matrix.reset();
oval.reset();
oval.addOval(ovalRect, Path.Direction.CW);
matrix.postRotate(-ROTATION, width / 2, height / 2);
oval.transform(matrix, oval);
region.setPath(oval, new Region(0, 0, (int) width / 2, (int) height));
canvas.drawPath(region.getBoundaryPath(), paint);
return bmp;
}
示例4: onTouchEvent
import android.graphics.Region; //導入方法依賴的package包/類
@Override
public boolean onTouchEvent(final MotionEvent event) {
if (mDrawCompleted) {
Point point = new Point();
point.x = (int) event.getX();
point.y = (int) event.getY();
int count = 0;
Region r = new Region();
for (PieSlice slice : mSlices) {
r.setPath(slice.getPath(), slice.getRegion());
switch (event.getAction()) {
default:
break;
case MotionEvent.ACTION_DOWN:
if (r.contains(point.x, point.y)) {
mSelectedIndex = count;
postInvalidate();
}
break;
case MotionEvent.ACTION_UP:
if (count == mSelectedIndex
&& mListener != null
&& r.contains(point.x, point.y)) {
mListener.onSliceClick(mSelectedIndex);
}
break;
}
count++;
}
}
// Case we click somewhere else, also get feedback!
if(MotionEvent.ACTION_UP == event.getAction()
&& mSelectedIndex == -1
&& mListener != null) {
mListener.onSliceClick(mSelectedIndex);
}
// Reset selection
if (MotionEvent.ACTION_UP == event.getAction()
|| MotionEvent.ACTION_CANCEL == event.getAction()) {
mSelectedIndex = -1;
postInvalidate();
}
return true;
}