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));
        }
Example #2
0
        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));
        }