示例#1
0
        public override Vector2?GetValue(IKeyframe <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));
        }
        public override PointF GetValue(IKeyframe <PointF> 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;
            }

            _pathMeasure.GetPosTan(keyframeProgress * _pathMeasure.Length, ref _pos);
            _point.Set(_pos[0], _pos[1]);
            return(_point);
        }
示例#3
0
            internal static PathKeyframe NewInstance(JsonObject json, LottieComposition composition, IAnimatableValueFactory <PointF> valueFactory)
            {
                var    keyframe = KeyFrameFactory.NewInstance(json, composition, composition.DpScale, valueFactory);
                PointF cp1      = null;
                PointF 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.CreatePath(keyframe.StartValue, keyframe.EndValue, cp1, cp2);
                }
                return(pathKeyframe);
            }