Search in sources :

Example 36 with RectF

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

the class RotaryView method Init.

public void Init() {
    dp = getResources().getDimension(R.dimen.triangle_dp);
    bitmapScale = BitmapFactory.decodeResource(getResources(), R.drawable.triangle_icon_round_calibration);
    brWidth = bitmapScale.getWidth();
    brHeight = bitmapScale.getHeight();
    WidthCenter = getWidth() / 2;
    HeightCenter = getHeight() / 2;
    zoom(0f);
    rectf = new RectF();
    rectf.set(dp * 0.1f, dp * 0.1f, getWidth() - dp * 0.1f, getHeight() - dp * 0.1f);
}
Also used : RectF(android.graphics.RectF)

Example 37 with RectF

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

the class ArcDrawable method onBoundsChange.

@Override
protected void onBoundsChange(Rect bounds) {
    super.onBoundsChange(bounds);
    mWidth = dp2px(40);
    mHeight = mWidth;
    mBounds = new RectF(bounds.width() / 2 - mWidth / 2, bounds.top, bounds.width() / 2 + mWidth / 2, bounds.top + mHeight);
}
Also used : RectF(android.graphics.RectF)

Example 38 with RectF

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

the class RingDrawable method onBoundsChange.

@Override
protected void onBoundsChange(Rect bounds) {
    super.onBoundsChange(bounds);
    mWidth = getRefreshLayout().getFinalOffset();
    mHeight = mWidth;
    mBounds = new RectF(bounds.width() / 2 - mWidth / 2, bounds.top, bounds.width() / 2 + mWidth / 2, bounds.top + mHeight);
    mBounds.inset(dp2px(15), dp2px(15));
}
Also used : RectF(android.graphics.RectF)

Example 39 with RectF

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

the class ProgressWheel method setupBounds.

/**
     * Set the bounds of the component
     */
private void setupBounds() {
    // Width should equal to Height, find the min value to steup the circle
    int minValue = Math.min(layout_width, layout_height);
    // Calc the Offset if needed
    int xOffset = layout_width - minValue;
    int yOffset = layout_height - minValue;
    // Add the offset
    paddingTop = this.getPaddingTop() + (yOffset / 2);
    paddingBottom = this.getPaddingBottom() + (yOffset / 2);
    paddingLeft = this.getPaddingLeft() + (xOffset / 2);
    paddingRight = this.getPaddingRight() + (xOffset / 2);
    //this.getLayoutParams().width;
    int width = getWidth();
    //this.getLayoutParams().height;
    int height = getHeight();
    rectBounds = new RectF(paddingLeft, paddingTop, width - paddingRight, height - paddingBottom);
    circleBounds = new RectF(paddingLeft + barWidth, paddingTop + barWidth, width - paddingRight - barWidth, height - paddingBottom - barWidth);
    circleInnerContour = new RectF(circleBounds.left + (rimWidth / 2.0f) + (contourSize / 2.0f), circleBounds.top + (rimWidth / 2.0f) + (contourSize / 2.0f), circleBounds.right - (rimWidth / 2.0f) - (contourSize / 2.0f), circleBounds.bottom - (rimWidth / 2.0f) - (contourSize / 2.0f));
    circleOuterContour = new RectF(circleBounds.left - (rimWidth / 2.0f) - (contourSize / 2.0f), circleBounds.top - (rimWidth / 2.0f) - (contourSize / 2.0f), circleBounds.right + (rimWidth / 2.0f) + (contourSize / 2.0f), circleBounds.bottom + (rimWidth / 2.0f) + (contourSize / 2.0f));
    fullRadius = (width - paddingRight - barWidth) / 2;
    circleRadius = (fullRadius - barWidth) + 1;
}
Also used : RectF(android.graphics.RectF) Paint(android.graphics.Paint)

Example 40 with RectF

use of android.graphics.RectF in project Depth-LIB-Android- by danielzeller.

the class CustomShadow method buildShadowCorners.

private void buildShadowCorners() {
    RectF innerBounds = new RectF(-mCornerRadius, -mCornerRadius, mCornerRadius, mCornerRadius);
    RectF outerBounds = new RectF(innerBounds);
    outerBounds.inset(-mShadowSize, -mShadowSize);
    if (mCornerShadowPath == null) {
        mCornerShadowPath = new Path();
    } else {
        mCornerShadowPath.reset();
    }
    mCornerShadowPath.setFillType(Path.FillType.EVEN_ODD);
    mCornerShadowPath.moveTo(-mCornerRadius, 0);
    mCornerShadowPath.rLineTo(-mShadowSize, 0);
    // outer arc
    mCornerShadowPath.arcTo(outerBounds, 180f, 90f, false);
    // inner arc
    mCornerShadowPath.arcTo(innerBounds, 270f, -90f, false);
    mCornerShadowPath.close();
    float startRatio = mCornerRadius / (mCornerRadius + mShadowSize);
    mCornerShadowPaint.setShader(new RadialGradient(0, 0, mCornerRadius + mShadowSize, new int[] { mShadowStartColor, mShadowStartColor, mShadowEndColor }, new float[] { 0f, startRatio, 1f }, Shader.TileMode.CLAMP));
    // we offset the content shadowSize/2 pixels up to make it more realistic.
    // this is why edge shadow shader has some extra space
    // When drawing bottom edge shadow, we use that extra space.
    mEdgeShadowPaint.setShader(new LinearGradient(0, -mCornerRadius + mShadowSize, 0, -mCornerRadius - mShadowSize, new int[] { mShadowStartColor, mShadowStartColor, mShadowEndColor }, new float[] { 0f, .5f, 1f }, Shader.TileMode.CLAMP));
    mEdgeShadowPaint.setAntiAlias(false);
}
Also used : RectF(android.graphics.RectF) Path(android.graphics.Path) LinearGradient(android.graphics.LinearGradient) RadialGradient(android.graphics.RadialGradient)

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