예제 #1
0
        protected override 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.Color       = new Color(mColor);
            mPaint.StrokeWidth = 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.Color = new Color(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.StrokeWidth = centerRingWidth;
                canvas.DrawArc(mTempBounds, RING_START_ANGLE, mRotation, false, mPaint);
            }

            mPaint.Color = new Color(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);
        }
예제 #2
0
        protected override void Draw(Canvas canvas, Rect bounds)
        {
            int saveCount = canvas.Save();

            mTempBounds.Set(Bounds);
            mTempBounds.Inset(mStrokeInset, mStrokeInset);
            mTempBounds.Inset(mTempBounds.Width() * (1.0f - mScale) / 2.0f, mTempBounds.Width() * (1.0f - mScale) / 2.0f);

            canvas.Rotate(mGroupRotation, mTempBounds.CenterX(), mTempBounds.CenterY());

            mPaint.Color       = new Color(mColor);
            mPaint.Alpha       = (int)(MAX_ALPHA * mScale);
            mPaint.StrokeWidth = mStrokeWidth * mScale;

            if (mSwipeDegrees != 0)
            {
                for (int i = 0; i < mGearCount; i++)
                {
                    canvas.DrawArc(mTempBounds, mStartDegrees + DEGREE_360 / mGearCount * i, mSwipeDegrees, false, mPaint);
                }
            }

            canvas.RestoreToCount(saveCount);
        }
예제 #3
0
        protected override void Draw(Canvas canvas, Rect bounds)
        {
            int saveCount = canvas.Save();

            mTempBounds.Set(Bounds);
            mTempBounds.Inset(mStrokeInset, mStrokeInset);

            canvas.Rotate(mGroupRotation, mTempBounds.CenterX(), mTempBounds.CenterY());

            if (mSwipeDegrees != 0)
            {
                mPaint.Color = new Color(mCurrentColor);
                canvas.DrawArc(mTempBounds, mStartDegrees, mSwipeDegrees, false, mPaint);
            }

            canvas.RestoreToCount(saveCount);
        }
예제 #4
0
        protected override void Draw(Canvas canvas, Rect bounds)
        {
            RectF arcBounds = mTempBounds;

            arcBounds.Set(bounds);
            arcBounds.Inset(mStrokeInset, mStrokeInset);
            mCurrentBounds.Set(arcBounds);

            int saveCount = canvas.Save();

            //draw circle trim
            float startAngle = (mStartTrim + mRotation) * 360;
            float endAngle   = (mEndTrim + mRotation) * 360;
            float sweepAngle = endAngle - startAngle;

            if (sweepAngle != 0)
            {
                mPaint.Color = new Color(mColor);
                mPaint.SetStyle(Paint.Style.Stroke);
                canvas.DrawArc(arcBounds, startAngle, sweepAngle, false, mPaint);
            }

            //draw water wave
            if (mWaveProgress < 1.0f)
            {
                var nColor = new Color(mColor);


                mPaint.Color = Color.Argb((int)(Color.GetAlphaComponent(mColor) * (1.0f - mWaveProgress)), Color.GetRedComponent(mColor), Color.GetGreenComponent(mColor), Color.GetBlueComponent(mColor));

                mPaint.SetStyle(Paint.Style.Stroke);
                float radius = Math.Min(arcBounds.Width(), arcBounds.Height()) / 2.0f;
                canvas.DrawCircle(arcBounds.CenterX(), arcBounds.CenterY(), radius * (1.0f + mWaveProgress), mPaint);
            }
            //draw ball bounce
            if (mPathMeasure != null)
            {
                mPaint.Color = new Color(mBallColor);
                mPaint.SetStyle(Paint.Style.Fill);
                canvas.DrawCircle(mCurrentPosition[0], mCurrentPosition[1], mSkipBallSize * mScale, mPaint);
            }

            canvas.RestoreToCount(saveCount);
        }
