protected internal override void ComputeRender(float renderProgress) { if (mCurrentBounds.IsEmpty) { return; } if (mMotherMovePath.IsEmpty) { mMotherMovePath.Set(CreateMotherMovePath()); mMotherMovePathMeasure.SetPath(mMotherMovePath, false); mChildMovePath.Set(CreateChildMovePath()); mChildMovePathMeasure.SetPath(mChildMovePath, false); } //mother oval float motherMoveProgress = MOTHER_MOVE_INTERPOLATOR.GetInterpolation(renderProgress); mMotherMovePathMeasure.GetPosTan(GetCurrentMotherMoveLength(motherMoveProgress), mMotherPosition, null); mMotherOvalHalfWidth = mMaxMotherOvalSize; mMotherOvalHalfHeight = mMaxMotherOvalSize * GetMotherShapeFactor(motherMoveProgress); //child Oval float childMoveProgress = CHILD_MOVE_INTERPOLATOR.GetInterpolation(renderProgress); mChildMovePathMeasure.GetPosTan(GetCurrentChildMoveLength(childMoveProgress), mChildPosition, null); SetupChildParams(childMoveProgress); mRotateDegrees = (int)(DensityUtil.Radian2Degrees(Math.Atan((mMotherPosition[1] - mChildPosition[1]) / (mMotherPosition[0] - mChildPosition[0])))); mRevealCircleRadius = GetCurrentRevealCircleRadius(renderProgress); mCurrentOvalColor = GetCurrentOvalColor(renderProgress); mCurrentBackgroundColor = GetCurrentBackgroundColor(renderProgress); }
private float GetRestLength(Path path, float startD) { Path tempPath = new Path(); PathMeasure pathMeasure = new PathMeasure(path, false); pathMeasure.GetSegment(startD, pathMeasure.Length, tempPath, true); pathMeasure.SetPath(tempPath, false); return(pathMeasure.Length); }
internal static void ApplyTrimPathIfNeeded(Path path, float startValue, float endValue, float offsetValue) { LottieLog.BeginSection("applyTrimPathIfNeeded"); PathMeasure.SetPath(path); var length = PathMeasure.Length; if (startValue == 1f && endValue == 0f) { LottieLog.EndSection("applyTrimPathIfNeeded"); return; } if (length < 1f || Math.Abs(endValue - startValue - 1) < .01) { LottieLog.EndSection("applyTrimPathIfNeeded"); return; } var start = length * startValue; var end = length * endValue; var newStart = Math.Min(start, end); var newEnd = Math.Max(start, end); var offset = offsetValue * length; newStart += offset; newEnd += offset; // If the trim path has rotated around the path, we need to shift it back. if (newStart >= length && newEnd >= length) { newStart = MiscUtils.FloorMod(newStart, length); newEnd = MiscUtils.FloorMod(newEnd, length); } if (newStart < 0) { newStart = MiscUtils.FloorMod(newStart, length); } if (newEnd < 0) { newEnd = MiscUtils.FloorMod(newEnd, length); } // If the start and end are equals, return an empty path. if (newStart == newEnd) { path.Reset(); LottieLog.EndSection("applyTrimPathIfNeeded"); return; } if (newStart >= newEnd) { newStart -= length; } _tempPath.Reset(); PathMeasure.GetSegment(newStart, newEnd, ref _tempPath, true); if (newEnd > length) { _tempPath2.Reset(); PathMeasure.GetSegment(0, newEnd % length, ref _tempPath2, true); _tempPath.AddPath(_tempPath2); } else if (newStart < 0) { _tempPath2.Reset(); PathMeasure.GetSegment(length + newStart, length, ref _tempPath2, true); _tempPath.AddPath(_tempPath2); } path.Set(_tempPath); LottieLog.EndSection("applyTrimPathIfNeeded"); }