public override Vector2?GetValue(Keyframe <Vector2?> keyframe, float keyframeProgress) { var pathKeyframe = (PathKeyframe)keyframe; var path = pathKeyframe.Path; if (path == null || path.Contours.Count == 0) { return(keyframe.StartValue); } if (ValueCallback != null) { return(ValueCallback.GetValueInternal(pathKeyframe.StartFrame.Value, pathKeyframe.EndFrame.Value, pathKeyframe.StartValue, pathKeyframe.EndValue, LinearCurrentKeyframeProgress, keyframeProgress, Progress)); } if (_pathMeasureKeyframe != pathKeyframe) { _pathMeasure?.Dispose(); _pathMeasure = new PathMeasure(path); _pathMeasureKeyframe = pathKeyframe; } return(_pathMeasure.GetPosTan(keyframeProgress * _pathMeasure.Length)); }
public override Vector2?GetValue(Keyframe <Vector2?> keyframe, float keyframeProgress) { var pathKeyframe = (PathKeyframe)keyframe; var path = pathKeyframe.Path; if (path == null || path.IsEmpty) { return(keyframe.StartValue); } if (ValueCallback != null) { var value = ValueCallback.GetValueInternal(pathKeyframe.StartFrame.Value, pathKeyframe.EndFrame.Value, pathKeyframe.StartValue, pathKeyframe.EndValue, LinearCurrentKeyframeProgress, keyframeProgress, Progress); if (value != null) { return(value); } } if (_pathMeasureKeyframe != pathKeyframe) { _pathMeasure?.Dispose(); _pathMeasure = new SKPathMeasure(path); _pathMeasureKeyframe = pathKeyframe; } _pathMeasure.GetPositionAndTangent(keyframeProgress * _pathMeasure.Length, out var pos, out _); return(new Vector2(pos.X, pos.Y)); }
public override Vector2?GetValue(Keyframe <Vector2?> keyframe, float keyframeProgress) { var pathKeyframe = (PathKeyframe)keyframe; var path = pathKeyframe.Path; if (path == null || path.Contours.Count == 0) { return(keyframe.StartValue); } if (_pathMeasureKeyframe != pathKeyframe) { _pathMeasure = new PathMeasure(path); _pathMeasureKeyframe = pathKeyframe; } return(_pathMeasure.GetPosTan(keyframeProgress * _pathMeasure.Length)); }
internal static PathKeyframe NewInstance(JsonObject json, LottieComposition composition, IAnimatableValueFactory <Vector2?> valueFactory) { var keyframe = KeyFrameFactory.NewInstance(json, composition, composition.DpScale, valueFactory); Vector2?cp1 = null; Vector2?cp2 = null; var tiJson = json.GetNamedArray("ti", null); var toJson = json.GetNamedArray("to", null); if (tiJson != null && toJson != null) { cp1 = JsonUtils.PointFromJsonArray(toJson, composition.DpScale); cp2 = JsonUtils.PointFromJsonArray(tiJson, composition.DpScale); } var pathKeyframe = new PathKeyframe(composition, keyframe.StartValue, keyframe.EndValue, keyframe.Interpolator, keyframe.StartFrame, keyframe.EndFrame); var equals = keyframe.EndValue != null && keyframe.StartValue != null && keyframe.StartValue.Equals(keyframe.EndValue); if (pathKeyframe.EndValue != null && !equals) { pathKeyframe._path = Utils.Utils.CreatePath(keyframe.StartValue.Value, keyframe.EndValue.Value, cp1, cp2); } return(pathKeyframe); }