예제 #5
0
        protected override void Draw(Canvas canvas, Rect bounds)
        {
            int saveCount = canvas.Save();

            mTempBounds.Set(Bounds);
            mTempBounds.Inset(mStrokeInset, mStrokeInset);
            canvas.Rotate(mGroupRotation, mTempBounds.CenterX(), mTempBounds.CenterY());

            for (int i = 0; i < 3; i++)
            {
                if (mLevelSwipeDegrees[i] != 0)
                {
                    mPaint.Color = new Color(mLevelColors[i]);
                    canvas.DrawArc(mTempBounds, mEndDegrees, mLevelSwipeDegrees[i], false, mPaint);
                }
            }

            canvas.RestoreToCount(saveCount);
        }
예제 #6
0
        protected override void Draw(Canvas canvas, Rect bounds)
        {
            int saveCount = canvas.Save();

            mTempBounds.Set(Bounds);
            mTempBounds.Inset(mStrokeInSet, mStrokeInSet);

            canvas.Rotate(mGroupRotation, mTempBounds.CenterX(), mTempBounds.CenterY());

            if (mSwipeDegrees != 0)
            {
                for (int i = 0; i < mColors.Length; i++)
                {
                    mPaint.StrokeWidth = mStrokeWidth / (i + 1);
                    mPaint.Color       = new Color(mColors[i]);
                    canvas.DrawArc(CreateArcBounds(mTempBounds, i), mStartDegrees + DEGREE_180 * (i % 2), mSwipeDegrees, false, mPaint);
                }
            }

            canvas.RestoreToCount(saveCount);
        }
예제 #7
0
        // Grows the cropping rectange by (dx, dy) in image space.
        private void growBy(float dx, float dy)
        {
            if (maintainAspectRatio)
            {
                if (dx != 0)
                {
                    dy = dx / initialAspectRatio;
                }
                else if (dy != 0)
                {
                    dx = dy * initialAspectRatio;
                }
            }

            // Don't let the cropping rectangle grow too fast.
            // Grow at most half of the difference between the image rectangle and
            // the cropping rectangle.
            RectF r = new RectF(cropRect);
            if (dx > 0F && r.Width() + 2 * dx > imageRect.Width())
            {
                float adjustment = (imageRect.Width() - r.Width()) / 2F;
                dx = adjustment;
                if (maintainAspectRatio)
                {
                    dy = dx / initialAspectRatio;
                }
            }
            if (dy > 0F && r.Height() + 2 * dy > imageRect.Height())
            {
                float adjustment = (imageRect.Height() - r.Height()) / 2F;
                dy = adjustment;
                if (maintainAspectRatio)
                {
                    dx = dy * initialAspectRatio;
                }
            }

            r.Inset(-dx, -dy);

            // Don't let the cropping rectangle shrink too fast.
            float widthCap = 25F;
            if (r.Width() < widthCap)
            {
                r.Inset(-(widthCap - r.Width()) / 2F, 0F);
            }
            float heightCap = maintainAspectRatio
                ? (widthCap / initialAspectRatio)
                    : widthCap;
            if (r.Height() < heightCap)
            {
                r.Inset(0F, -(heightCap - r.Height()) / 2F);
            }

            // Put the cropping rectangle inside the image rectangle.
            if (r.Left < imageRect.Left)
            {
                r.Offset(imageRect.Left - r.Left, 0F);
            }
            else if (r.Right > imageRect.Right)
            {
                r.Offset(-(r.Right - imageRect.Right), 0);
            }
            if (r.Top < imageRect.Top)
            {
                r.Offset(0F, imageRect.Top - r.Top);
            }
            else if (r.Bottom > imageRect.Bottom)
            {
                r.Offset(0F, -(r.Bottom - imageRect.Bottom));
            }

            cropRect.Set(r);
            DrawRect = computeLayout();
            context.Invalidate();
        }