Search in sources :

Example 71 with RectF

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);
}
Also used : RectF(android.graphics.RectF) Paint(android.graphics.Paint)

Example 72 with RectF

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);
}
Also used : RectF(android.graphics.RectF) Paint(android.graphics.Paint)

Example 73 with RectF

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));
}
Also used : RectF(android.graphics.RectF) Rect(android.graphics.Rect) Matrix(android.graphics.Matrix) PointF(android.graphics.PointF) Test(org.junit.Test)

Example 74 with RectF

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);
    }
}
Also used : RectF(android.graphics.RectF)

Example 75 with RectF

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;
}
Also used : RectF(android.graphics.RectF) ImageView(android.widget.ImageView)

Aggregations

RectF (android.graphics.RectF)1274 Paint (android.graphics.Paint)451 Rect (android.graphics.Rect)178 Matrix (android.graphics.Matrix)155 Bitmap (android.graphics.Bitmap)150 Path (android.graphics.Path)141 Canvas (android.graphics.Canvas)136 Point (android.graphics.Point)86 ImageView (android.widget.ImageView)78 PorterDuffXfermode (android.graphics.PorterDuffXfermode)51 LinearGradient (android.graphics.LinearGradient)41 View (android.view.View)39 SuppressLint (android.annotation.SuppressLint)35 Drawable (android.graphics.drawable.Drawable)27 PointF (android.graphics.PointF)23 RadialGradient (android.graphics.RadialGradient)21 TextPaint (android.text.TextPaint)21 ArrayList (java.util.ArrayList)21 BitmapDrawable (android.graphics.drawable.BitmapDrawable)20 TypedArray (android.content.res.TypedArray)14