private Path CreateWaterPath(RectF waterRect, float progress) { Path path = new Path(); path.MoveTo(waterRect.Left, waterRect.Top); //Similar to the way draw the bottle's Bottom sides float radius = (waterRect.Width() - mStrokeWidth) / 2.0f; float CenterY = waterRect.Bottom - 0.86f * radius; float bottleBottomWidth = waterRect.Width() / 2.0f; RectF bodyRect = new RectF(waterRect.Left, CenterY - radius, waterRect.Right, CenterY + radius); path.AddArc(bodyRect, 187.5f, -67.5f); path.LineTo(waterRect.CenterX() - bottleBottomWidth / 2.0f, waterRect.Bottom); path.LineTo(waterRect.CenterX() + bottleBottomWidth / 2.0f, waterRect.Bottom); path.AddArc(bodyRect, 60, -67.5f); //draw the water waves float cubicXChangeSize = waterRect.Width() * 0.35f * progress; float cubicYChangeSize = waterRect.Height() * 1.2f * progress; path.CubicTo(waterRect.Left + waterRect.Width() * 0.80f - cubicXChangeSize, waterRect.Top - waterRect.Height() * 1.2f + cubicYChangeSize, waterRect.Left + waterRect.Width() * 0.55f - cubicXChangeSize, waterRect.Top - cubicYChangeSize, waterRect.Left, waterRect.Top - mStrokeWidth / 2.0f); path.LineTo(waterRect.Left, waterRect.Top); return(path); }
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); }
private Path CreateBottlePath(RectF bottleRect) { float bottleneckWidth = bottleRect.Width() * 0.3f; float bottleneckHeight = bottleRect.Height() * 0.415f; float bottleneckDecorationWidth = bottleneckWidth * 1.1f; float bottleneckDecorationHeight = bottleneckHeight * 0.167f; Path path = new Path(); //draw the Left side of the bottleneck decoration path.MoveTo(bottleRect.CenterX() - bottleneckDecorationWidth * 0.5f, bottleRect.Top); path.QuadTo(bottleRect.CenterX() - bottleneckDecorationWidth * 0.5f - bottleneckWidth * 0.15f, bottleRect.Top + bottleneckDecorationHeight * 0.5f, bottleRect.CenterX() - bottleneckWidth * 0.5f, bottleRect.Top + bottleneckDecorationHeight); path.LineTo(bottleRect.CenterX() - bottleneckWidth * 0.5f, bottleRect.Top + bottleneckHeight); //draw the Left side of the bottle's body float radius = (bottleRect.Width() - mStrokeWidth) / 2.0f; float CenterY = bottleRect.Bottom - 0.86f * radius; RectF bodyRect = new RectF(bottleRect.Left, CenterY - radius, bottleRect.Right, CenterY + radius); path.AddArc(bodyRect, 255, -135); //draw the Bottom of the bottle float bottleBottomWidth = bottleRect.Width() / 2.0f; path.LineTo(bottleRect.CenterX() - bottleBottomWidth / 2.0f, bottleRect.Bottom); path.LineTo(bottleRect.CenterX() + bottleBottomWidth / 2.0f, bottleRect.Bottom); //draw the Right side of the bottle's body path.AddArc(bodyRect, 60, -135); //draw the Right side of the bottleneck decoration path.LineTo(bottleRect.CenterX() + bottleneckWidth * 0.5f, bottleRect.Top + bottleneckDecorationHeight); path.QuadTo(bottleRect.CenterX() + bottleneckDecorationWidth * 0.5f + bottleneckWidth * 0.15f, bottleRect.Top + bottleneckDecorationHeight * 0.5f, bottleRect.CenterX() + bottleneckDecorationWidth * 0.5f, bottleRect.Top); return(path); }