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);
}
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;
}
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);
}
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);
}
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;
}
Aggregations