Search in sources :

Example 26 with RectF

use of android.graphics.RectF in project LoadingDrawable by dinuscxj.

the class GhostsEyeLoadingRenderer method draw.

@Override
protected void draw(Canvas canvas, Rect bounds) {
    int saveCount = canvas.save();
    RectF arcBounds = mTempBounds;
    arcBounds.set(bounds);
    mPaint.setColor(mColor);
    mPaint.setStyle(Paint.Style.STROKE);
    canvas.drawPath(createLeftEyeCircle(arcBounds, mLeftEyeCircleOffsetY), mPaint);
    canvas.drawPath(createRightEyeCircle(arcBounds, mRightEyeCircleOffsetY), mPaint);
    mPaint.setStyle(Paint.Style.FILL);
    //create left eye ball
    canvas.drawOval(createLeftEyeBall(arcBounds, mLeftEyeBallOffsetY), mPaint);
    //create right eye ball
    canvas.drawOval(createRightEyeBall(arcBounds, mRightEyeBallOffsetY), mPaint);
    canvas.restoreToCount(saveCount);
}
Also used : RectF(android.graphics.RectF) Paint(android.graphics.Paint)

Example 27 with RectF

use of android.graphics.RectF in project LoadingDrawable by dinuscxj.

the class GhostsEyeLoadingRenderer method createLeftEyeBall.

private RectF createLeftEyeBall(RectF arcBounds, float offsetY) {
    //the center of the left eye
    float leftEyeCenterX = arcBounds.centerX() - mEyeInterval / 2.0f - mEyeCircleRadius;
    float leftEyeCenterY = arcBounds.centerY() - mEyeBallOffsetY + offsetY;
    RectF rectF = new RectF(leftEyeCenterX - mEyeBallWidth / 2.0f, leftEyeCenterY - mEyeBallHeight / 2.0f, leftEyeCenterX + mEyeBallWidth / 2.0f, leftEyeCenterY + mEyeBallHeight / 2.0f);
    return rectF;
}
Also used : RectF(android.graphics.RectF)

Example 28 with RectF

use of android.graphics.RectF in project LoadingDrawable by dinuscxj.

the class DanceLoadingRenderer method draw.

@Override
protected void draw(Canvas canvas, Rect bounds) {
    int saveCount = canvas.save();
    mTempBounds.set(bounds);
    mTempBounds.inset(mStrokeInset, mStrokeInset);
    mCurrentBounds.set(mTempBounds);
    float outerCircleRadius = Math.min(mTempBounds.height(), mTempBounds.width()) / 2.0f;
    float interCircleRadius = outerCircleRadius / 2.0f;
    float centerRingWidth = interCircleRadius - mStrokeWidth / 2;
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setColor(mColor);
    mPaint.setStrokeWidth(mStrokeWidth);
    canvas.drawCircle(mTempBounds.centerX(), mTempBounds.centerY(), outerCircleRadius, mPaint);
    mPaint.setStyle(Paint.Style.FILL);
    canvas.drawCircle(mTempBounds.centerX(), mTempBounds.centerY(), interCircleRadius * mScale, mPaint);
    if (mRotation != 0) {
        mPaint.setColor(mArcColor);
        mPaint.setStyle(Paint.Style.STROKE);
        //strokeWidth / 2.0f + mStrokeWidth / 2.0f is the center of the inter circle width
        mTempBounds.inset(centerRingWidth / 2.0f + mStrokeWidth / 2.0f, centerRingWidth / 2.0f + mStrokeWidth / 2.0f);
        mPaint.setStrokeWidth(centerRingWidth);
        canvas.drawArc(mTempBounds, RING_START_ANGLE, mRotation, false, mPaint);
    }
    mPaint.setColor(mColor);
    mPaint.setStyle(Paint.Style.FILL);
    for (int i = 0; i < NUM_POINTS; i++) {
        canvas.rotate(i * DANCE_INTERVAL_ANGLE, POINT_X[i], POINT_Y[i]);
        RectF rectF = new RectF(POINT_X[i] - mDanceBallRadius - mShapeChangeWidth / 2.0f, POINT_Y[i] - mDanceBallRadius - mShapeChangeHeight / 2.0f, POINT_X[i] + mDanceBallRadius + mShapeChangeWidth / 2.0f, POINT_Y[i] + mDanceBallRadius + mShapeChangeHeight / 2.0f);
        canvas.drawOval(rectF, mPaint);
        canvas.rotate(-i * DANCE_INTERVAL_ANGLE, POINT_X[i], POINT_Y[i]);
    }
    canvas.restoreToCount(saveCount);
}
Also used : RectF(android.graphics.RectF) Paint(android.graphics.Paint)

