示例#1
0
        public override void Run()
        {
            ASS ass_in  = ASS.FromFile(this.InFileName);
            ASS ass_out = new ASS();

            ass_out.Header = ass_in.Header;
            ass_out.Events = new List <ASSEvent>();

            string pt0Str = @"{\blur3\bord4\p4}m 10 10 s 10 -10 -10 -10 -10 10";
            string pt1Str = @"{\p4}m 0 100 l 1 1 100 0 1 -1 0 -100 -1 -1 -100 0 -1 1";

            Random rnd = new Random();

            double totalTime        = 20;
            double timeStep         = 0.01;
            double particleStopTime = 10;
            int    particlePerStep  = 5;
            double orgX             = 0;
            double orgY             = 0;

            //double dOrgY = this.PlayResY / totalTime;
            for (double time = 0; time < totalTime; time += timeStep)
            {
                Console.WriteLine(time);
                if (particleStopTime < time)
                {
                    continue;
                }
                double r = time / particleStopTime;
                double a = time * 3;
                orgX = this.PlayResX * 0.5 + this.PlayResX * 0.55 * Math.Cos(a) * r;
                orgY = this.PlayResY * 0.5 + this.PlayResY * 0.55 * Math.Sin(a) * r;
                for (int iDot = 0; iDot < particlePerStep; iDot++)
                {
                    ParticleDot dot       = new ParticleDot(orgX, orgY, Common.RandomDouble(rnd, -30, 30), Common.RandomDouble(rnd, -30, 30), -Common.RandomDouble(rnd, 0.5, 2));
                    double      liveTime  = -1.0 / dot.dA;
                    double      startTime = time;
                    double      endTime   = time + liveTime;
                    double      xEnd      = dot.X + dot.dX * liveTime;
                    double      yEnd      = dot.Y + dot.dY * liveTime;
                    double      r0        = 0.8;
                    double      g0        = 0.2;
                    double      b0        = 1;
                    double      r1        = 0;
                    double      g1        = 0;
                    double      b1        = 1;
                    string      colStart  = ASSColor.ToBBGGRR(b0 * 256, g0 * 256, r0 * 256);
                    string      colEnd    = ASSColor.ToBBGGRR(b1 * 256, g1 * 256, r1 * 256);
                    ass_out.Events.Add(new ASSEvent
                    {
                        Effect  = "",
                        Layer   = 0,
                        MarginL = "0000",
                        MarginR = "0000",
                        MarginV = "0000",
                        Name    = "NTP",
                        Style   = "Default",
                        Start   = startTime,
                        End     = endTime,
                        Text    = ASSEffect.move(dot.X, dot.Y, xEnd, yEnd) + ASSEffect.c(3, colStart) + ASSEffect.fad(0, liveTime) + ASSEffect.t(0, liveTime, ASSEffect.c(3, colEnd).t()) + pt0Str
                    });
                    ass_out.Events.Add(new ASSEvent
                    {
                        Effect  = "",
                        Layer   = 0,
                        MarginL = "0000",
                        MarginR = "0000",
                        MarginV = "0000",
                        Name    = "NTP",
                        Style   = "Default",
                        Start   = startTime,
                        End     = endTime,
                        Text    = ASSEffect.move(dot.X, dot.Y - 1, xEnd, yEnd - 1) + ASSEffect.a(1, "77") + ASSEffect.c(1, colStart) + ASSEffect.fad(0, liveTime) + ASSEffect.t(0, liveTime, ASSEffect.c(1, colEnd).t()) + pt1Str
                    });
                }
            }

            ass_out.SaveFile(OutFileName);
        }
示例#2
0
        public override void Run()
        {
            ASS ass_in  = ASS.FromFile(this.InFileName);
            ASS ass_out = new ASS();

            ass_out.Header = ass_in.Header;
            ass_out.Events = new List <ASSEvent>();

            string pt0Str = @"{\blur3\bord4\p4}m 10 10 s 10 -10 -10 -10 -10 10";
            string pt1Str = @"{\p4}m 0 100 l 1 1 100 0 1 -1 0 -100 -1 -1 -100 0 -1 1";

            List <ParticleDot> dots = new List <ParticleDot>();
            Random             rnd  = new Random();

            double totalTime        = 20;
            double timeStep         = 0.04;
            double particleStopTime = 10;
            int    particlePerStep  = 5;
            double orgX             = 0;
            double dOrgX            = this.PlayResX / particleStopTime;
            double orgY             = 0;

            //double dOrgY = this.PlayResY / totalTime;
            for (double time = 0; time < totalTime; time += timeStep)
            {
                Console.WriteLine(time);

                // Draw Dots
                dots = dots.Where(pd => !pd.Die).ToList();
                foreach (ParticleDot dot in dots)
                {
                    dot.A += dot.dA * timeStep;
                    dot.R  = dot.R;
                    dot.G  = 0.2 * dot.A;
                    dot.B  = 0.8 * dot.A;
                    dot.X += dot.dX * timeStep;
                    dot.Y += dot.dY * timeStep;

                    double a0 = (1 - dot.A) * 256;
                    if (a0 < 0)
                    {
                        a0 = 0;
                    }
                    if (a0 > 255)
                    {
                        a0 = 255;
                    }
                    string aStr = Common.ToHex2(a0);
                    string cStr = ASSColor.ToBBGGRR(dot.R * 256, dot.G * 256, dot.B * 256);

                    ass_out.Events.Add(new ASSEvent
                    {
                        Effect  = "",
                        Layer   = 0,
                        MarginL = "0000",
                        MarginR = "0000",
                        MarginV = "0000",
                        Name    = "NTP",
                        Style   = "Default",
                        Start   = time,
                        End     = time + timeStep,
                        Text    = ASSEffect.pos(dot.X, dot.Y) + ASSEffect.a(1, aStr) + ASSEffect.a(3, aStr) + ASSEffect.c(3, cStr) + pt0Str
                    });
                    ass_out.Events.Add(new ASSEvent
                    {
                        Effect  = "",
                        Layer   = 0,
                        MarginL = "0000",
                        MarginR = "0000",
                        MarginV = "0000",
                        Name    = "NTP",
                        Style   = "Default",
                        Start   = time,
                        End     = time + timeStep,
                        Text    = ASSEffect.pos(dot.X, dot.Y - 1) + ASSEffect.a(1, aStr) + ASSEffect.a(3, aStr) + ASSEffect.c(1, cStr) + pt1Str
                    });
                }
                orgX += dOrgX * timeStep;
                //orgY += dOrgY * timeStep;
                orgY = this.PlayResY * 0.5 + this.PlayResY * 0.3 * Math.Sin(time * 2);

                if (particleStopTime < time)
                {
                    continue;
                }
                for (int iDot = 0; iDot < particlePerStep; iDot++)
                {
                    dots.Add(new ParticleDot(orgX, orgY, Common.RandomDouble(rnd, -30, 30), Common.RandomDouble(rnd, -30, 30), -Common.RandomDouble(rnd, 0.5, 1)));
                }
            }

            ass_out.SaveFile(OutFileName);
        }