Exemple #1
0
        private static AssLine CreateKaraokeStepLine(AssLine originalLine, SortedList <TimeSpan, int> activeSectionsPerStep, int stepIdx)
        {
            TimeSpan timeOffset        = activeSectionsPerStep.Keys[stepIdx];
            int      numActiveSections = activeSectionsPerStep.Values[stepIdx];

            DateTime startTime = TimeUtil.SnapTimeToFrame((originalLine.Start + timeOffset).AddMilliseconds(20));

            if (startTime >= originalLine.End)
            {
                return(null);
            }

            DateTime endTime;

            if (stepIdx < activeSectionsPerStep.Count - 1)
            {
                endTime = TimeUtil.SnapTimeToFrame((originalLine.Start + activeSectionsPerStep.Keys[stepIdx + 1]).AddMilliseconds(20)).AddMilliseconds(-1);
                if (endTime > originalLine.End)
                {
                    endTime = originalLine.End;
                }
            }
            else
            {
                endTime = originalLine.End;
            }

            AssLine stepLine = (AssLine)originalLine.Clone();

            stepLine.Start = startTime;
            stepLine.End   = endTime;

            foreach (AssSection section in stepLine.Sections.Take(numActiveSections))
            {
                section.Animations.RemoveAll(a => a is SecondaryColorAnimation);
            }

            foreach (AssSection section in stepLine.Sections.Skip(numActiveSections))
            {
                section.ForeColor = section.SecondaryColor;

                section.Animations.RemoveAll(a => a is ForeColorAnimation);
                foreach (SecondaryColorAnimation anim in section.Animations.OfType <SecondaryColorAnimation>().ToList())
                {
                    section.Animations.Remove(anim);
                    section.Animations.Add(new ForeColorAnimation(anim.StartTime, anim.StartColor, anim.EndTime, anim.EndColor));
                }

                if (section.ForeColor.A == 0 && !section.Animations.OfType <ForeColorAnimation>().Any())
                {
                    section.ForeColor = Color.FromArgb(0, 0, 0, 0);
                    section.BackColor = Color.FromArgb(0, 0, 0, 0);
                    section.ShadowColors.Clear();
                }
            }

            AddKaraokeEffects(originalLine, stepLine, activeSectionsPerStep, stepIdx);
            return(stepLine);
        }
Exemple #2
0
        private AssLine CreateTextVisualizationLine(AssLine originalLine)
        {
            AssLine textLine = (AssLine)originalLine.Clone();

            foreach (AssSection textSection in textLine.Sections)
            {
                textSection.BackColor = Color.Empty;
                textSection.ShadowColors.Clear();
            }
            return(textLine);
        }
Exemple #3
0
        private AssLine CreateBackgroundVisualizationLine(AssLine originalLine)
        {
            AssLine backgroundLine = (AssLine)originalLine.Clone();

            foreach (AssSection section in backgroundLine.Sections)
            {
                section.ForeColor      = Color.Empty;
                section.SecondaryColor = Color.Empty;
                section.ShadowColors.Clear();
            }
            return(backgroundLine);
        }
Exemple #4
0
        private AssLine CreateShadowVisualizationLine(AssLine originalLine, Func <AssSection, Color> getShadowColor, float positionOffset, float blur)
        {
            AssLine shadowLine = (AssLine)originalLine.Clone();

            if (positionOffset != 0)
            {
                PointF position = shadowLine.Position ?? GetDefaultPosition(shadowLine.AnchorPoint);
                shadowLine.Position = new PointF(position.X + positionOffset, position.Y + positionOffset);
            }

            foreach (AssSection shadowSection in shadowLine.Sections)
            {
                shadowSection.ForeColor = getShadowColor(shadowSection);
                shadowSection.BackColor = Color.Empty;
                shadowSection.ShadowColors.Clear();
                shadowSection.Blur = blur;
            }
            return(shadowLine);
        }
Exemple #5
0
        private IEnumerable <AssLine> CreateKaraokeStepLines(AssLine originalLine, SortedList <TimeSpan, int> activeSectionsPerStep, int stepIdx)
        {
            TimeSpan timeOffset        = activeSectionsPerStep.Keys[stepIdx];
            int      numActiveSections = activeSectionsPerStep.Values[stepIdx];

            DateTime startTime = TimeUtil.RoundTimeToFrameCenter(originalLine.Start + timeOffset);

            if (startTime >= originalLine.End)
            {
                return(new List <AssLine>());
            }

            DateTime endTime;

            if (stepIdx < activeSectionsPerStep.Count - 1)
            {
                endTime = TimeUtil.RoundTimeToFrameCenter(originalLine.Start + activeSectionsPerStep.Keys[stepIdx + 1]);
                if (endTime > originalLine.End)
                {
                    endTime = originalLine.End;
                }
            }
            else
            {
                endTime = originalLine.End;
            }

            AssLine stepLine = (AssLine)originalLine.Clone();

            stepLine.Start = startTime;
            stepLine.End   = endTime;

            foreach (AssSection section in stepLine.Sections.Take(numActiveSections))
            {
                section.Duration    = TimeSpan.Zero;
                section.StartOffset = TimeSpan.Zero;
                section.Animations.RemoveAll(a => a is SecondaryColorAnimation);
            }

            foreach (AssSection section in stepLine.Sections.Skip(numActiveSections))
            {
                section.Duration    = TimeSpan.Zero;
                section.StartOffset = TimeSpan.Zero;

                section.ForeColor = section.SecondaryColor;

                section.Animations.RemoveAll(a => a is ForeColorAnimation);
                foreach (SecondaryColorAnimation anim in section.Animations.OfType <SecondaryColorAnimation>().ToList())
                {
                    section.Animations.Remove(anim);
                    section.Animations.Add(new ForeColorAnimation(anim.StartTime, anim.StartColor, anim.EndTime, anim.EndColor, anim.Acceleration));
                }

                if (section.ForeColor.A == 0 && !section.Animations.OfType <ForeColorAnimation>().Any())
                {
                    section.ForeColor = Color.FromArgb(0);
                    section.BackColor = Color.FromArgb(0);
                    section.ShadowColors.Clear();
                }
            }

            return(ApplyKaraokeType(originalLine, stepLine, activeSectionsPerStep, stepIdx));
        }