public static IEnumerable <InterpolationFrame> Create(Sequence sequence)
        {
            var spans = new Dictionary <int, List <InterpolationSpan> >();
            var interpolationFrames = new List <InterpolationFrame>();

            foreach (var keyFrame in sequence.KeyFrames.OrderByDescending(x => x.Time))
            {
                var interpolationFrameData = new List <InterpolationSpan>();
                foreach (var lightDataKvp in keyFrame.LightValues)
                {
                    if (!spans.ContainsKey(lightDataKvp.Key))
                    {
                        spans.Add(lightDataKvp.Key, new List <InterpolationSpan>());
                    }

                    var lightKeyFrameData = spans[lightDataKvp.Key];
                    var nextSpan          = lightKeyFrameData.FirstOrDefault();
                    var interpolationSpan = new InterpolationSpan(lightDataKvp.Key,
                                                                  keyFrame.Time,
                                                                  lightDataKvp.Value.Color,
                                                                  lightDataKvp.Value.InterpolationMode,
                                                                  nextSpan);
                    lightKeyFrameData.Insert(0, interpolationSpan);

                    interpolationFrameData.Add(interpolationSpan);
                }

                interpolationFrames.Add(new InterpolationFrame(keyFrame.Time, interpolationFrameData.ToDictionary(x => x.LightId, x => x)));
            }

            return(interpolationFrames);
        }
 public InterpolationSpan(int lightId,
                          TimeSpan time,
                          Color color,
                          InterpolationMode interpolationMode,
                          InterpolationSpan nextKeyFrameData)
 {
     LightId           = lightId;
     Time              = time;
     Color             = color;
     InterpolationMode = interpolationMode;
     NextSpan          = nextKeyFrameData;
 }