private Path CreateProgressPath(float progress, float circleRadius, RectF progressRect)
        {
            RectF arcProgressRect  = new RectF(progressRect.Left, progressRect.Top, progressRect.Left + circleRadius * 2, progressRect.Bottom);
            RectF rectProgressRect = null;

            float progressWidth     = progress * progressRect.Width();
            float progressModeWidth = mMode == MODE_LEAF_COUNT ? (float)mCurrentLeafCount / (float)LEAF_COUNT * progressRect.Width() : progress *progressRect.Width();

            float swipeAngle = DEGREE_180;

            //the Left half circle of the progressbar
            if (progressModeWidth < circleRadius)
            {
                swipeAngle = progressModeWidth / circleRadius * DEGREE_180;
            }

            //the center rect of the progressbar
            if (progressModeWidth < progressRect.Width() - circleRadius && progressModeWidth >= circleRadius)
            {
                rectProgressRect = new RectF(progressRect.Left + circleRadius, progressRect.Top, progressRect.Left + progressModeWidth, progressRect.Bottom);
            }

            //the Right half circle of the progressbar
            if (progressWidth >= progressRect.Width() - circleRadius)
            {
                rectProgressRect = new RectF(progressRect.Left + circleRadius, progressRect.Top, progressRect.Right - circleRadius, progressRect.Bottom);
                mScale           = (progressRect.Width() - progressWidth) / circleRadius;
            }

            //the Left of the Right half circle
            if (progressWidth < progressRect.Width() - circleRadius)
            {
                mRotation = (progressWidth / (progressRect.Width() - circleRadius)) * FULL_GROUP_ROTATION % DEGREE_360;

                RectF leafRect = new RectF(progressRect.Left + progressWidth, progressRect.Top, progressRect.Right - circleRadius, progressRect.Bottom);
                AddLeaf(progress, leafRect);
            }

            Path path = new Path();

            path.AddArc(arcProgressRect, DEGREE_180 - swipeAngle / 2, swipeAngle);

            if (rectProgressRect != null)
            {
                path.AddRect(rectProgressRect, Path.Direction.Cw);
            }

            return(path);
        }
예제 #2
0
        private Path CreateRiverPath(RectF arcBounds)
        {
            if (mRiverPath != null)
            {
                return(mRiverPath);
            }

            mRiverPath = new Path();

            RectF rectF = new RectF(arcBounds.CenterX() - mRiverWidth / 2.0f, arcBounds.CenterY() - mRiverHeight / 2.0f, arcBounds.CenterX() + mRiverWidth / 2.0f, arcBounds.CenterY() + mRiverHeight / 2.0f);

            rectF.Inset(mRiverBankWidth / 2.0f, mRiverBankWidth / 2.0f);

            mRiverPath.AddRect(rectF, Path.Direction.Cw);

            return(mRiverPath);
        }