Example 29 with RectF

use of android.graphics.RectF in project LoadingDrawable by dinuscxj.

the class CoolWaitLoadingRenderer method draw.

@Override
protected void draw(Canvas canvas, Rect bounds) {
    int saveCount = canvas.save();
    RectF arcBounds = mCurrentBounds;
    arcBounds.set(bounds);
    mPaint.setColor(mBottomColor);
    canvas.drawPath(mCurrentBottomWaitPath, mPaint);
    mPaint.setColor(mMiddleColor);
    canvas.drawPath(mCurrentMiddleWaitPath, mPaint);
    mPaint.setColor(mTopColor);
    canvas.drawPath(mCurrentTopWaitPath, mPaint);
    canvas.restoreToCount(saveCount);
}
Also used : RectF(android.graphics.RectF) Paint(android.graphics.Paint)

Example 30 with RectF

use of android.graphics.RectF in project LoadingDrawable by dinuscxj.

the class CoolWaitLoadingRenderer method createWaitPath.

private Path createWaitPath(RectF bounds) {
    Path path = new Path();
    //create circle
    path.moveTo(bounds.centerX() + mWaitCircleRadius, bounds.centerY());
    //create w
    path.cubicTo(bounds.centerX() + mWaitCircleRadius, bounds.centerY() - mWaitCircleRadius * 0.5f, bounds.centerX() + mWaitCircleRadius * 0.3f, bounds.centerY() - mWaitCircleRadius, bounds.centerX() - mWaitCircleRadius * 0.35f, bounds.centerY() + mWaitCircleRadius * 0.5f);
    path.quadTo(bounds.centerX() + mWaitCircleRadius, bounds.centerY() - mWaitCircleRadius, bounds.centerX() + mWaitCircleRadius * 0.05f, bounds.centerY() + mWaitCircleRadius * 0.5f);
    path.lineTo(bounds.centerX() + mWaitCircleRadius * 0.75f, bounds.centerY() - mWaitCircleRadius * 0.2f);
    path.cubicTo(bounds.centerX(), bounds.centerY() + mWaitCircleRadius * 1f, bounds.centerX() + mWaitCircleRadius, bounds.centerY() + mWaitCircleRadius * 0.4f, bounds.centerX() + mWaitCircleRadius, bounds.centerY());
    //create arc
    path.arcTo(new RectF(bounds.centerX() - mWaitCircleRadius, bounds.centerY() - mWaitCircleRadius, bounds.centerX() + mWaitCircleRadius, bounds.centerY() + mWaitCircleRadius), 0, -359);
    path.arcTo(new RectF(bounds.centerX() - mWaitCircleRadius, bounds.centerY() - mWaitCircleRadius, bounds.centerX() + mWaitCircleRadius, bounds.centerY() + mWaitCircleRadius), 1, -359);
    path.arcTo(new RectF(bounds.centerX() - mWaitCircleRadius, bounds.centerY() - mWaitCircleRadius, bounds.centerX() + mWaitCircleRadius, bounds.centerY() + mWaitCircleRadius), 2, -2);
    //create w
    path.cubicTo(bounds.centerX() + mWaitCircleRadius, bounds.centerY() - mWaitCircleRadius * 0.5f, bounds.centerX() + mWaitCircleRadius * 0.3f, bounds.centerY() - mWaitCircleRadius, bounds.centerX() - mWaitCircleRadius * 0.35f, bounds.centerY() + mWaitCircleRadius * 0.5f);
    path.quadTo(bounds.centerX() + mWaitCircleRadius, bounds.centerY() - mWaitCircleRadius, bounds.centerX() + mWaitCircleRadius * 0.05f, bounds.centerY() + mWaitCircleRadius * 0.5f);
    path.lineTo(bounds.centerX() + mWaitCircleRadius * 0.75f, bounds.centerY() - mWaitCircleRadius * 0.2f);
    path.cubicTo(bounds.centerX(), bounds.centerY() + mWaitCircleRadius * 1f, bounds.centerX() + mWaitCircleRadius, bounds.centerY() + mWaitCircleRadius * 0.4f, bounds.centerX() + mWaitCircleRadius, bounds.centerY());
    return path;
}
Also used : Path(android.graphics.Path) RectF(android.graphics.RectF)

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