use of android.graphics.RectF in project AndroidSDK-RecipeBook by gabu.
the class CanvasView method drawRect.
private void drawRect(Canvas canvas) {
Paint paint = new Paint();
paint.setColor(Color.WHITE);
paint.setStrokeWidth(5);
// RectFを指定
RectF rect = new RectF(30, 30, 60, 60);
canvas.drawRect(rect, paint);
// default
// Paint.Style.FILL
// 塗りつぶすだけ(線を引かない)
canvas.drawRect(90, 30, 120, 60, paint);
// 線を引くだけ(塗りつぶさない)
paint.setStyle(Paint.Style.STROKE);
canvas.drawRect(30, 90, 60, 120, paint);
// 線を引いて、かつ塗りつぶす
paint.setStyle(Paint.Style.FILL_AND_STROKE);
canvas.drawRect(90, 90, 120, 120, paint);
}
use of android.graphics.RectF in project AndroidSDK-RecipeBook by gabu.
the class CanvasView method drawOval.
private void drawOval(Canvas canvas) {
Paint paint = new Paint();
paint.setColor(Color.WHITE);
paint.setAntiAlias(true);
RectF rect = new RectF(30, 30, 90, 60);
canvas.drawOval(rect, paint);
RectF rect2 = new RectF(120, 30, 150, 90);
canvas.drawOval(rect2, paint);
}
use of android.graphics.RectF in project fresco by facebook.
the class ScaleTypeDrawableTest method testConfigureBounds_FOCUS_CROP_VC.
/**
* Underlying drawable's aspect ratio is smaller than view's, so it has to be slided vertically
* after scaling. Focus point is at 40% and it can be completely centered.
*/
@Test
public void testConfigureBounds_FOCUS_CROP_VC() {
Rect bounds = new Rect(10, 10, 410, 310);
int width = 200;
int height = 300;
PointF focusPoint = new PointF(0.5f, 0.4f);
Matrix expectedMatrix = new Matrix();
expectedMatrix.setScale(2.0f, 2.0f);
expectedMatrix.postTranslate(10, -79);
testConfigureBounds(bounds, width, height, ScaleType.FOCUS_CROP, focusPoint, expectedMatrix);
// expected bounds of the actual image after the scaling has been performed (without cropping)
testActualImageBounds(new RectF(10f, -79f, 410f, 521f));
}
use of android.graphics.RectF in project XobotOS by xamarin.
the class View method getHitRect.
/**
* Hit rectangle in parent's coordinates
*
* @param outRect The hit rectangle of the view.
*/
public void getHitRect(Rect outRect) {
updateMatrix();
final TransformationInfo info = mTransformationInfo;
if (info == null || info.mMatrixIsIdentity || mAttachInfo == null) {
outRect.set(mLeft, mTop, mRight, mBottom);
} else {
final RectF tmpRect = mAttachInfo.mTmpTransformRect;
tmpRect.set(-info.mPivotX, -info.mPivotY, getWidth() - info.mPivotX, getHeight() - info.mPivotY);
info.mMatrix.mapRect(tmpRect);
outRect.set((int) tmpRect.left + mLeft, (int) tmpRect.top + mTop, (int) tmpRect.right + mLeft, (int) tmpRect.bottom + mTop);
}
}
use of android.graphics.RectF in project Hummingbird-for-Android by xiprox.
the class DefaultOnDoubleTapListener method onSingleTapConfirmed.
@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
if (this.photoViewAttacher == null)
return false;
ImageView imageView = photoViewAttacher.getImageView();
if (null != photoViewAttacher.getOnPhotoTapListener()) {
final RectF displayRect = photoViewAttacher.getDisplayRect();
if (null != displayRect) {
final float x = e.getX(), y = e.getY();
// Check to see if the user tapped on the photo
if (displayRect.contains(x, y)) {
float xResult = (x - displayRect.left) / displayRect.width();
float yResult = (y - displayRect.top) / displayRect.height();
photoViewAttacher.getOnPhotoTapListener().onPhotoTap(imageView, xResult, yResult);
return true;
}
}
}
if (null != photoViewAttacher.getOnViewTapListener()) {
photoViewAttacher.getOnViewTapListener().onViewTap(imageView, e.getX(), e.getY());
}
return false;
}
Aggregations