Search in sources :

Example 81 with RectF

use of android.graphics.RectF in project XobotOS by xamarin.

the class RoundRectShape method onResize.

@Override
protected void onResize(float w, float h) {
    super.onResize(w, h);
    RectF r = rect();
    mPath.reset();
    if (mOuterRadii != null) {
        mPath.addRoundRect(r, mOuterRadii, Path.Direction.CW);
    } else {
        mPath.addRect(r, Path.Direction.CW);
    }
    if (mInnerRect != null) {
        mInnerRect.set(r.left + mInset.left, r.top + mInset.top, r.right - mInset.right, r.bottom - mInset.bottom);
        if (mInnerRect.width() < w && mInnerRect.height() < h) {
            if (mInnerRadii != null) {
                mPath.addRoundRect(mInnerRect, mInnerRadii, Path.Direction.CCW);
            } else {
                mPath.addRect(mInnerRect, Path.Direction.CCW);
            }
        }
    }
}
Also used : RectF(android.graphics.RectF)

Example 82 with RectF

use of android.graphics.RectF in project XobotOS by xamarin.

the class GestureOverlayView method setGesture.

public void setGesture(Gesture gesture) {
    if (mCurrentGesture != null) {
        clear(false);
    }
    setCurrentColor(mCertainGestureColor);
    mCurrentGesture = gesture;
    final Path path = mCurrentGesture.toPath();
    final RectF bounds = new RectF();
    path.computeBounds(bounds, true);
    // TODO: The path should also be scaled to fit inside this view
    mPath.rewind();
    mPath.addPath(path, -bounds.left + (getWidth() - bounds.width()) / 2.0f, -bounds.top + (getHeight() - bounds.height()) / 2.0f);
    mResetGesture = true;
    invalidate();
}
Also used : Path(android.graphics.Path) RectF(android.graphics.RectF)

Example 83 with RectF

use of android.graphics.RectF in project XobotOS by xamarin.

the class Animation method clone.

@Override
protected Animation clone() throws CloneNotSupportedException {
    final Animation animation = (Animation) super.clone();
    animation.mPreviousRegion = new RectF();
    animation.mRegion = new RectF();
    animation.mTransformation = new Transformation();
    animation.mPreviousTransformation = new Transformation();
    return animation;
}
Also used : RectF(android.graphics.RectF)

Example 84 with RectF

use of android.graphics.RectF in project XobotOS by xamarin.

the class Animation method initializeInvalidateRegion.

/**
     * @param left
     * @param top
     * @param right
     * @param bottom
     *
     * @hide
     */
public void initializeInvalidateRegion(int left, int top, int right, int bottom) {
    final RectF region = mPreviousRegion;
    region.set(left, top, right, bottom);
    // Enlarge the invalidate region to account for rounding errors
    region.inset(-1.0f, -1.0f);
    if (mFillBefore) {
        final Transformation previousTransformation = mPreviousTransformation;
        applyTransformation(mInterpolator.getInterpolation(0.0f), previousTransformation);
    }
}
Also used : RectF(android.graphics.RectF)

Example 85 with RectF

use of android.graphics.RectF in project CloudReader by youlookwhat.

the class PhotoViewAttacher method updateBaseMatrix.

/**
     * Calculate Matrix for FIT_CENTER
     *
     * @param d - Drawable being displayed
     */
private void updateBaseMatrix(Drawable d) {
    ImageView imageView = getImageView();
    if (null == imageView || null == d) {
        return;
    }
    final float viewWidth = getImageViewWidth(imageView);
    final float viewHeight = getImageViewHeight(imageView);
    final int drawableWidth = d.getIntrinsicWidth();
    final int drawableHeight = d.getIntrinsicHeight();
    mBaseMatrix.reset();
    final float widthScale = viewWidth / drawableWidth;
    final float heightScale = viewHeight / drawableHeight;
    if (mScaleType == ScaleType.CENTER) {
        mBaseMatrix.postTranslate((viewWidth - drawableWidth) / 2F, (viewHeight - drawableHeight) / 2F);
    } else if (mScaleType == ScaleType.CENTER_CROP) {
        float scale = Math.max(widthScale, heightScale);
        mBaseMatrix.postScale(scale, scale);
        //            mBaseMatrix.postTranslate((viewWidth - drawableWidth * scale) / 2F,
        //                    (viewHeight - drawableHeight * scale) / 2F);
        //需求改变,高度设为0;
        mBaseMatrix.postTranslate((viewWidth - drawableWidth * scale) / 2F, 0);
    } else if (mScaleType == ScaleType.CENTER_INSIDE) {
        float scale = Math.min(1.0f, Math.min(widthScale, heightScale));
        mBaseMatrix.postScale(scale, scale);
        mBaseMatrix.postTranslate((viewWidth - drawableWidth * scale) / 2F, (viewHeight - drawableHeight * scale) / 2F);
    } else {
        RectF mTempSrc = new RectF(0, 0, drawableWidth, drawableHeight);
        RectF mTempDst = new RectF(0, 0, viewWidth, viewHeight);
        if ((int) mBaseRotation % 180 != 0) {
            mTempSrc = new RectF(0, 0, drawableHeight, drawableWidth);
        }
        switch(mScaleType) {
            case FIT_CENTER:
                mBaseMatrix.setRectToRect(mTempSrc, mTempDst, ScaleToFit.CENTER);
                break;
            case FIT_START:
                mBaseMatrix.setRectToRect(mTempSrc, mTempDst, ScaleToFit.START);
                break;
            case FIT_END:
                mBaseMatrix.setRectToRect(mTempSrc, mTempDst, ScaleToFit.END);
                break;
            case FIT_XY:
                mBaseMatrix.setRectToRect(mTempSrc, mTempDst, ScaleToFit.FILL);
                break;
            default:
                break;
        }
    }
    resetMatrix();
}
Also used : RectF(android.graphics.RectF) ImageView(android.widget.ImageView) SuppressLint(android.annotation.SuppressLint)

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