Search in sources :

Example 11 with RectF

use of android.graphics.RectF in project Launcher3 by chislon.

the class CropView method getCrop.

public RectF getCrop() {
    final RectF edges = mTempEdges;
    getEdgesHelper(edges);
    final float scale = mRenderer.scale;
    float cropLeft = -edges.left / scale;
    float cropTop = -edges.top / scale;
    float cropRight = cropLeft + getWidth() / scale;
    float cropBottom = cropTop + getHeight() / scale;
    return new RectF(cropLeft, cropTop, cropRight, cropBottom);
}
Also used : RectF(android.graphics.RectF)

Example 12 with RectF

use of android.graphics.RectF in project PhotoView by chrisbanes.

the class PhotoViewAttacher method onTouch.

@Override
public boolean onTouch(View v, MotionEvent ev) {
    boolean handled = false;
    if (mZoomEnabled && Util.hasDrawable((ImageView) v)) {
        switch(ev.getAction()) {
            case MotionEvent.ACTION_DOWN:
                ViewParent parent = v.getParent();
                // event
                if (parent != null) {
                    parent.requestDisallowInterceptTouchEvent(true);
                }
                // If we're flinging, and the user presses down, cancel
                // fling
                cancelFling();
                break;
            case MotionEvent.ACTION_CANCEL:
            case MotionEvent.ACTION_UP:
                // to min scale
                if (getScale() < mMinScale) {
                    RectF rect = getDisplayRect();
                    if (rect != null) {
                        v.post(new AnimatedZoomRunnable(getScale(), mMinScale, rect.centerX(), rect.centerY()));
                        handled = true;
                    }
                }
                break;
        }
        // Try the Scale/Drag detector
        if (mScaleDragDetector != null) {
            boolean wasScaling = mScaleDragDetector.isScaling();
            boolean wasDragging = mScaleDragDetector.isDragging();
            handled = mScaleDragDetector.onTouchEvent(ev);
            boolean didntScale = !wasScaling && !mScaleDragDetector.isScaling();
            boolean didntDrag = !wasDragging && !mScaleDragDetector.isDragging();
            mBlockParentIntercept = didntScale && didntDrag;
        }
        // Check to see if the user double tapped
        if (mGestureDetector != null && mGestureDetector.onTouchEvent(ev)) {
            handled = true;
        }
    }
    return handled;
}
Also used : RectF(android.graphics.RectF) ViewParent(android.view.ViewParent) ImageView(android.widget.ImageView)

Example 13 with RectF

use of android.graphics.RectF in project PhotoPicker by donglua.

the class TouchImageView method getZoomedRect.

/**
   * Return a Rect representing the zoomed image.
   *
   * @return rect representing zoomed image
   */
public RectF getZoomedRect() {
    if (mScaleType == ScaleType.FIT_XY) {
        throw new UnsupportedOperationException("getZoomedRect() not supported with FIT_XY");
    }
    PointF topLeft = transformCoordTouchToBitmap(0, 0, true);
    PointF bottomRight = transformCoordTouchToBitmap(viewWidth, viewHeight, true);
    float w = getDrawable().getIntrinsicWidth();
    float h = getDrawable().getIntrinsicHeight();
    return new RectF(topLeft.x / w, topLeft.y / h, bottomRight.x / w, bottomRight.y / h);
}
Also used : RectF(android.graphics.RectF) PointF(android.graphics.PointF)

Example 14 with RectF

use of android.graphics.RectF in project UltimateAndroid by cymcsg.

the class AnimatorProxy method invalidateAfterUpdate.

private void invalidateAfterUpdate() {
    View view = mView.get();
    if (view == null || view.getParent() == null) {
        return;
    }
    final RectF after = mAfter;
    computeRect(after, view);
    after.union(mBefore);
    ((View) view.getParent()).invalidate((int) Math.floor(after.left), (int) Math.floor(after.top), (int) Math.ceil(after.right), (int) Math.ceil(after.bottom));
}
Also used : RectF(android.graphics.RectF) View(android.view.View)

Example 15 with RectF

use of android.graphics.RectF in project UltimateRecyclerView by cymcsg.

the class CircularImageView method onDraw.

@Override
public void onDraw(Canvas canvas) {
    // Don't draw anything without an image
    if (image == null)
        return;
    // Nothing to draw (Empty bounds)
    if (image.getHeight() == 0 || image.getWidth() == 0)
        return;
    // Update shader if canvas size has changed
    int oldCanvasSize = canvasSize;
    canvasSize = getWidth() < getHeight() ? getWidth() : getHeight();
    if (oldCanvasSize != canvasSize)
        updateBitmapShader();
    // Apply shader to paint
    paint.setShader(shader);
    // Keep track of selectorStroke/border width
    int outerWidth = 0;
    // Get the exact X/Y axis of the view
    int center = canvasSize / 2;
    if (hasSelector && isSelected) {
        // Draw the selector stroke & apply the selector filter, if applicable
        outerWidth = selectorStrokeWidth;
        center = (canvasSize - (outerWidth * 2)) / 2;
        paint.setColorFilter(selectorFilter);
        canvas.drawCircle(center + outerWidth, center + outerWidth, ((canvasSize - (outerWidth * 2)) / 2) + outerWidth - 4.0f, paintSelectorBorder);
    } else if (hasBorder) {
        // If no selector was drawn, draw a border and clear the filter instead... if enabled
        outerWidth = borderWidth;
        center = (canvasSize - (outerWidth * 2)) / 2;
        paint.setColorFilter(null);
        RectF rekt = new RectF(0 + outerWidth / 2, 0 + outerWidth / 2, canvasSize - outerWidth / 2, canvasSize - outerWidth / 2);
        canvas.drawArc(rekt, 360, 360, false, paintBorder);
    //canvas.drawCircle(center + outerWidth, center + outerWidth, ((canvasSize - (outerWidth * 2)) / 2) + outerWidth - 4.0f, paintBorder);
    } else
        // Clear the color filter if no selector nor border were drawn
        paint.setColorFilter(null);
    // Draw the circular image itself
    canvas.drawCircle(center + outerWidth, center + outerWidth, ((canvasSize - (outerWidth * 2)) / 2), paint);
}
Also used : RectF(android.graphics.RectF) Paint(android.graphics.Paint)

Aggregations

RectF (android.graphics.RectF)1216 Paint (android.graphics.Paint)437 Rect (android.graphics.Rect)176 Matrix (android.graphics.Matrix)150 Bitmap (android.graphics.Bitmap)148 Path (android.graphics.Path)140 Canvas (android.graphics.Canvas)134 Point (android.graphics.Point)78 ImageView (android.widget.ImageView)74 PorterDuffXfermode (android.graphics.PorterDuffXfermode)49 View (android.view.View)39 LinearGradient (android.graphics.LinearGradient)38 SuppressLint (android.annotation.SuppressLint)32 Drawable (android.graphics.drawable.Drawable)26 PointF (android.graphics.PointF)21 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