コード例 #1
0
        public List <ASSEvent> Create(IMovingObject imo)
        {
            List <ASSEvent> result = new List <ASSEvent>();
            //string pt0Str = @"{\blur3\bord4\p4}m 10 10 s 10 -10 -10 -10 -10 10";
            string pt0Str = @"{\blur" + (Pt0Size - 1) + @"\bord" + Pt0Size + @"\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";

            for (double time = ParticleStartTime; time < ParticleEndTime; time += TimeStep)
            {
                for (int iDot = 0; iDot < ParticlePerStep; iDot++)
                {
                    ASSPointF   orgP      = imo.GetPosition(time);
                    double      orgX      = orgP.X;
                    double      orgY      = orgP.Y;
                    ParticleDot dot       = new ParticleDot(orgX, orgY, Common.RandomDouble(rnd, MinDX, MaxDX), Common.RandomDouble(rnd, MinDY, MaxDY), -Common.RandomDouble(rnd, MinDA, MaxDA));
                    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;
                    result.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.a(1, "FF") + ASSEffect.c(3, ColorStart) + ASSEffect.fad(0, liveTime) + ASSEffect.t(0, liveTime, ASSEffect.c(3, ColorEnd).t()) + pt0Str
                    });
                    if (Star)
                    {
                        result.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, ColorStart) + ASSEffect.fad(0, liveTime) + ASSEffect.t(0, liveTime, ASSEffect.c(1, ColorEnd).t()) + pt1Str
                        });
                    }
                }
            }
            return(result);
        }
コード例 #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";

            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);
        }