private Keyframe GetLastKeyframe(long tick)
 => tick > StartTick && Keyframes.Any(x => x.Tick < tick)
         ? Keyframes
 .Where(x => x.Tick < tick)
 .OrderBy(x => Math.Abs(x.Tick - tick))
 .FirstOrDefault()
         : Keyframe.GetDefault(StartTick);
示例#2
0
        void ChangeKeyframeText(SvgWidget widget, object newValue, object delta)
        {
            var cmds = new CompoundCommand();

            foreach (var kf in Keyframes.Where(x => x.Model.Selected.Value))
            {
                cmds.Append(Command.Set(kf.Model.Text, (string)newValue));
            }

            History.Insert(cmds);
        }
示例#3
0
        public override void Nudge(ref CompoundCommand cmds, NudgeDirection direction, float timeDelta, float valueDelta)
        {
            base.Nudge(ref cmds, direction, timeDelta, valueDelta);

            foreach (var kf in Keyframes.Where(x => x.Model.Selected.Value))
            {
                switch (direction)
                {
                case NudgeDirection.Up:
                    var newValue = (float)VMath.Clamp(kf.Model.Value.Value + valueDelta, Model.Minimum.Value, Model.Maximum.Value);
                    cmds.Append(Command.Set(kf.Model.Value, newValue));
                    break;

                case NudgeDirection.Down:
                    newValue = (float)VMath.Clamp(kf.Model.Value.Value - valueDelta, Model.Minimum.Value, Model.Maximum.Value);
                    cmds.Append(Command.Set(kf.Model.Value, newValue));
                    break;
                }
            }
        }
示例#4
0
        public Matrix GetAbsoluteTransformAtTime(float time)
        {
            Matrix parentTransform = Matrix.Identity;

            if (Parent != null)
            {
                parentTransform = Parent.GetAbsoluteTransformAtTime(time);
            }

            Matrix transform = Transform;

            if (Keyframes.Any())
            {
                var framesBefore = Keyframes.Where(x => x.Time < time);
                var framesAfter  = Keyframes.Where(x => x.Time > time);
                var frame1       = framesBefore.Any() ? framesBefore.Last() : Keyframes.First();
                var frame2       = framesAfter.Any() ? framesAfter.First() : Keyframes.Last();

                transform = Matrix.Lerp(frame1.Transform, frame2.Transform, Math.Min((time - frame1.Time) / (float)(frame2.Time - frame1.Time), 1f)) * Transform;
            }

            return(transform * parentTransform);
        }
 private Keyframe GetNextKeyframe(long tick)
 => Keyframes?
 .Where(x => x.Tick >= tick)
 .OrderBy(x => Math.Abs(x.Tick - tick))
 .FirstOrDefault()
 ?? Keyframe.GetDefault(tick);