예제 #1
0
        public ASSEvent CreateMovingPixel(double start, double end, int x0, int y0, int x1, int y1, string c1, string a1, int fade_mode)
        {
            string fade_string = "";

            switch (fade_mode)
            {
            case 0: break;

            case 1: fade_string = ASSEffect.fad(end - start, 0); break;

            case 2: fade_string = ASSEffect.fad(0, end - start); break;

            default: break;
            }
            return
                (new ASSEvent
            {
                Start = start,
                End = end,
                Layer = 0,
                Style = "pt",
                Effect = "",
                MarginL = "0000",
                MarginR = "0000",
                MarginV = "0000",
                Name = "NTP",
                Text = fade_string + ASSEffect.move(x0, y0, x1, y1) + ASSEffect.c(1, c1) + ASSEffect.a(1, a1) + '.'
            });
        }
예제 #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>();

            Random rnd = new Random();

            string ptstr  = @"{\p1}m 0 0 l 1 0 1 1 0 1";
            string pt1str = @"{\p4}m 0 0 l 50 49 100 0 51 50 100 100 50 51 0 100 49 50 0 0 m 45 45 s 55 45 55 55 45 55 c{\p0}";

            double dy = -0.5;
            double y  = 200;
            int    yl = 190;
            int    yh = 210;
            int    ag = 0;

            for (int x = 100; x <= 700; x++)
            {
                if (y == yh)
                {
                    dy = -0.5;
                }
                if (y == yl)
                {
                    dy = 0.5;
                }
                y  += dy;
                ag += 1;

                double t0 = (double)(x - 100) / 100;

                ass_out.AppendEvent(0, "pt", t0, t0 + 2,
                                    ASSEffect.pos(x, y) + ASSEffect.an(5) +
                                    ASSEffect.a(1, "E0") + ASSEffect.c(1, "FFFFFF") +
                                    ASSEffect.a(3, "F0") + ASSEffect.c(3, "FFFFFF") + ASSEffect.bord(2) + ASSEffect.be(1) +
                                    ASSEffect.frx(ag) + ASSEffect.fry(ag) + ASSEffect.frz(ag) +
                                    ASSEffect.fad(0, 2) +
                                    ASSEffect.t(0, 2, ASSEffect.fsc(500, 500).t()) +
                                    pt1str);
            }

            ass_out.SaveFile(OutFileName);
        }
        public override void Run()
        {
            string ptstr = @"{\p1}m 0 0 l 1 0 1 1 0 1";
            string lstr0 = @"{\p1}m -1 0 l 0 -50 0 0";
            string lstr1 = @"{\p1}m -1 0 l 0 0 0 50";

            ASS ass_in  = ASS.FromFile(this.InFileName);
            ASS ass_out = new ASS();

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

            int    ox   = 300;
            int    oy   = 300;
            Random rnd  = new Random();
            string lcol = "00C6FF";

            for (int count = 0; count < 50; count++)
            {
                double t0 = 2 + Common.RandomDouble(rnd, 0, 1);
                double t1 = t0 + 1;
                double x0 = Common.RandomDouble(rnd, ox - 10, ox + 10);
                double x1 = Common.RandomDouble(rnd, ox - 20, ox + 20);
                //if (Common.RandomBool(rnd, 0.5)) x1 = ox - 20; else x1 = ox + 20;
                int startag = Common.RandomInt(rnd, 0, 90);

                ass_out.AppendEvent(5, "pt", t0, t1,
                                    ASSEffect.fad(0.2, 0) + ASSEffect.move(x0, oy, x1, oy) +
                                    ASSEffect.a(1, "00") + ASSEffect.c(1, lcol) + ASSEffect.a(3, "FF") +
                                    ASSEffect.frx(startag) +
                                    ASSEffect.t(0, t1 - t0, ASSEffect.frx(90).t()) +
                                    lstr0);
                ass_out.AppendEvent(5, "pt", t0, t1,
                                    ASSEffect.fad(0.2, 0) + ASSEffect.move(x0, oy, x1, oy) +
                                    ASSEffect.a(1, "00") + ASSEffect.c(1, lcol) + ASSEffect.a(3, "FF") +
                                    ASSEffect.frx(startag) +
                                    ASSEffect.t(0, t1 - t0, ASSEffect.frx(90).t()) +
                                    lstr1);
            }

            ass_out.SaveFile(OutFileName);
        }
예제 #4
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 ptString = @"{\p8}m 0 0 l 128 0 128 128 0 128";

            int[,] map = new int[this.PlayResX, this.PlayResY];

            for (int iEv = 0; iEv < ass_in.Events.Count; iEv++)
            {
                //if (iEv != 0) continue;
                ASSEvent        ev     = ass_in.Events[iEv];
                List <KElement> kelems = ev.SplitK(false);

                /// an7 pos
                int x0 = MarginLeft;
                if (iEv == 5)
                {
                    x0 = PlayResX - GetTotalWidth(ev) - MarginRight;
                }
                int y0 = PlayResY - MarginBottom - FontHeight;

                Random rnd = new Random();

                int kSum = 0;

                for (int iK = 0; iK < kelems.Count; iK++)
                {
                    Console.WriteLine("{0} / {1} : {2} / {3}", iEv + 1, ass_in.Events.Count, iK + 1, kelems.Count);

                    KElement   ke   = kelems[iK];
                    double     r    = (double)iK / (double)(kelems.Count - 1);
                    StringMask mask = GetMask(ke.KText, x0, y0);
                    Size       sz   = new Size(mask.Width, mask.Height);

                    /// an5 pos
                    int x = x0 + this.FontSpace + sz.Width / 2;
                    int y = y0 + FontHeight / 2;
                    mask = GetMask(ke.KText, x, y);

                    x0 += this.FontSpace + sz.Width;
                    y0  = y0;

                    double kStart = ev.Start + kSum * 0.01;
                    kSum += ke.KValue;
                    double kEnd = ev.Start + kSum * 0.01;

                    double t0 = ev.Start - 1.0 + 0.1 * iK;
                    double t1 = t0 + 0.4;
                    double t2 = ev.End - 1.0 + 0.1 * iK;
                    double t3 = t2 + 0.4;

                    for (int i = 1; i <= 5; i++)
                    {
                        ass_out.Events.Add(
                            ev.StartReplace(t0 + i * 0.03).EndReplace(t1 + i * 0.03).TextReplace(
                                ASSEffect.move(x + 30, y - 30, x, y) + ASSEffect.a(1, "FF") + ASSEffect.blur(2) +
                                ASSEffect.fad((t1 - t0) * 2, 0) + ASSEffect.fry(-180) +
                                ASSEffect.t(0, t1 - t0, ASSEffect.fry(0).t()) +
                                ke.KText));
                    }
                    ass_out.Events.Add(
                        ev.StartReplace(t0).EndReplace(t1).TextReplace(
                            ASSEffect.move(x + 30, y - 30, x, y) + ASSEffect.a(1, "FF") + ASSEffect.blur(2) +
                            ASSEffect.fad(t1 - t0, 0) + ASSEffect.fry(-180) +
                            ASSEffect.t(0, t1 - t0, ASSEffect.fry(0).t()) +
                            ke.KText));
                    ass_out.Events.Add(
                        ev.StartReplace(kStart).EndReplace(t2).TextReplace(
                            ASSEffect.pos(x + 1, y + 1) + ASSEffect.a(1, "FF") + ASSEffect.a(3, "77") + ASSEffect.c(3, "000000") +
                            ASSEffect.bord(8) + ASSEffect.blur(8) + ASSEffect.fad(0.2, 0.2) +
                            ke.KText));
                    ass_out.Events.Add(
                        ev.StartReplace(t1).EndReplace(t2).TextReplace(
                            ASSEffect.pos(x, y) + ASSEffect.a(1, "FF") + ASSEffect.blur(2) +
                            ke.KText));
                    ass_out.Events.Add(
                        ev.StartReplace(t0).EndReplace(t1).TextReplace(
                            ASSEffect.move(x + 31, y - 29, x + 1, y + 1) + ASSEffect.a(1, "FF") + ASSEffect.a(3, "77") + ASSEffect.c(3, "000000") +
                            ASSEffect.bord(8) + ASSEffect.blur(8) + ASSEffect.fad(t1 - t0, 0) + ASSEffect.fry(-180) +
                            ASSEffect.t(0, t1 - t0, ASSEffect.fry(0).t()) +
                            ke.KText));
                    ass_out.Events.Add(
                        ev.StartReplace(t1).EndReplace(kStart + 0.2).TextReplace(
                            ASSEffect.pos(x + 1, y + 1) + ASSEffect.a(1, "FF") + ASSEffect.a(3, "77") + ASSEffect.c(3, "000000") +
                            ASSEffect.bord(8) + ASSEffect.blur(8) + ASSEffect.fad(0, 0.2) +
                            ke.KText));
                    for (int i = 1; i <= 5; i++)
                    {
                        ass_out.Events.Add(
                            ev.StartReplace(t2 + i * 0.03).EndReplace(t3 + i * 0.03).TextReplace(
                                ASSEffect.move(x, y, x - 30, y + 30) + ASSEffect.a(1, "00") + ASSEffect.blur(2) +
                                ASSEffect.fad(0, 2 * (t3 - t2)) + ASSEffect.t(0, t3 - t2, ASSEffect.fry(180).t()) +
                                ke.KText));
                    }
                    ass_out.Events.Add(
                        ev.StartReplace(t2).EndReplace(t3).TextReplace(
                            ASSEffect.move(x, y, x - 30, y + 30) + ASSEffect.a(1, "00") + ASSEffect.blur(2) +
                            ASSEffect.fad(0, t3 - t2) + ASSEffect.t(0, t3 - t2, ASSEffect.fry(180).t()) +
                            ke.KText));

                    for (int i = 0; i < this.PlayResX; i++)
                    {
                        for (int j = 0; j < this.PlayResY; j++)
                        {
                            map[i, j] = -1;
                        }
                    }
                    for (int i = 0; i < mask.Points.Count; i++)
                    {
                        ASSPoint pt = mask.Points[i];
                        map[pt.X, pt.Y] = i;
                    }
                    int[] dx0 = { 0, 1, 0, -1 };
                    int[] dy0 = { 1, 0, -1, 0 };
                    int[] dx1 = { 1, 1, -1, -1 };
                    int[] dy1 = { -1, 1, -1, 1 };
                    int[] ind = new int[mask.Points.Count]; // 顺序标号
                    for (int i = 0; i < ind.Length; i++)
                    {
                        ind[i] = -1;
                    }
                    Queue <int> q;
                    int         left = ind.Length; // 剩下
                    while (left > 0)
                    {
                        q = new Queue <int>();
                        for (int i = 0; i < ind.Length; i++)
                        {
                            if (ind[i] == -1)
                            {
                                q.Enqueue(i);
                                ind[i] = 0;
                                break;
                            }
                        }
                        while (q.Count > 0)
                        {
                            int s = q.Dequeue();
                            left--;
                            ASSPoint pt = mask.Points[s];
                            int      x1, y1, t;
                            for (int i = 0; i < 4; i++)
                            {
                                x1 = pt.X + dx0[i];
                                y1 = pt.Y + dy0[i];
                                if (x1 >= 0 && x1 < PlayResX && y1 >= 0 && y1 < PlayResY && map[x1, y1] >= 0)
                                {
                                    t = map[x1, y1];
                                    if (ind[t] < 0)
                                    {
                                        ind[t] = ind[s] + 1;
                                        q.Enqueue(t);
                                    }
                                }
                            }
                            for (int i = 0; i < 4; i++)
                            {
                                if (Common.RandomBool(rnd, 0.5))
                                {
                                    continue;
                                }
                                x1 = pt.X + dx0[i];
                                y1 = pt.Y + dy0[i];
                                if (x1 >= 0 && x1 < PlayResX && y1 >= 0 && y1 < PlayResY && map[x1, y1] >= 0)
                                {
                                    t = map[x1, y1];
                                    if (ind[t] < 0)
                                    {
                                        ind[t] = ind[s] + 1;
                                        q.Enqueue(t);
                                    }
                                }
                            }
                        }
                    }

                    for (int i = 0; i < mask.Points.Count; i++)
                    {
                        ASSPoint pt    = mask.Points[i];
                        double   indsc = 50.0;
                        if (iEv >= 4)
                        {
                            indsc = 75.0;
                        }
                        double tp0 = kStart - 0.1 + (double)ind[i] / indsc + Common.RandomDouble_Gauss(rnd, -0.2, 0.2);
                        double tp1 = tp0 + 0.3;
                        double tp2 = tp1 + 0.3;
                        string pc0 = "5955FF";
                        string pc1 = "55FDFF";
                        string pc2 = "9C4E4D";
                        ass_out.Events.Add(
                            ev.StartReplace(tp0).EndReplace(tp1).StyleReplace("pt").LayerReplace(5).TextReplace(
                                ASSEffect.pos(pt.X, pt.Y) + ASSEffect.fad(0.3, 0) +
                                ASSEffect.a(1, Common.ToHex2(255 - pt.Brightness)) + ASSEffect.c(1, pc0) +
                                ptString
                                ));
                        ass_out.Events.Add(
                            ev.StartReplace(tp1).EndReplace(tp2).StyleReplace("pt").LayerReplace(5).TextReplace(
                                ASSEffect.pos(pt.X, pt.Y) +
                                ASSEffect.a(1, Common.ToHex2(255 - pt.Brightness)) + ASSEffect.c(1, pc0) +
                                ASSEffect.t(0, tp2 - tp1, ASSEffect.c(1, pc1).t()) +
                                ptString
                                ));
                        ass_out.Events.Add(
                            ev.StartReplace(tp2).EndReplace(t2).StyleReplace("pt").LayerReplace(5).TextReplace(
                                ASSEffect.pos(pt.X, pt.Y) +
                                ASSEffect.a(1, Common.ToHex2(255 - pt.Brightness)) + ASSEffect.c(1, pc1) +
                                ASSEffect.t(0, 0.3, ASSEffect.c(1, pc2).t()) +
                                ptString
                                ));
                    }
                }
            }
            ass_out.SaveFile(OutFileName);
        }
        public void Run()
        {
            ASS ass    = ASS.FromFile(InFileName);
            ASS outass = new ASS();

            outass.Header = ass.Header;
            outass.Events = new List <ASSEvent>();
            Particle particle = new Particle
            {
                IsMove          = false,
                IsRandomColor   = false,
                IsPatternScale  = true,
                Count           = 1,
                FontSize        = 26,
                MinLast         = 0.5,
                MaxLast         = 0.8,
                ParticlePattern = ParticlePatternType.Circle,
                PatternScaleX   = 600,
                PatternScaleY   = 600,
                Style           = "Circle",
                XOffset         = 0,
                YOffset         = 0
            };

            ASSColor[] colors =
            {
                new ASSColor {
                    A = 0, Index = 1, R = 0xCA, G = 0xB4, B = 0x6D
                },
                new ASSColor {
                    A = 0, Index = 1, R = 0xEE, G = 0x85, B = 0x57
                },
                new ASSColor {
                    A = 0, Index = 1, R = 0xE4, G = 0x30, B = 0x99
                },
                new ASSColor {
                    A = 0, Index = 1, R = 0x5D, G = 0xD3, B = 0xEE
                },
                new ASSColor {
                    A = 0, Index = 1, R = 0xE1, G = 0x32, B = 0x63
                }
            };
            for (int i = 0; i < ass.Events.Count; i++)
            {
                ASSEvent        ev     = ass.Events[i];
                List <KElement> klist  = ev.SplitK();
                int             ksum   = 0;
                ASSColor        lastcc = null;
                for (int j = 0; j < klist.Count; j++)
                {
                    int x = (PlayResX - klist.Count * FontWidth) / 2 + j * FontWidth + FontWidth / 2;
                    int y = PlayResY - MarginBottom - FontHeight / 2;
                    if (i == 7)
                    {
                        y = MarginTop + FontHeight / 2;
                    }
                    double   kStart = ksum * 0.01;
                    double   kEnd   = (ksum + klist[j].KValue) * 0.01;
                    ASSColor cc     = colors[(i + j) % colors.Length];

                    /*while (lastcc == cc)
                     *  cc = colors[rnd.Next(colors.Length)];
                     * lastcc = cc;*/
                    if (!Char.IsWhiteSpace(klist[j].KText[0]))
                    {
                        outass.Events.Add(ev.TextReplace(
                                              ASSEffect.an(5) + ASSEffect.pos(x, y) + ASSEffect.a(1, "FF") +
                                              ASSEffect.t(kStart, kStart + 0.2, cc.ToString()) +
                                              (i % 4 <= 1 ?
                                               ASSEffect.t(ev.Last - 0.3 - 0.5 * (1 - ((double)j / (double)klist.Count)), ev.Last - 0.5 * (1 - ((double)j / (double)klist.Count)), @"\1a&HFF&\2a&HFF&\3a&HFF&\4a&HFF&" + ((i % 2 == 0) ? @"\frx700" : @"\fry700")) :
                                               (i % 4 == 3 ? ASSEffect.t(ev.Last - 0.5 * (1 - ((double)j / (double)klist.Count)), ev.Last - 0.5 * (1 - ((double)j / (double)klist.Count)) + 0.01, @"\1a&HFF&\2a&HFF&\3a&HFF&\4a&HFF&") : ASSEffect.t(ev.Last - 0.8 - 0.5 * (1 - ((double)j / (double)klist.Count)), ev.Last - 0.5 * (1 - ((double)j / (double)klist.Count)), @"\1a&HFF&\2a&HFF&\3a&HFF&\4a&HFF&" + @"\frz700"))) +
                                              klist[j].KText
                                              ));
                        if (i % 4 == 3)
                        {
                            outass.Events.Add(ev.StartReplace(ev.Start + ev.Last - 0.5 * (1 - ((double)j / (double)klist.Count)) + 0.01).EndReplace(ev.Start + ev.Last - 0.5 * (1 - ((double)j / (double)klist.Count)) + 0.01 + 0.2).TextReplace(
                                                  ASSEffect.an(5) + ASSEffect.move(x, y, x - 40, y) + ASSEffect.fad(0, 0.2) + ASSEffect.c(cc) + klist[j].KText));
                        }
                        particle.X     = x - FontWidth / 2;
                        particle.Y     = y - FontHeight / 2;
                        particle.Start = ev.Start + kStart;
                        particle.End   = particle.Start;
                        particle.Color = cc;
                        outass.Events.AddRange(particle.Create());
                    }
                    ksum += klist[j].KValue;
                }
            }
            outass.Shift(Shift);
            outass.SaveFile(OutFileName);
        }
        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 ptStr = @"{\p4}m 0 100 l 1 1 100 0 1 -1 0 -100 -1 -1 -100 0 -1 1 c m 10 10 s 10 -10 -10 -10 -10 10 c";

            GetMask("!", 0, 0);

            for (int iEv = 0; iEv < ass_in.Events.Count; iEv++)
            {
                ASSEvent        ev     = ass_in.Events[iEv];
                List <KElement> kelems = ev.SplitK(false);

                /// an7 pos
                int x0 = (PlayResX - GetTotalWidth(ev)) / 2;
                int y0 = PlayResY - MarginBottom - FontHeight;

                Random rnd = new Random();

                int kSum = 0;

                for (int iK = 0; iK < kelems.Count; iK++)
                {
                    KElement ke = kelems[iK];
                    double   r  = (double)iK / (double)(kelems.Count - 1);
                    Size     sz = GetSize(ke.KText);

                    /// an5 pos
                    int x = x0 + this.FontSpace + sz.Width / 2;
                    int y = y0 + FontHeight;

                    StringMask mk = GetMask(ke.KText, x0, y0);
                    if (ke.KText.ToLower() == "silky")
                    {
                        mk = GetMask(ke.KText, x0 - 2, y0);
                    }

                    int bx0 = x0;
                    int by0 = y0;

                    x0 += this.FontSpace + sz.Width;
                    y0  = y0;

                    double kStart = ev.Start + kSum * 0.01;
                    kSum += ke.KValue;
                    double kEnd = ev.Start + kSum * 0.01;

                    double t0 = ev.Start + r * 1.0 - 1.0;
                    double t1 = t0 + 0.2;
                    double t2 = t0 + 0.4;
                    double t3 = t0 + 0.6;
                    double t4 = t0 + 0.8;
                    double t5 = ev.End + r * 1.0 - 1.0;
                    if (t5 < t4)
                    {
                        t5 = t4;
                    }
                    double t6 = t5 + 0.5;

                    ass_out.Events.Add(
                        ev.StartReplace(t0).EndReplace(t1).TextReplace(
                            ASSEffect.move(x, y, x, y - 60) + ASSEffect.a(1, "FF") + ASSEffect.a(3, "FF") +
                            ASSEffect.t(0, t1 - t0, ASSEffect.a(1, "C0").t() + ASSEffect.a(3, "C0").t() + ASSEffect.frx(180).t()) +
                            ke.KText));
                    ass_out.Events.Add(
                        ev.StartReplace(t1).EndReplace(t2).TextReplace(
                            ASSEffect.move(x, y - 60, x, y) + ASSEffect.a(1, "C0") + ASSEffect.a(3, "C0") + ASSEffect.frx(180) +
                            ASSEffect.t(0, t2 - t1, ASSEffect.a(1, "80").t() + ASSEffect.a(3, "80").t() + ASSEffect.frx(360).t()) +
                            ke.KText));
                    ass_out.Events.Add(
                        ev.StartReplace(t2).EndReplace(t3).TextReplace(
                            ASSEffect.move(x, y, x, y - 60) + ASSEffect.a(1, "80") + ASSEffect.a(3, "80") +
                            ASSEffect.t(0, t3 - t2, ASSEffect.a(1, "40").t() + ASSEffect.a(3, "40").t() + ASSEffect.frx(180).t()) +
                            ke.KText));
                    ass_out.Events.Add(
                        ev.StartReplace(t3).EndReplace(t4).TextReplace(
                            ASSEffect.move(x, y - 60, x, y) + ASSEffect.a(1, "40") + ASSEffect.a(3, "40") + ASSEffect.frx(180) +
                            ASSEffect.t(0, t4 - t3, ASSEffect.a(1, "00").t() + ASSEffect.a(3, "00").t() + ASSEffect.frx(360).t()) +
                            ke.KText));
                    ass_out.Events.Add(
                        ev.StartReplace(t4).EndReplace(t5).TextReplace(
                            ASSEffect.pos(x, y) + ASSEffect.a(1, "00") + ASSEffect.a(3, "00") +
                            ke.KText));
                    ass_out.Events.Add(
                        ev.StartReplace(t5).EndReplace(t6).TextReplace(
                            ASSEffect.move(x, y, x + r * 100 - 50, y + 30) + ASSEffect.a(1, "00") + ASSEffect.a(3, "00") +
                            ASSEffect.fad(0, t6 - t5) +
                            ke.KText));

                    ASSColor col = Common.RandomColor(rnd, 1);

                    foreach (ASSPoint pt in mk.Points)
                    {
                        if (!Common.RandomBool(rnd, 0.5))
                        {
                            continue;
                        }
                        double r1  = Common.RandomDouble(rnd, kStart - 0.15, kEnd + 0.15);
                        double r0  = r1 - 0.5;
                        double r2  = Common.RandomDouble(rnd, kStart + 0.9, kStart + 1.2);
                        double r3  = r2 + 0.5;
                        int    x_0 = Common.RandomInt(rnd, pt.X - 80, pt.X - 30);
                        int    y_0 = Common.RandomInt(rnd, pt.Y - 30, pt.Y + 30);
                        int    x_1 = Common.RandomInt(rnd, pt.X + 80, pt.X + 30);
                        int    y_1 = Common.RandomInt(rnd, pt.Y - 30, pt.Y + 30);
                        ass_out.Events.Add(
                            ev.StartReplace(r0).EndReplace(r1).StyleReplace("pt").TextReplace(
                                ASSEffect.move(x_0, y_0, pt.X, pt.Y) + ASSEffect.c(col) + ASSEffect.fad(r1 - r0, 0) + ptStr));
                        ass_out.Events.Add(
                            ev.StartReplace(r1).EndReplace(r2).StyleReplace("pt").TextReplace(
                                ASSEffect.pos(pt.X, pt.Y) + ASSEffect.c(col) + ptStr));
                        ass_out.Events.Add(
                            ev.StartReplace(r2).EndReplace(r3).StyleReplace("pt").TextReplace(
                                ASSEffect.move(pt.X, pt.Y, x_1, y_1) + ASSEffect.c(col) + ASSEffect.fad(0, r3 - r2) + ptStr));
                    }
                }
            }
            ass_out.SaveFile(OutFileName);
        }
예제 #7
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>();

            Random rnd = new Random();

            string ptstr = @"{\p1}m 0 0 l 1 0 1 1 0 1";

            string ts  = "この空のかなたへと 一人思いはせる";
            int    x0  = 50;
            int    y0  = 420;
            double stt = 0;

            foreach (char ch in ts)
            {
                Console.WriteLine(ch);
                stt += 0.2;
                if (Char.IsWhiteSpace(ch))
                {
                    x0 += 30;
                    continue;
                }
                StringMask mask = GetMask(ch + "", x0, y0);
                ASSPoint   p1   = Common.RandomPoint(rnd, x0 - 25, x0 - 15, y0 - 40, y0 + 40);
                ASSPoint   p2   = Common.RandomPoint(rnd, x0 - 45, x0 + 5, y0 - 40, y0 + 40);
                ASSPoint   p3   = Common.RandomPoint(rnd, x0 - 45, x0 + 5, y0 - 40, y0 + 40);
                ASSPoint   p4   = Common.RandomPoint(rnd, x0 - 25, x0 - 15, y0 - 40, y0 + 40);
                Bezier     bz   = new Bezier(p1, p2, p3, p4);
                ASSPoint   p5   = Common.RandomPoint(rnd, x0 - 25, x0 - 15, y0 - 40, y0 + 40);
                ASSPoint   p6   = Common.RandomPoint(rnd, x0 - 45, x0 + 5, y0 - 40, y0 + 40);
                ASSPoint   p7   = Common.RandomPoint(rnd, x0 - 45, x0 + 5, y0 - 40, y0 + 40);
                ASSPoint   p8   = Common.RandomPoint(rnd, x0 - 25, x0 - 15, y0 - 40, y0 + 40);
                Bezier     bz2  = new Bezier(p5, p6, p7, p8);
                Bezier[]   bzs  = new Bezier[20];
                for (int i = 0; i < bzs.Length; i++)
                {
                    bzs[i] = CreateBezier3(rnd, Common.RandomDouble(rnd, x0 + i * FontWidth - 40, x0 + i * FontWidth + 40), Common.RandomDouble(rnd, y0 - 40, y0 + 40), Common.RandomDouble(rnd, 10, 50), Common.RandomDouble(rnd, 10, 50));
                }
                bz  = CreateBezier3(rnd, x0 - 20, y0, 20, 40);
                bz2 = CreateBezier3(rnd, x0 - 20, y0, 20, 40);

                /*foreach (ASSPoint pt in bzs[0].Create(0.01f))
                 * {
                 *  ass_out.Events.Add(
                 *      new ASSEvent
                 *      {
                 *          Effect = "",
                 *          Style = "pt",
                 *          Layer = 10,
                 *          MarginL = "0000",
                 *          MarginR = "0000",
                 *          MarginV = "0000",
                 *          Name = "",
                 *          Start = 0,
                 *          End = 100,
                 *          Text = ASSEffect.pos(pt.X, pt.Y) + ASSEffect.a(1, "00") + ASSEffect.a(3, "FF") + ASSEffect.c(1, "FFFFFF") + ptstr
                 *      });
                 * }*/
                double t = (float)Common.RandomDouble(rnd, 0, 1);
                foreach (ASSPoint pt in mask.Points)
                {
                    string a1   = Common.ToHex2(255 - pt.Brightness);
                    string tarc = Common.scaleColor("0000FF", "FFFFFF", Math.Abs(Common.RandomDouble_Gauss(rnd, -1, 1, 2)));
                    double te   = stt + 1 + (0.5 - Math.Abs(((double)t - 0.5)));
                    ass_out.Events.Add(
                        new ASSEvent
                    {
                        Effect  = "",
                        Style   = "pt",
                        Layer   = 0,
                        MarginL = "0000",
                        MarginR = "0000",
                        MarginV = "0000",
                        Name    = "",
                        Start   = stt,
                        End     = te,
                        Text    = ASSEffect.pos(pt.X, pt.Y) + ASSEffect.a(1, a1) + ASSEffect.a(3, "FF") + ASSEffect.c(1, "0000FF") +
                                  ptstr
                    });

                    /*
                     * ASSPoint tar = bz.Get(t);
                     * if (Common.RandomBool(rnd, 0.5)) tar = bz2.Get(t);
                     * ass_out.Events.Add(
                     *  new ASSEvent
                     *  {
                     *      Effect = "",
                     *      Style = "pt",
                     *      Layer = 0,
                     *      MarginL = "0000",
                     *      MarginR = "0000",
                     *      MarginV = "0000",
                     *      Name = "",
                     *      Start = stt + 1,
                     *      End = stt + 2 + (0.5 - Math.Abs(((double)t - 0.5))),
                     *      Text = ASSEffect.move(pt.X, pt.Y, tar.X, tar.Y) + ASSEffect.fad(0, 0.5) +
                     *              ASSEffect.a(1, "77") + ASSEffect.a(3, "E7") + ASSEffect.c(1, "FFFFFF") + ASSEffect.c(3, "0000FF") +
                     *              ASSEffect.bord(2) + ASSEffect.blur(2) +
                     *              ptstr
                     *  });*/
                    double lastx = pt.X;
                    double lasty = pt.Y;
                    double tt0   = Common.RandomDouble(rnd, 0.2, 1);
                    tt0 = 1;
                    double tt1 = tt0 / 3;
                    t = (float)Common.RandomDouble(rnd, 0, 1);
                    for (int i = 0; i < bzs.Length; i++)
                    {
                        //if (t < 0.5) t = 0.5 - t; else t = 1.5 - t;
                        ASSPoint pb  = bzs[i].Get((float)t);
                        double   te0 = te + tt0 + (tt1 - Math.Abs(((double)t - 0.5)) / 0.5 * tt1);
                        ass_out.Events.Add(
                            new ASSEvent
                        {
                            Effect  = "",
                            Style   = "pt",
                            Layer   = 0,
                            MarginL = "0000",
                            MarginR = "0000",
                            MarginV = "0000",
                            Name    = "",
                            Start   = te,
                            End     = te0,
                            Text    = ASSEffect.move(lastx, lasty, pb.X, pb.Y) + ASSEffect.fad(0, ((i + 1 == bzs.Length) ? 0.5 : 0)) +
                                      ASSEffect.a(1, "77") + ASSEffect.a(3, "E0") + ASSEffect.c(1, "FFFFFF") + ASSEffect.c(3, "0000FF") +
                                      ASSEffect.bord(3) + ASSEffect.blur(3) +
                                      ptstr
                        });
                        lastx = pb.X;
                        lasty = pb.Y;
                        te    = te0;
                    }
                }
                break;
                x0 += mask.Width + this.FontSpace;
            }

            ass_out.SaveFile(OutFileName);
        }
예제 #8
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);
        }
예제 #9
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 ptString = @"{\p8}m 0 0 l 128 0 128 128 0 128";

            string[] colString = { "4BFCCC", "CE8046", "52065D", "8F0036", "33AE52", "6ADB57" };
            colString = colString.Select(s => ASSColor.HtmlToASS(s)).ToArray();

            for (int iEv = 0; iEv < ass_in.Events.Count; iEv++)
            {
                Console.WriteLine("{0} / {1}", iEv + 1, ass_in.Events.Count);

                ASSEvent        ev     = ass_in.Events[iEv];
                List <KElement> kelems = ev.SplitK(true);

                /// an7 pos
                int x0 = (PlayResX - GetTotalWidth(ev)) / 2;
                int y0 = PlayResY - MarginBottom - FontHeight;

                Random rnd = new Random();

                int kSum = 0;

                string col0  = colString[iEv % colString.Length];
                string col1  = (iEv >= 7 && iEv <= 10) ? "CCCCCC" : "CCCCCC";
                string col20 = "FFFFFF";
                string col21 = "CCCCCC";
                string col22 = "888888";
                string col23 = "444444";
                string col24 = "111111";
                if (iEv >= 7 && iEv <= 10)
                {
                    col20 = "111111";
                    col21 = "444444";
                    col23 = "CCCCCC";
                    col24 = "FFFFFF";
                }

                for (int iK = 0; iK < kelems.Count; iK++)
                {
                    KElement ke = kelems[iK];
                    double   r  = (double)iK / (double)(kelems.Count - 1);
                    Size     sz = GetSize(ke.KText);

                    /// an5 pos
                    int x = x0 + this.FontSpace + sz.Width / 2;
                    int y = y0 + FontHeight;

                    int        mask_x0 = x0 + 2;
                    int        mask_y0 = y0 + 0;
                    StringMask mask    = GetMask(ke.KText, mask_x0, mask_y0);
                    if (ke.KText == "ト")
                    {
                        mask = GetMask(ke.KText, mask_x0 + 3, mask_y0);
                    }
                    if (ke.KText == "ル")
                    {
                        mask = GetMask(ke.KText, mask_x0 + 1, mask_y0);
                    }
                    if (ke.KText == "ば")
                    {
                        mask = GetMask(ke.KText, mask_x0 + 1, mask_y0);
                    }
                    if (ke.KText == "し")
                    {
                        mask = GetMask(ke.KText, mask_x0 + 1, mask_y0);
                    }
                    if (ke.KText == "ダ")
                    {
                        mask = GetMask(ke.KText, mask_x0 + 1, mask_y0);
                    }
                    if (ke.KText == "ユ")
                    {
                        mask = GetMask(ke.KText, mask_x0 + 1, mask_y0);
                    }
                    if (ke.KText == "ン")
                    {
                        mask = GetMask(ke.KText, mask_x0, mask_y0);
                    }
                    if (ke.KText == "ざ")
                    {
                        mask = GetMask(ke.KText, mask_x0, mask_y0);
                    }
                    if (ke.KText == "に")
                    {
                        mask = GetMask(ke.KText, mask_x0 - 1, mask_y0);
                    }
                    if (ke.KText == "浮")
                    {
                        mask = GetMask(ke.KText, mask_x0 - 1, mask_y0);
                    }
                    if (ke.KText == "な")
                    {
                        mask = GetMask(ke.KText, mask_x0 - 1, mask_y0);
                    }
                    if (ke.KText == "く")
                    {
                        mask = GetMask(ke.KText, mask_x0 - 1, mask_y0);
                    }
                    if (ke.KText == "の")
                    {
                        mask = GetMask(ke.KText, mask_x0 - 1, mask_y0);
                    }
                    if (ke.KText == "肩")
                    {
                        mask = GetMask(ke.KText, mask_x0 - 1, mask_y0);
                    }
                    if (ke.KText == "を")
                    {
                        mask = GetMask(ke.KText, mask_x0 - 1, mask_y0);
                    }
                    if (ke.KText == "て")
                    {
                        mask = GetMask(ke.KText, mask_x0 - 1, mask_y0);
                    }
                    if (ke.KText == "テ")
                    {
                        mask = GetMask(ke.KText, mask_x0 - 1, mask_y0);
                    }
                    if (ke.KText == "熱")
                    {
                        mask = GetMask(ke.KText, mask_x0 - 1, mask_y0);
                    }
                    if (ke.KText == "る")
                    {
                        mask = GetMask(ke.KText, mask_x0 - 1, mask_y0);
                    }
                    if (ke.KText == "こ")
                    {
                        mask = GetMask(ke.KText, mask_x0 - 1, mask_y0);
                    }
                    if (ke.KText == "読")
                    {
                        mask = GetMask(ke.KText, mask_x0 - 1, mask_y0);
                    }
                    if (ke.KText == "ま")
                    {
                        mask = GetMask(ke.KText, mask_x0 - 1, mask_y0);
                    }
                    if (ke.KText == "さ")
                    {
                        mask = GetMask(ke.KText, mask_x0 - 1, mask_y0);
                    }
                    if (ke.KText == "波")
                    {
                        mask = GetMask(ke.KText, mask_x0 - 1, mask_y0);
                    }
                    if (ke.KText == "時")
                    {
                        mask = GetMask(ke.KText, mask_x0 - 1, mask_y0);
                    }
                    if (ke.KText == "間")
                    {
                        mask = GetMask(ke.KText, mask_x0 - 1, mask_y0);
                    }
                    if (ke.KText == "柄")
                    {
                        mask = GetMask(ke.KText, mask_x0 - 1, mask_y0);
                    }
                    if (ke.KText == "焼")
                    {
                        mask = GetMask(ke.KText, mask_x0 - 1, mask_y0);
                    }

                    x0 += this.FontSpace + sz.Width;
                    y0  = y0;

                    double kStart = ev.Start + kSum * 0.01;
                    kSum += ke.KValue;
                    double kEnd = ev.Start + kSum * 0.01;

                    double t0 = ev.Start + r * 1.0 - 1.0;
                    double t1 = t0 + 0.2;
                    double t2 = t0 + 0.4;
                    double t3 = t0 + 0.6;
                    double t4 = t0 + 0.8;
                    double t5 = kStart - 0.1;
                    double t6 = kStart + 0.05;
                    double t7 = kStart + 0.15;
                    double t8 = kStart + 0.3;
                    double t9 = ev.End + r * 1.0 - 1.0;
                    double tA = t9 + 0.4;

                    ass_out.Events.Add(
                        ev.StyleReplace("bd").StartReplace(t5).EndReplace(t7).TextReplace(
                            ASSEffect.pos(x, y) + ASSEffect.fad(t6 - t5, 0) + ASSEffect.bord(15) +
                            ASSEffect.a(1, "FF") + ASSEffect.c(3, col0) + ASSEffect.blur(10) +
                            ke.KText));
                    ass_out.Events.Add(
                        ev.StyleReplace("bd").StartReplace(t7).EndReplace(t8 + 0.15).TextReplace(
                            ASSEffect.pos(x, y) + ASSEffect.bord(15) + ASSEffect.fad(0, t8 + 0.15 - t7) +
                            ASSEffect.a(1, "FF") + ASSEffect.c(3, col0) + ASSEffect.blur(10) +
                            ke.KText));
                    ass_out.Events.Add(
                        ev.StyleReplace("bd").StartReplace(t7).EndReplace(t8 + 0.15).TextReplace(
                            ASSEffect.pos(x, y) + ASSEffect.fad(t8 + 0.15 - t7, 0) +
                            ASSEffect.a(1, "FF") + ASSEffect.c(3, col0) + ASSEffect.blur(10) + ASSEffect.a(3, "77") +
                            ke.KText));
                    ass_out.Events.Add(
                        ev.StyleReplace("bd").StartReplace(t8 + 0.15).EndReplace(t9).TextReplace(
                            ASSEffect.pos(x, y) +
                            ASSEffect.a(1, "FF") + ASSEffect.c(3, col0) + ASSEffect.blur(10) + ASSEffect.a(3, "77") +
                            ke.KText));
                    ass_out.Events.Add(
                        ev.StyleReplace("bd").StartReplace(t9).EndReplace(tA).TextReplace(
                            ASSEffect.pos(x, y) + ASSEffect.fad(0, tA - t9) +
                            ASSEffect.a(1, "FF") + ASSEffect.c(3, col0) + ASSEffect.blur(10) + ASSEffect.a(3, "77") +
                            ke.KText));

                    ass_out.Events.Add(
                        ev.StartReplace(kEnd - 0.1).EndReplace(t9).TextReplace(
                            ASSEffect.pos(x, y) + ASSEffect.fad(t9 - kEnd + 0.1, 0) +
                            ASSEffect.a(3, "FF") + ASSEffect.c(1, col0) +
                            ke.KText));
                    ass_out.Events.Add(
                        ev.StartReplace(t9).EndReplace(tA).TextReplace(
                            ASSEffect.pos(x, y) + ASSEffect.fad(0, tA - t9) +
                            ASSEffect.a(3, "FF") + ASSEffect.c(1, col0) +
                            ke.KText));

                    ass_out.Events.Add(
                        ev.StartReplace(t0).EndReplace(t1).TextReplace(
                            ASSEffect.move(x, y, x, y - 75) + ASSEffect.a(1, "FF") + ASSEffect.a(3, "FF") + ASSEffect.blur(1) + ASSEffect.c(3, col20) +
                            ASSEffect.t(0, t1 - t0, ASSEffect.a(3, "C0").t() + ASSEffect.frx(180).t() + ASSEffect.c(3, col21).t()) +
                            ke.KText));
                    ass_out.Events.Add(
                        ev.StartReplace(t1).EndReplace(t2).TextReplace(
                            ASSEffect.move(x, y - 75, x, y) + ASSEffect.a(1, "FF") + ASSEffect.a(3, "C0") + ASSEffect.frx(180) + ASSEffect.blur(1) + ASSEffect.c(3, col21) +
                            ASSEffect.t(0, t2 - t1, ASSEffect.a(3, "80").t() + ASSEffect.frx(360).t() + ASSEffect.c(3, col22).t()) +
                            ke.KText));
                    ass_out.Events.Add(
                        ev.StartReplace(t2).EndReplace(t3).TextReplace(
                            ASSEffect.move(x, y, x, y - 75) + ASSEffect.a(1, "FF") + ASSEffect.a(3, "80") + ASSEffect.blur(1) + ASSEffect.c(3, col22) +
                            ASSEffect.t(0, t3 - t2, ASSEffect.a(3, "40").t() + ASSEffect.frx(180).t() + ASSEffect.c(3, col23).t()) +
                            ke.KText));
                    ass_out.Events.Add(
                        ev.StartReplace(t3).EndReplace(t4).TextReplace(
                            ASSEffect.move(x, y - 75, x, y) + ASSEffect.a(1, "FF") + ASSEffect.a(3, "40") + ASSEffect.frx(180) + ASSEffect.blur(1) + ASSEffect.c(3, col23) +
                            ASSEffect.t(0, t4 - t3, ASSEffect.a(3, "00").t() + ASSEffect.frx(360).t() + ASSEffect.c(3, col24).t() + ASSEffect.blur(1).t()) +
                            ke.KText));
                    ass_out.Events.Add(
                        ev.StartReplace(t4).EndReplace(t5).TextReplace(
                            ASSEffect.pos(x, y) + ASSEffect.c(3, col24) +
                            ASSEffect.a(1, "FF") + ASSEffect.blur(1) +
                            ke.KText));
                    ass_out.Events.Add(
                        ev.StartReplace(t5).EndReplace(t8 + 0.1).TextReplace(
                            ASSEffect.pos(x, y) +
                            ASSEffect.a(1, "FF") + ASSEffect.t(0, t8 + 0.1 - t5, ASSEffect.c(3, col20).t() + ASSEffect.fry(360 * 3).t()) + ASSEffect.blur(1) +
                            ke.KText));
                    ass_out.Events.Add(
                        ev.StartReplace(t8 + 0.1).EndReplace(t9).TextReplace(
                            ASSEffect.pos(x, y) +
                            ASSEffect.a(1, "FF") + ASSEffect.c(3, col20) + ASSEffect.blur(1) +
                            ke.KText));
                    ass_out.Events.Add(
                        ev.StartReplace(t9).EndReplace(tA).TextReplace(
                            ASSEffect.pos(x, y) +
                            ASSEffect.a(1, "FF") + ASSEffect.c(3, col20) + ASSEffect.blur(1) +
                            ASSEffect.fad(0, tA - t9) + ASSEffect.t(0, tA - t9, ASSEffect.fry(700).t()) +
                            ke.KText));

                    foreach (ASSPoint pt in mask.Points)
                    {
                        double ptx0  = Common.RandomInt_Gauss(rnd, pt.X, 10);
                        double pty0  = Common.RandomInt_Gauss(rnd, pt.Y - 60, 10);
                        double ptx1  = Common.RandomInt_Gauss(rnd, pt.X - 60, 20);
                        double pty1  = Common.RandomInt_Gauss(rnd, pt.Y, 10);
                        double pt_kt = ((double)(pt.X - mask.X0) / (double)mask.Width) * (kEnd - kStart) + kStart;
                        double ptt0  = Common.RandomDouble(rnd, pt_kt - 0.4, pt_kt);
                        double ptt1  = Common.RandomDouble(rnd, ptt0 + 0.25, ptt0 + 0.45);
                        double ptt2  = ev.End - 1.0 * (1.0 - r) + 0.3 * (double)(pt.Y - y0) / (double)FontHeight + Common.RandomDouble(rnd, 0, 0.2);
                        double ptt3  = Common.RandomDouble(rnd, ptt2 + 0.25, ptt2 + 0.45);
                        string ptcol = Common.scaleColor(col0, col1, (double)(pt.Y - y0) / (double)FontHeight);

                        ass_out.Events.Add(
                            ev.StartReplace(ptt0).EndReplace(ptt1).StyleReplace("pt").TextReplace(
                                ASSEffect.move(ptx0, pty0, pt.X, pt.Y) +
                                ASSEffect.a(1, Common.ToHex2(255 - pt.Brightness)) + ASSEffect.c(1, ptcol) +
                                ASSEffect.fad(0.4 * (ptt1 - ptt0), 0) +
                                ptString
                                ));
                        ass_out.Events.Add(
                            ev.StartReplace(ptt1).EndReplace(ptt2).StyleReplace("pt").TextReplace(
                                ASSEffect.pos(pt.X, pt.Y) +
                                ASSEffect.a(1, Common.ToHex2(255 - pt.Brightness)) + ASSEffect.c(1, ptcol) +
                                ptString
                                ));
                        ass_out.Events.Add(
                            ev.StartReplace(ptt2).EndReplace(ptt3).StyleReplace("pt").TextReplace(
                                ASSEffect.move(pt.X, pt.Y, ptx1, pty1) +
                                ASSEffect.a(1, Common.ToHex2(255 - pt.Brightness)) + ASSEffect.c(1, ptcol) +
                                ASSEffect.fad(0, ptt3 - ptt2) +
                                ptString
                                ));
                    }
                }
            }
            ass_out.SaveFile(OutFileName);
        }
예제 #10
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);
        }
예제 #11
0
        public void Run()
        {
            ASS ass    = ASS.FromFile(InFileName);
            ASS outass = new ASS();

            outass.Header = ass.Header;
            outass.Events = new List <ASSEvent>();

            for (int countEvent = 0; countEvent < 1; countEvent++)
            {
                ASSEvent        ev     = ass.Events[countEvent];
                List <KElement> kelems = ev.SplitK();
                int             kSum   = 0;
                for (int iKelems = 0; iKelems < kelems.Count; iKelems++)
                {
                    KElement kelem  = kelems[iKelems];
                    int      x      = (PlayResX - MarginLeft - MarginRight - (kelems.Count * FontWidth)) / 2 + MarginLeft + iKelems * FontWidth;
                    int      y      = MarginTop;
                    double   scale  = (double)(kelems.Count - iKelems) / (double)kelems.Count;
                    double   kStart = (double)kSum * 0.01;
                    double   kEnd   = (double)(kSum + kelem.KValue) * 0.01;
                    kSum += kelem.KValue;
                    outass.Events.Add(ev.StartOffset(-0.8 * scale).TextReplace(
                                          ASSEffect.t(0, 0.6, @"\1a&HDD&\3a&H11&") +                                               // fade in
                                          ASSEffect.t(kStart + 0.8 * scale + 0.2, kStart + 0.8 * scale + 0.2 + 0.1, @"\3a&HFF&") + // remove outline
                                          ASSEffect.t(ev.Last - 0.6 - 0.8 * scale, ev.Last - 0.8 * scale, @"\1a&HFF&\3a&HFF&") +   // fade out
                                          ASSEffect.pos(x, y) + kelem.KText));
                    outass.Events.Add(ev.LayerReplace(1).StartOffset(kStart + 0.2).TextReplace(
                                          ASSEffect.a(1, "00") + ASSEffect.c(1, "333333") + ASSEffect.a(3, "FF") +                                         // color
                                          ASSEffect.fad(0.3, 0) +                                                                                          // fade
                                          ASSEffect.t(0, 0.1, @"\3a&HFF&") +                                                                               // remove outline
                                          ASSEffect.t(ev.Last - (kStart + 0.2) - 0.6 - 0.8 * scale, ev.Last - (kStart + 0.2) - 0.8 * scale, @"\1a&HFF&") + // fade out
                                          ASSEffect.pos(x, y) + kelem.KText));
                    outass.Events.Add(ev.LayerReplace(1).StartOffset(kStart).EndReplace(ev.Start + kStart + 0.3).TextReplace(
                                          ASSEffect.a(1, "AA") + ASSEffect.c(1, "333333") + ASSEffect.a(3, "FF") + // color
                                          ASSEffect.fad(0.2, 0.1) +                                                // fade
                                          ASSEffect.move(x, y - 5, x, y) + kelem.KText));
                    outass.Events.Add(ev.LayerReplace(1).StartOffset(kStart).EndReplace(ev.Start + kStart + 0.3).TextReplace(
                                          ASSEffect.a(1, "AA") + ASSEffect.c(1, "333333") + ASSEffect.a(3, "FF") + // color
                                          ASSEffect.fad(0.2, 0.1) +                                                // fade
                                          ASSEffect.move(x, y + 5, x, y) + kelem.KText));
                }
            }

            for (int countEvent = 1; countEvent < 4; countEvent++)
            {
                ASSEvent        ev     = ass.Events[countEvent];
                List <KElement> kelems = ev.SplitK();
                int             kSum   = 0;
                for (int iKelems = 0; iKelems < kelems.Count; iKelems++)
                {
                    KElement kelem  = kelems[iKelems];
                    int      x      = (PlayResX - MarginLeft - MarginRight - (kelems.Count * FontWidth)) / 2 + MarginLeft + iKelems * FontWidth;
                    int      y      = MarginTop;
                    double   scale  = (double)(kelems.Count - iKelems) / (double)kelems.Count;
                    double   kStart = (double)kSum * 0.01;
                    double   kEnd   = (double)(kSum + kelem.KValue) * 0.01;
                    kSum += kelem.KValue;
                    outass.Events.Add(ev.StartOffset(-0.8 * scale).TextReplace(
                                          ASSEffect.t(0, 0.6, @"\1a&HDD&\3a&H11&") +                                             // fade in
                                          ASSEffect.t(ev.Last - 0.6 - 0.8 * scale, ev.Last - 0.8 * scale, @"\1a&HFF&\3a&HFF&") + // fade out
                                          ASSEffect.pos(x, y) + kelem.KText));
                    outass.Events.Add(ev.LayerReplace(1).StartOffset(kStart + 0.2).TextReplace(
                                          ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") + ASSEffect.a(3, "FF") +                                         // color
                                          ASSEffect.fad(0.3, 0) +                                                                                          // fade
                                          ASSEffect.t(ev.Last - (kStart + 0.2) - 0.6 - 0.8 * scale, ev.Last - (kStart + 0.2) - 0.8 * scale, @"\1a&HFF&") + // fade out
                                          ASSEffect.pos(x, y) + kelem.KText));
                    outass.Events.Add(ev.LayerReplace(1).StartOffset(kStart).EndReplace(ev.Start + kStart + 0.3).TextReplace(
                                          ASSEffect.a(1, "AA") + ASSEffect.c(1, "FFFFFF") + ASSEffect.a(3, "FF") + // color
                                          ASSEffect.fad(0.2, 0.1) +                                                // fade
                                          ASSEffect.move(x, y - 5, x, y) + kelem.KText));
                    outass.Events.Add(ev.LayerReplace(1).StartOffset(kStart).EndReplace(ev.Start + kStart + 0.3).TextReplace(
                                          ASSEffect.a(1, "AA") + ASSEffect.c(1, "FFFFFF") + ASSEffect.a(3, "FF") + // color
                                          ASSEffect.fad(0.2, 0.1) +                                                // fade
                                          ASSEffect.move(x, y + 5, x, y) + kelem.KText));
                }
            }

            for (int countEvent = 4; countEvent < 8; countEvent++)
            {
                ASSEvent        ev     = ass.Events[countEvent];
                List <KElement> kelems = ev.SplitK();
                int             kSum   = 0;
                for (int iKelems = 0; iKelems < kelems.Count; iKelems++)
                {
                    KElement kelem  = kelems[iKelems];
                    int      x      = (countEvent <= 5) ? (MarginLeft + iKelems * FontWidth) : (PlayResX - MarginRight - (kelems.Count - iKelems) * FontWidth);
                    int      y      = MarginTop;
                    double   scale  = (double)(kelems.Count - iKelems) / (double)kelems.Count;
                    double   kStart = (double)kSum * 0.01;
                    double   kEnd   = (double)(kSum + kelem.KValue) * 0.01;
                    kSum += kelem.KValue;

                    double t1 = ev.Start - 0.8 * scale;
                    double t2 = t1 + 0.6;
                    double t3 = ev.End - 0.8 * scale;
                    double t4 = t3 + 0.6;
                    outass.Events.Add(ev.StartReplace(t1).EndReplace(t2).TextReplace(
                                          ASSEffect.a(2, "00") + ASSEffect.c(2, "FFFFFF") +
                                          ASSEffect.t(0, 0.6, @"\1a&HDD&\3a&H11&") + // fade in
                                          ASSEffect.move(x, y - 8, x, y) + kelem.KText));
                    outass.Events.Add(ev.StartReplace(t2).EndReplace(t3).TextReplace(
                                          ASSEffect.a(2, "00") + ASSEffect.c(2, "FFFFFF") +
                                          ASSEffect.a(1, "DD") + ASSEffect.a(3, "11") + // hold
                                          ASSEffect.pos(x, y) + kelem.KText));
                    outass.Events.Add(ev.StartReplace(t3).EndReplace(t4).TextReplace(
                                          ASSEffect.a(1, "00") + ASSEffect.c(2, "FFFFFF") + ASSEffect.a(3, "11") +
                                          ASSEffect.t(0, 0.6, @"\1a&HFF&\3a&HFF&") + // fade out
                                          ASSEffect.move(x, y, x, y + 8) + kelem.KText));
                    outass.Events.Add(ev.LayerReplace(1).StartReplace(ev.Start + kStart).EndReplace(t3).TextReplace(
                                          ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") +
                                          ASSEffect.a(2, "DD") +
                                          ASSEffect.K(kEnd - kStart) + // karaoke
                                          ASSEffect.pos(x, y) + kelem.KText));
                }
            }

            for (int countEvent = 8; countEvent < 12; countEvent++)
            {
                ASSEvent        ev     = ass.Events[countEvent];
                List <KElement> kelems = ev.SplitK();
                int             kSum   = 0;
                for (int iKelems = 0; iKelems < kelems.Count; iKelems++)
                {
                    KElement kelem  = kelems[iKelems];
                    int      x      = MarginLeft + (countEvent - 8) * FontWidth;
                    int      y      = MarginTop + iKelems * FontHeight;
                    double   scale  = (double)(kelems.Count - iKelems) / (double)kelems.Count;
                    double   kStart = (double)kSum * 0.01;
                    double   kEnd   = (double)(kSum + kelem.KValue) * 0.01;
                    kSum += kelem.KValue;
                    outass.Events.Add(ev.EndOffset(1.0).TextReplace(
                                          ASSEffect.t(0, 0.2, @"\1a&HDD&\3a&H11&") +                             // fade in
                                          ASSEffect.t(ev.Last + 1.0 - 0.6, ev.Last + 1.0, @"\1a&HFF&\3a&HFF&") + // fade out
                                          ASSEffect.pos(x, y) + kelem.KText));
                    outass.Events.Add(ev.StartOffset(kStart).EndReplace(ev.Start + kStart + 0.3).TextReplace(
                                          ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") +
                                          ASSEffect.fad(0.2, 0.1) +
                                          ASSEffect.pos(x, y) + kelem.KText));
                }
            }

            for (int countEvent = 12; countEvent < 16; countEvent++)
            {
                ASSEvent        ev     = ass.Events[countEvent];
                List <KElement> kelems = ev.SplitK();
                int             kSum   = 0;
                for (int iKelems = 0; iKelems < kelems.Count; iKelems++)
                {
                    KElement kelem  = kelems[iKelems];
                    int      x      = PlayResX - MarginRight - (countEvent - 11) * FontWidth;
                    int      y      = MarginTop + iKelems * FontHeight;
                    double   scale  = (double)(kelems.Count - iKelems) / (double)kelems.Count;
                    double   kStart = (double)kSum * 0.01;
                    double   kEnd   = (double)(kSum + kelem.KValue) * 0.01;
                    kSum += kelem.KValue;
                    outass.Events.Add(ev.EndOffset(1.0).TextReplace(
                                          ASSEffect.t(0, 0.2, @"\1a&HDD&\3a&H11&") +                             // fade in
                                          ASSEffect.t(ev.Last + 1.0 - 0.6, ev.Last + 1.0, @"\1a&HFF&\3a&HFF&") + // fade out
                                          ASSEffect.pos(x, y) + kelem.KText));
                    outass.Events.Add(ev.StartOffset(kStart).EndReplace(ev.Start + kStart + 0.3).TextReplace(
                                          ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") +
                                          ASSEffect.fad(0.2, 0.1) +
                                          ASSEffect.pos(x, y) + kelem.KText));
                }
            }

            for (int countEvent = 16; countEvent < 20; countEvent++)
            {
                ASSEvent        ev     = ass.Events[countEvent];
                List <KElement> kelems = ev.SplitK();
                int             kSum   = 0;
                for (int iKelems = 0; iKelems < kelems.Count; iKelems++)
                {
                    KElement kelem  = kelems[iKelems];
                    int      x      = MarginLeft + (countEvent - 16) * FontWidth;
                    int      y      = MarginTop + iKelems * FontHeight;
                    double   scale  = (double)(kelems.Count - iKelems) / (double)kelems.Count;
                    double   kStart = (double)kSum * 0.01;
                    double   kEnd   = (double)(kSum + kelem.KValue) * 0.01;
                    kSum += kelem.KValue;
                    outass.Events.Add(ev.EndOffset(1.0).TextReplace(
                                          ASSEffect.t(0, 0.2, @"\1a&HDD&\3a&H11&") +                             // fade in
                                          ASSEffect.t(ev.Last + 1.0 - 0.6, ev.Last + 1.0, @"\1a&HFF&\3a&HFF&") + // fade out
                                          ASSEffect.pos(x, y) + kelem.KText));
                    outass.Events.Add(ev.StartOffset(kStart).EndReplace(ev.Start + kStart + 0.3).TextReplace(
                                          ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") +
                                          ASSEffect.fad(0.2, 0.1) +
                                          ASSEffect.pos(x, y) + kelem.KText));
                }
            }

            for (int countEvent = 20; countEvent < 23; countEvent++)
            {
                ASSEvent        ev     = ass.Events[countEvent];
                List <KElement> kelems = ev.SplitK();
                int             kSum   = 0;
                for (int iKelems = 0; iKelems < kelems.Count; iKelems++)
                {
                    KElement kelem  = kelems[iKelems];
                    int      x      = PlayResX - MarginRight - (countEvent - 19) * FontWidth;
                    int      y      = MarginTop + iKelems * FontHeight;
                    double   scale  = (double)(kelems.Count - iKelems) / (double)kelems.Count;
                    double   kStart = (double)kSum * 0.01;
                    double   kEnd   = (double)(kSum + kelem.KValue) * 0.01;
                    kSum += kelem.KValue;
                    outass.Events.Add(ev.EndOffset(1.0).TextReplace(
                                          ASSEffect.t(0, 0.2, @"\1a&HDD&\3a&H11&") +                             // fade in
                                          ASSEffect.t(ev.Last + 1.0 - 0.6, ev.Last + 1.0, @"\1a&HFF&\3a&HFF&") + // fade out
                                          ASSEffect.pos(x, y) + kelem.KText));
                    if (countEvent == 22 && iKelems == kelems.Count - 1)
                    {
                        outass.Events.Add(ev.StartOffset(kStart).EndReplace(ev.Start + kStart + 1.2).TextReplace(
                                              ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") +
                                              ASSEffect.fad(0.2, 1) +
                                              ASSEffect.pos(x, y) + kelem.KText));
                    }
                    else
                    {
                        outass.Events.Add(ev.StartOffset(kStart).EndReplace(ev.Start + kStart + 0.3).TextReplace(
                                              ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") +
                                              ASSEffect.fad(0.2, 0.1) +
                                              ASSEffect.pos(x, y) + kelem.KText));
                    }
                }
            }

            for (int countEvent = 23; countEvent < ass.Events.Count; countEvent++)
            {
                outass.Events.Add(ass.Events[countEvent]);
            }

            outass.Shift(Shift);
            outass.SaveFile(OutFileName);
        }
예제 #12
0
        public List <ASSEvent> Create()
        {
            List <ASSEvent> result = new List <ASSEvent>();

            for (int iCount = 0; iCount < Count; iCount++)
            {
                ASSEvent ev = new ASSEvent
                {
                    Layer   = 0,
                    Effect  = "",
                    Name    = "NTP",
                    MarginL = "0000",
                    MarginR = "0000",
                    MarginV = "0000",
                    Style   = Style,
                    Start   = Common.RandomDouble(rnd, Start, End)
                };
                double last = Common.RandomDouble(rnd, MinLast, MaxLast);
                ev.End  = Start + last;
                ev.Text = ASSEffect.an(5) + ASSEffect.fad(0, last);
                if (IsMove && MoveStyle == 1)
                {
                    int x1 = Common.RandomInt(rnd, X, X + FontSize);
                    int y1 = Common.RandomInt(rnd, Y, Y + FontSize);
                    int y2 = Common.RandomInt(rnd, Y + FontSize / 2 - AreaHeight / 2, Y + FontSize / 2 + AreaHeight / 2);
                    int x2 = Common.RandomInt(rnd, X - AreaWidth, X);
                    ev.Text += ASSEffect.move(x1 + XOffset, y1 + YOffset, x2 + XOffset, y2 + YOffset);
                }
                else if (IsMove && MoveStyle == 2)
                {
                    int x1 = Common.RandomInt(rnd, X, X + FontSize);
                    int y1 = Common.RandomInt(rnd, Y, Y + FontSize);
                    int y2 = Common.RandomInt(rnd, Y + FontSize / 2 - AreaHeight / 2, Y + FontSize / 2 + AreaHeight / 2);
                    int x2 = Common.RandomInt(rnd, X + FontSize / 2 - AreaWidth / 2, X + FontSize / 2 + AreaWidth / 2);
                    ev.Text += ASSEffect.move(x1 + XOffset, y1 + YOffset, x2 + XOffset, y2 + YOffset);
                }
                else if (IsMove && MoveStyle == 3)
                {
                    int x1 = X + FontSize / 2;
                    int y1 = Y + FontSize / 2;
                    int y2 = Common.RandomInt(rnd, y1 - AreaHeight / 2, y1 + AreaHeight / 2);
                    int x2 = Common.RandomInt(rnd, x1 - AreaWidth / 2, x1 + AreaWidth / 2);
                    ev.Text += ASSEffect.move(x1 + XOffset, y1 + YOffset, x2 + XOffset, y2 + YOffset);
                }
                else
                {
                    ev.Text += ASSEffect.pos(X + FontSize / 2 + XOffset, Y + FontSize / 2 + YOffset);
                }
                if (!IsRandomColor)
                {
                    ev.Text += ASSEffect.c(Color);
                }
                else
                {
                    ev.Text += ASSEffect.c(Common.RandomColor(rnd, 1, Color1, Color2));
                }
                if (BE > 0)
                {
                    ev.Text += ASSEffect.be(BE);
                }
                if (IsPatternScale)
                {
                    ev.Text += ASSEffect.t(0, last, @"\fscx" + PatternScaleX + @"\fscy" + PatternScaleY);
                }
                if (IsRotate)
                {
                    ev.Text += ASSEffect.t(0, last, ASSEffect.frz((int)(last * 1000)).t());
                }
                ev.Text += (char)ParticlePattern;

                result.Add(ev);
            }
            return(result);
        }
예제 #13
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 ms1    = "Style: Default,DFGMaruGothic-Md,26,&H00FF0000,&HFF600D00,&H000000FF,&HFF0A5A84,-1,0,0,0,100,100,0,0,0,2,0,5,20,20,20,128";
            string ms3    = "Style: Default,DFGMaruGothic-Md,26,&H000000FF,&HFF600D00,&H00FF0000,&HFF0A5A84,-1,0,0,0,100,100,0,0,0,2,0,5,20,20,20,128";
            string ptstr  = @"{\p1}m 0 0 l 1 0 1 1 0 1";
            string pt0Str = @"{\blur2\bord3\p4}m 5 5 s 5 -5 -5 -5 -5 5";

            Random rnd = new Random();

            InitBFS();

            for (int iEv = 0; iEv < ass_in.Events.Count; iEv++)
            {
                //if (iEv < 8) continue;
                ASSEvent        ev     = ass_in.Events[iEv];
                List <KElement> kelems = ev.SplitK(false);

                this.MaskStyle = ms3;
                /// an7 pos
                int x0 = PlayResX - MarginRight - FontWidth;
                if (iEv % 2 == 0)
                {
                    x0 = MarginLeft;
                }
                int startx0 = x0;
                int y0      = MarginTop;

                int kSum = 0;

                int           lum0count = 0;
                List <double> lum0x     = new List <double>();
                List <double> lum0y     = new List <double>();
                for (int lumy0 = -20; lumy0 < PlayResY;)
                {
                    lumy0 += Common.RandomInt(rnd, 5, 10);
                    lum0y.Add(lumy0);
                    lum0x.Add(Common.RandomInt(rnd, x0 - 2, x0 + FontWidth + 2));
                    lum0count++;
                }

                int           lumcount = 0;
                List <double> lumx     = new List <double>();
                List <double> lumy     = new List <double>();
                for (int lumy0 = -20; lumy0 < PlayResY;)
                {
                    lumy0 += Common.RandomInt(rnd, 20, 40);
                    lumy.Add(lumy0);
                    lumx.Add(Common.RandomInt(rnd, x0 - 10, x0 + FontWidth + 10));
                    lumcount++;
                }

                string[] lumcol =
                {
                    "003DB8",
                };

                for (int iK = 0; iK < kelems.Count; iK++)
                {
                    if (iK == 16)
                    {
                        int sadf = 2;
                    }
                    //if (iK > 3) continue;
                    Console.WriteLine("{0} / {1} : {2} / {3}", iEv + 1, ass_in.Events.Count, iK + 1, kelems.Count);
                    KElement ke = kelems[iK];
                    double   r  = (double)iK / (double)(kelems.Count - 1);
                    this.MaskStyle = ms3;
                    StringMask mask = GetMask(ke.KText, x0, y0);
                    Size       sz   = new Size(mask.Width, mask.Height);

                    double kStart = ev.Start + kSum * 0.01;
                    double kEnd   = kStart + ke.KValue * 0.01;
                    kSum += ke.KValue;

                    /// an5 pos
                    int x     = x0 + FontWidth / 2;
                    int y     = y0 + FontHeight / 2;
                    int baky0 = y0;
                    y0 += sz.Height + FontSpace;

                    Console.WriteLine(y0);

                    this.MaskStyle = ms1;
                    mask           = GetMask(ke.KText, x, y);

                    int bakx0 = x0;

                    if (ke.KText.Trim().Length == 0)
                    {
                        continue;
                    }

                    double t0  = ev.Start - 1.0 + r * 2;
                    double t1  = t0 + 1;
                    double t11 = kStart - 0.4;
                    double t2  = ev.End;

                    ass_out.Events.Add(
                        ev.StartReplace(t11).EndReplace(t11 + 0.8).TextReplace(
                            ASSEffect.pos(x, y) + ASSEffect.a(1, "00") + ASSEffect.a(3, "00") + ASSEffect.c(1, "FFFFFF") + ASSEffect.c(3, "FFFFFF") +
                            ASSEffect.fad(0.2, 0.6) + ASSEffect.bord(0) + ASSEffect.blur(0) +
                            ASSEffect.t(0, 1, ASSEffect.bord(5).t() + ASSEffect.blur(5).t()) +
                            ke.KText));
                    ass_out.Events.Add(
                        ev.StartReplace(t11 + 0.4).EndReplace(t2 + 0.5).TextReplace(
                            ASSEffect.pos(x, y) + ASSEffect.a(1, "00") + ASSEffect.a(3, "00") + ASSEffect.c(1, "FFFFFF") + ASSEffect.c(3, "FFFFFF") +
                            ASSEffect.fad(0.4, 1) + ASSEffect.bord(2) + ASSEffect.blur(2) +
                            ke.KText));

                    int[]    ind = CalculateBFSOrder(mask);
                    double[] wt  = new double[mask.Points.Count];
                    double[] wt0 = new double[mask.Points.Count];
                    for (int i = 0; i < ind.Length; i++)
                    {
                        ASSPoint pt = mask.Points[i];
                        double   ag = Common.GetAngle(pt.X, pt.Y, x, y);
                        double   r0 = Common.GetDistance(pt.X, pt.Y, x, y) * 1.0;
                        double   r1 = Common.GetDistance(pt.X, pt.Y, x, y) * 1.3;
                        //double r2 = Common.GetDistance(pt.X, pt.Y, x, y) * 1.1;
                        double ptx0 = pt.X; // (double)x + Math.Cos(ag) * r0;
                        double pty0 = pt.Y; // (double)y - Math.Sin(ag) * r0;
                        double ptx  = (double)x + Math.Cos(ag) * r1;
                        double pty  = (double)y - Math.Sin(ag) * r1;
                        //double ptx2 = (double)x + Math.Cos(ag) * r2;
                        //double pty2 = (double)y - Math.Sin(ag) * r2;
                        string bt  = Common.ToHex2((255 - pt.Brightness) * Common.RandomDouble(rnd, 0.7, 0.9));
                        string bt2 = bt;
                        string bt3 = Common.ToHex2((255 - pt.Brightness * 0.8) * Common.RandomDouble(rnd, 0.7, 0.9));
                        double pt2 = kStart + (kEnd - kStart) * (pt.Y - baky0) / mask.Height + Common.RandomDouble_Gauss(rnd, -0.15, 0.00, 2);
                        wt[i] = 1;
                        for (int j = 0; j < lumcount; j++)
                        {
                            double dis = Common.GetDistance(pt.X, pt.Y, lumx[j], lumy[j]) / 35.0;
                            if (wt[i] > dis)
                            {
                                wt[i] = dis;
                            }
                        }
                        wt0[i] = 1;
                        for (int j = 0; j < lum0count; j++)
                        {
                            double dis = Common.GetDistance(pt.X, pt.Y, lum0x[j], lum0y[j]) / 8.0;
                            if (wt0[i] > dis)
                            {
                                wt0[i] = dis;
                            }
                        }
                        string col0 = Common.scaleColor("222222", "FFFFFF", wt0[i]);
                        double pt3  = t2 + wt[i] + Common.RandomDouble_Gauss(rnd, -0.08, 0.08, 2);

                        ass_out.Events.Add(
                            ev.StartReplace(pt2 - 0.1).EndReplace(pt2).StyleReplace("pt").LayerReplace(15).TextReplace(
                                ASSEffect.a(1, "CC") + ASSEffect.c(1, "FFFFFF") + ASSEffect.a(3, "CC") + ASSEffect.c(1, "FFFFFF") +
                                ASSEffect.bord(1) + ASSEffect.be(1) +
                                ASSEffect.pos(ptx0, pty0) + ptstr));

                        string ptc = Common.scaleColor("FFFFFF", lumcol[0], wt[i]);
                        ass_out.Events.Add(
                            ev.StartReplace(t0).EndReplace(t1).StyleReplace("pt").TextReplace(
                                ASSEffect.a(1, bt) + ASSEffect.c(1, col0) + ASSEffect.fad(0.1, 0) + ASSEffect.a(3, "FF") +
                                ASSEffect.move(ptx, pty, ptx0, pty0) + ptstr));
                        ass_out.Events.Add(
                            ev.StartReplace(t1).EndReplace(pt2 + 0.2).StyleReplace("pt").TextReplace(
                                ASSEffect.a(1, bt) + ASSEffect.c(1, col0) + ASSEffect.a(3, "FF") +
                                ASSEffect.fad(0, 0.3) +
                                ASSEffect.pos(ptx0, pty0) + ptstr));
                        ass_out.Events.Add(
                            ev.StartReplace(pt2 - 0.1).EndReplace(pt3).StyleReplace("pt").TextReplace(
                                ASSEffect.a(1, bt2) + ASSEffect.c(1, ptc) + ASSEffect.a(3, "FF") +
                                ASSEffect.fad(0.3, 0.3) +
                                ASSEffect.pos(ptx0, pty0) + ptstr));
                    }

                    for (int i = 0; i < (int)(Math.Round((kEnd - kStart) * 200)); i++)
                    {
                        ASSPoint pt  = mask.Points[Common.RandomInt(rnd, 0, mask.Points.Count - 1)];
                        double   pt0 = Common.RandomDouble(rnd, kStart, kEnd);
                        double   pt1 = pt0 + 1.5;
                        string   ptc = lumcol[0];
                        ptc = Common.scaleColor(ptc, "FFFFFF", 0.65);
                        ass_out.Events.Add(
                            ev.StartReplace(pt0).EndReplace(pt1).StyleReplace("pt").LayerReplace(5).TextReplace(
                                ASSEffect.move(pt.X, pt.Y, Common.RandomInt(rnd, pt.X + 50, pt.X - 50), Common.RandomInt(rnd, pt.Y + 35, pt.Y - 35)) +
                                ASSEffect.fad(0, 0.3) + ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") +
                                ASSEffect.a(3, "00") + ASSEffect.c(3, ptc) +
                                ASSEffect.bord(2) + ASSEffect.blur(2) + CreatePolygon(rnd, 15, 15, 6)));
                    }
                }
            }

            ass_out.SaveFile(OutFileName);
            Console.WriteLine("Lines : {0}", ass_out.Events.Count);
        }
예제 #14
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 ms1   = "Style: Default,DFGMaruGothic-Md,35,&H00FF0000,&HFF000000,&HFFFFFFFF,&HFFFF0000,-1,0,0,0,100,100,2,0,1,2,0,5,25,25,25,128";
            string ptstr = @"{\p1}m 0 0 l 1 0 1 1 0 1";

            Random rnd = new Random();

            for (int iEv = 0; iEv < ass_in.Events.Count; iEv++)
            {
                //if (iEv != 1) continue;
                ASSEvent        ev     = ass_in.Events[iEv];
                List <KElement> kelems = ev.SplitK(false);

                this.MaskStyle = ms1;
                int x0      = MarginLeft;
                int startx0 = x0;
                int y0      = PlayResY - MarginBottom - FontHeight;

                if (iEv == -1)
                {
                    bool zz = false;
                    foreach (Beat bt in GetBeats())
                    {
                        ass_out.Events.Add(
                            ev.StartReplace(bt.Time).EndReplace(bt.Time + 0.3).TextReplace(
                                ASSEffect.pos(30, zz ? 30 : 80) + ASSEffect.an(7) + ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") + ASSEffect.a(3, "FF") +
                                ASSEffect.fad(0.05, 0.2) +
                                string.Format("ID:{0} STR:{1}", bt.Id, bt.Strength)));
                        zz = !zz;
                    }
                }

                if (iEv == 0)
                {
                    int   reg0      = 0;
                    int[] blurstrar = new int[] { 2, 3, 4, 5, 6, 7, 8 };
                    blurstrar = blurstrar.Select(bs => bs + 4).ToArray();
                    foreach (Beat bt in GetBeats())
                    {
                        if (bt.Id >= 151)
                        {
                            if (bt.Reg)
                            {
                                reg0 = 0;
                            }
                            else
                            {
                                reg0++;
                            }
                            int blurstr = blurstrar[reg0];
                            ass_out.Events.Add(
                                ev.StartReplace(bt.Time).EndReplace(bt.Time + 0.3).LayerReplace(5).TextReplace(
                                    ASSEffect.an(7) + ASSEffect.pos(0, 0) +
                                    ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") +
                                    ASSEffect.a(3, "44") + ASSEffect.c(3, "ED6D64") +
                                    ASSEffect.fad(0.05, 0.2) +
                                    ASSEffect.blur(blurstr) + ASSEffect.bord(blurstr) +
                                    @"{\p1}m 0 678 l 1280 678 1280 679 0 679"));
                            ass_out.Events.Add(
                                ev.StartReplace(bt.Time).EndReplace(bt.Time + 0.3).LayerReplace(6).TextReplace(
                                    ASSEffect.an(7) + ASSEffect.pos(0, 0) +
                                    ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") +
                                    ASSEffect.a(3, "44") + ASSEffect.c(3, "FFFFFF") +
                                    ASSEffect.fad(0.05, 0.2) +
                                    ASSEffect.blur(2) + ASSEffect.bord(2) +
                                    @"{\p1}m 0 678 l 1280 678 1280 679 0 679"));
                        }
                    }

                    foreach (Beat bt in GetBeats())
                    {
                        if (bt.Id < 151 || bt.Strength == 0)
                        {
                            continue;
                        }
                        for (int i = 0; i < 0.3 * 1500; i++)
                        {
                            double parx0 = Common.RandomInt(rnd, 0, PlayResX);
                            double pary0 = Common.RandomInt(rnd, 678 - 30, 678 + 20);
                            double parx1 = parx0 + Common.RandomInt(rnd, -5, 5);
                            double pary1 = pary0 - 30;
                            double part0 = bt.Time;
                            double part1 = bt.Time + 0.3;
                            ass_out.Events.Add(
                                ev.StartReplace(part0).EndReplace(part1).StyleReplace("pt").LayerReplace(3).TextReplace(
                                    ASSEffect.move(parx0, pary0, parx1, pary1) +
                                    ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") +
                                    ASSEffect.a(3, "55") + ASSEffect.c(3, "ED6D64") +
                                    ASSEffect.bord(2) + ASSEffect.blur(2) +
                                    ASSEffect.fad(0.05, 0.2) +
                                    ASSEffect.frz(Common.RandomInt(rnd, 0, 360)) +
                                    CreatePolygon(rnd, 10, 25, 6)));
                        }
                    }
                }

                int kSum = 0;

                //if (!(iEv == 1 || iEv == 3 || iEv == 5 || iEv == 7))
                if (iEv + 1 < ass_in.Events.Count && ass_in.Events[iEv + 1].Start - ev.End > 0.5)
                {
                    ev.End = ass_in.Events[iEv + 1].Start - 0.5;
                }

                for (int iK = 0; iK < kelems.Count; iK++)
                {
                    //if (iK > 3) continue;
                    Console.WriteLine("{0} / {1} : {2} / {3}", iEv + 1, ass_in.Events.Count, iK + 1, kelems.Count);
                    KElement ke = kelems[iK];
                    double   r  = (double)iK / (double)(kelems.Count - 1);
                    this.MaskStyle = ms1;
                    Size sz = GetSize(ke.KText);
                    if (ke.KText.Trim() == "")
                    {
                        sz.Width = 15;
                    }
                    double kStart = ev.Start + kSum * 0.01;
                    double kEnd   = kStart + ke.KValue * 0.01;
                    kSum += ke.KValue;
                    if (iK + 1 == kelems.Count && kEnd < ev.End)
                    {
                        kEnd = ev.End;
                    }
                    int        x    = x0 + this.FontSpace + sz.Width / 2;
                    int        y    = y0 + FontHeight / 2;
                    StringMask mask = GetMask(ke.KText, x, y);
                    x0 += this.FontSpace + sz.Width;
                    y0  = y0;
                    if (ke.KText.Trim().Length == 0)
                    {
                        continue;
                    }

                    double r0 = ev.Start - 0.3;
                    double t0 = kStart - 0.4;
                    double t1 = t0 + 0.4;
                    double t2 = ev.End;

                    double r1 = r0 + 0.3;
                    if (!(iEv == 0 || iEv == 2 || iEv == 4 || iEv == 6 || iEv == 8))
                    {
                        for (int i = -1; i <= 1; i++)
                        {
                            ass_out.Events.Add(
                                ev.StartReplace(r0).EndReplace(r1).TextReplace(
                                    ASSEffect.move(x + i * 10, y, x, y) + ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") +
                                    ASSEffect.a(3, "00") + ASSEffect.c(3, "FFFFFF") +
                                    ASSEffect.xbord(20) + ASSEffect.be(20) + ASSEffect.ybord(0) +
                                    ASSEffect.t(0, r1 - r0, ASSEffect.xbord(0).t() + ASSEffect.be(0).t()) +
                                    ASSEffect.fad((r1 - r0) * 1, 0) +
                                    ke.KText));
                        }
                    }
                    else
                    {
                        ass_out.Events.Add(
                            ev.StartReplace(ev.Start - 0.3).EndReplace(t1).LayerReplace(10).TextReplace(
                                ASSEffect.pos(x, y) + ASSEffect.a(1, "77") + ASSEffect.c(1, "777777") + ASSEffect.a(3, "FF") +
                                ASSEffect.fad(0.5, 0) +
                                ke.KText));
                    }

                    if (iEv == 4 || iEv == 5)
                    {
                        ass_out.Events.Add(
                            ev.StartReplace(kStart - 0.1).EndReplace(kEnd).StyleReplace("pt").LayerReplace(0).TextReplace(
                                ASSEffect.an(7) + ASSEffect.pos(0, 0) +
                                ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") +
                                ASSEffect.a(3, "77") + ASSEffect.c(3, "ED6D64") +
                                ASSEffect.bord(10) + ASSEffect.blur(10) +
                                ASSEffect.fad(0.2, 0.2) +
                                @"{\p1}" + string.Format("m {0} {1} l {0} {2} {3} {2} {3} {1}", x, PlayResY, PlayResY - MarginBottom - FontHeight - 285, x + 1)));
                        ass_out.Events.Add(
                            ev.StartReplace(kStart - 0.1).EndReplace(kEnd).StyleReplace("pt").LayerReplace(1).TextReplace(
                                ASSEffect.an(7) + ASSEffect.pos(0, 0) +
                                ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") +
                                ASSEffect.a(3, "77") + ASSEffect.c(3, "FFFFFF") +
                                ASSEffect.bord(2) + ASSEffect.blur(2) +
                                ASSEffect.fad(0.2, 0.2) +
                                @"{\p1}" + string.Format("m {0} {1} l {0} {2} {3} {2} {3} {1}", x, PlayResY, PlayResY - MarginBottom - FontHeight - 285, x + 1)));
                        for (int i = 0; i < (int)((kEnd - kStart) * 200); i++)
                        {
                            double parx0 = Common.RandomInt(rnd, x - 5, x + 5);
                            double pary0 = Common.RandomInt(rnd, PlayResY - MarginBottom - FontHeight - 285, PlayResY);
                            double parx1 = parx0 + Common.RandomInt(rnd, -20, 20);
                            double pary1 = pary0 + Common.RandomInt(rnd, -5, 5);
                            double part0 = Common.RandomDouble(rnd, kStart - 0.1, kEnd - 0.1);
                            double part1 = part0 + Common.GetDistance(parx0, pary0, parx1, pary1) / 50.0;
                            ass_out.Events.Add(
                                ev.StartReplace(part0).EndReplace(part1).StyleReplace("pt").LayerReplace(3).TextReplace(
                                    ASSEffect.move(parx0, pary0, parx1, pary1) +
                                    ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") +
                                    ASSEffect.a(3, "55") + ASSEffect.c(3, "ED6D64") +
                                    ASSEffect.bord(2) + ASSEffect.blur(2) +
                                    ASSEffect.fad(0.05, 0.2) +
                                    ASSEffect.frz(Common.RandomInt(rnd, 0, 360)) +
                                    CreatePolygon(rnd, 10, 25, 6)));
                        }
                    }

                    if (iEv == 0 || iEv == 2 || iEv == 4 || iEv == 6 || iEv == 8)
                    {
                        double dt = 0.002;
                        double dx, dy;
                        {
                            double t   = t1;
                            double ag  = Math.PI * 2.0 * (t - t0) / (t1 - t0) - Math.PI * 0.5;
                            double ca  = 40;
                            double cb  = 18;
                            double cx0 = ca * Math.Cos(ag);
                            double cy0 = cb * Math.Sin(-ag);
                            double cag = Math.PI * 0.25;
                            double cx1 = cx0 * Math.Cos(cag) + cy0 * Math.Sin(cag);
                            double cy1 = -cx0 *Math.Sin(cag) + cy0 * Math.Cos(cag);

                            dx = -cx1;
                            dy = -cy1;
                        }
                        for (double t = t0; t <= t1; t += dt)
                        {
                            double ag  = Math.PI * 2.0 * (t - t0) / (t1 - t0) - Math.PI * 0.5;
                            double ca  = 40;
                            double cb  = 18;
                            double cx0 = ca * Math.Cos(ag);
                            double cy0 = cb * Math.Sin(-ag);
                            double cag = Math.PI * 0.25;
                            double cx1 = cx0 * Math.Cos(cag) + cy0 * Math.Sin(cag);
                            double cy1 = -cx0 *Math.Sin(cag) + cy0 * Math.Cos(cag);

                            cx1 += x + dx;
                            cy1 += y + dy;
                            int fs = (int)((double)this.FontHeight * (t - t0) / (t1 - t0) + 1);
                            ass_out.Events.Add(
                                ev.StartReplace(t).EndReplace(t + 0.4).LayerReplace(20).TextReplace(
                                    ASSEffect.pos(cx1, cy1) + ASSEffect.fs(fs) +
                                    ASSEffect.a(1, "E0") + ASSEffect.c(1, "FFFFFF") + ASSEffect.a(3, "E0") + ASSEffect.c(3, "FFFFFF") +
                                    ASSEffect.fad(0, 0.3) +
                                    ASSEffect.bord(1) + ASSEffect.blur(1) +
                                    ke.KText));
                            ass_out.Events.Add(
                                ev.StartReplace(t).EndReplace(t + dt).TextReplace(
                                    ASSEffect.pos(cx1, cy1) + ASSEffect.fs(fs) +
                                    ASSEffect.pos(x, y) + ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") + ASSEffect.a(3, "FF") +
                                    ke.KText));
                        }
                        ass_out.Events.Add(
                            ev.StartReplace(t1).EndReplace(t1 + 0.35).LayerReplace(30).TextReplace(
                                ASSEffect.pos(x, y) + ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") + ASSEffect.a(3, "00") + ASSEffect.c(3, "FFFFFF") +
                                ASSEffect.bord(8) + ASSEffect.blur(8) + ASSEffect.fad(0.05, 0.2) +
                                ke.KText));
                        ass_out.Events.Add(
                            ev.StartReplace(t1).EndReplace(t2 + 0.2).LayerReplace(30).TextReplace(
                                ASSEffect.pos(x, y) + ASSEffect.a(1, "BB") + ASSEffect.c(1, "FFFFFF") + ASSEffect.a(3, "BB") + ASSEffect.c(3, "FFFFFF") +
                                ASSEffect.bord(2) + ASSEffect.blur(2) + ASSEffect.fad(0.2, 0.2) +
                                ke.KText));
                        ass_out.Events.Add(
                            ev.StartReplace(t1).EndReplace(t2).TextReplace(
                                ASSEffect.pos(x, y) + ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") + ASSEffect.a(3, "FF") +
                                ke.KText));
                    }
                    else
                    {
                        t0 += 0.2;
                        t1 += 0.2;
                        if (t0 < ev.Start)
                        {
                            t0 = ev.Start;
                            t1 = t0 + 0.4;
                        }
                        ass_out.Events.Add(
                            ev.StartReplace(r1 - 0.2).EndReplace(t0 + 0.2).LayerReplace(30).TextReplace(
                                ASSEffect.pos(x, y) + ASSEffect.a(1, "E0") + ASSEffect.c(1, "FFFFFF") + ASSEffect.a(3, "E0") + ASSEffect.c(3, "FFFFFF") +
                                ASSEffect.bord(2) + ASSEffect.blur(2) + ASSEffect.fad(0.2, 0.2) +
                                ke.KText));
                        ass_out.Events.Add(
                            ev.StartReplace(r1).EndReplace(t0).TextReplace(
                                ASSEffect.pos(x, y) + ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") + ASSEffect.a(3, "FF") +
                                ke.KText));
                        double dt = 0.002;
                        double dx, dy;
                        {
                            double t   = t1;
                            double ag  = Math.PI * 2.0 * (t - t0) / (t1 - t0) - Math.PI * 0.5;
                            double ca  = 40;
                            double cb  = 18;
                            double cx0 = ca * Math.Cos(ag);
                            double cy0 = cb * Math.Sin(-ag);
                            double cag = Math.PI * 0.25;
                            double cx1 = cx0 * Math.Cos(cag) + cy0 * Math.Sin(cag);
                            double cy1 = -cx0 *Math.Sin(cag) + cy0 * Math.Cos(cag);

                            dx = -cx1;
                            dy = -cy1;
                        }
                        for (double t = t0; t <= t1; t += dt)
                        {
                            double ag  = Math.PI * 2.0 * (t1 - t) / (t1 - t0) - Math.PI * 0.5;
                            double ca  = 40;
                            double cb  = 18;
                            double cx0 = ca * Math.Cos(ag);
                            double cy0 = cb * Math.Sin(-ag);
                            double cag = Math.PI * 0.25;
                            double cx1 = cx0 * Math.Cos(cag) + cy0 * Math.Sin(cag);
                            double cy1 = -cx0 *Math.Sin(cag) + cy0 * Math.Cos(cag);

                            cx1 += x + dx;
                            cy1 += y + dy;
                            int fs = (int)((double)this.FontHeight * (t1 - t) / (t1 - t0) + 1);
                            ass_out.Events.Add(
                                ev.StartReplace(t).EndReplace(t + 0.4).LayerReplace(20).TextReplace(
                                    ASSEffect.pos(cx1, cy1) + ASSEffect.fs(fs) +
                                    ASSEffect.a(1, "BB") + ASSEffect.c(1, "FFFFFF") + ASSEffect.a(3, "BB") + ASSEffect.c(3, "FFFFFF") +
                                    ASSEffect.fad(0, 0.3) +
                                    ASSEffect.bord(1) + ASSEffect.blur(1) +
                                    ke.KText));
                            ass_out.Events.Add(
                                ev.StartReplace(t).EndReplace(t + dt).TextReplace(
                                    ASSEffect.pos(cx1, cy1) + ASSEffect.fs(fs) +
                                    ASSEffect.pos(x, y) + ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") + ASSEffect.a(3, "FF") +
                                    ke.KText));
                        }
                    }

                    double bt_lo = t1;
                    bt_lo = ev.Start - 0.3 + 0.2;
                    double bt_hi            = t2;
                    Func <double, bool> bbt = ti => ti >= t1;
                    if (!(iEv == 0 || iEv == 2 || iEv == 4 || iEv == 6 || iEv == 8))
                    {
                        bt_lo = ev.Start - 0.2;
                        bt_hi = t1;
                        bbt   = ti => ti < kStart;
                    }
                    if (iEv == 0 || iEv == 2 || iEv == 4 || iEv == 6 || iEv == 8)
                    {
                        double t3 = t2 + 0.3;
                        if (iEv + 1 < ass_in.Events.Count && ass_in.Events[iEv + 1].Start - ev.End < 0.3)
                        {
                            t3 = t2 + 0.1;
                        }
                        for (int i = -1; i <= 1; i++)
                        {
                            ass_out.Events.Add(
                                ev.StartReplace(t2).EndReplace(t3).TextReplace(
                                    ASSEffect.move(x, y, x + i * 10, y) + ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") +
                                    ASSEffect.a(3, "00") + ASSEffect.c(3, "FFFFFF") +
                                    ASSEffect.bord(0) + ASSEffect.blur(0) +
                                    ASSEffect.t(0, t3 - t2, ASSEffect.xbord(20).t() + ASSEffect.be(20).t()) +
                                    ASSEffect.fad(0, t3 - t2) +
                                    ke.KText));
                        }
                    }
                    else
                    {
                        double te = ev.End + 0.5;
                        //if (iEv == 9) te -= 1;
                        bt_hi = te - 0.5;
                        ass_out.Events.Add(
                            ev.EndReplace(te).LayerReplace(10).TextReplace(
                                ASSEffect.pos(x, y) + ASSEffect.a(1, "77") + ASSEffect.c(1, "777777") + ASSEffect.a(3, "FF") +
                                ASSEffect.fad(0, 0.5) +
                                ke.KText));
                    }

                    foreach (Beat bt in GetBeats())
                    {
                        if (bt.Strength == 0)
                        {
                            continue;
                        }
                        if (bt.Time >= bt_lo && bt.Time < bt_hi)
                        {
                            string col     = "FFFFFF";
                            int    blurstr = 4;
                            string ac      = "44";
                            if (bt.Strength == 2)
                            {
                                col     = "EEEEEE";
                                blurstr = 3;
                                ac      = "77";
                            }
                            if (bt.Strength == 10)
                            {
                                blurstr = 5;
                                ac      = "00";
                            }
                            if (!bbt(bt.Time))
                            {
                                blurstr = 2;
                                col     = "111111";
                            }
                            ass_out.Events.Add(
                                ev.StartReplace(bt.Time).EndReplace(bt.Time + 0.3).LayerReplace(55).TextReplace(
                                    ASSEffect.pos(x, y) + ASSEffect.fad(0.05, 0.2) +
                                    ASSEffect.a(1, ac) + ASSEffect.c(1, col) + ASSEffect.a(3, ac) + ASSEffect.c(3, col) +
                                    ASSEffect.bord(blurstr) + ASSEffect.blur(blurstr) +
                                    ke.KText));
                        }
                    }
                }
            }

            ass_out.SaveFile(OutFileName);
            Console.WriteLine("Lines : {0}", ass_out.Events.Count);
        }
예제 #15
0
        public override void Run()
        {
            string ms3 = "Style: Default,DFGMaruMoji-SL,44,&H0000FFFF,&HFF000000,&H00FF0000,&HFF000000,0,0,0,0,100,100,2,0,1,2,0,5,30,30,10,128";
            string msc = "Style: Default,華康少女文字W5(P),44,&H0000FFFF,&HFF000000,&H00FF0000,&HFF000000,0,0,0,0,100,100,2,0,1,2,0,5,30,30,10,136";
            // 8BFF97 green

            ASS ass_in  = ASS.FromFile(this.InFileName);
            ASS ass_out = new ASS();

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

            Random rnd = new Random();

            int testEv = -1;

            for (int iEv = 0; iEv <= 22; iEv++)
            {
                if (testEv >= 0 && iEv != testEv)
                {
                    continue;
                }
                ASSEvent        ev     = ass_in.Events[iEv];
                List <KElement> kelems = ev.SplitK(false);

                this.MaskStyle = ms3;
                double sw = (iEv % 2 == 0) ? 0 : GetTotalWidth(ev);
                /// an7 pos
                int x0 = (iEv % 2 == 0) ? MarginLeft : (int)(PlayResX - MarginRight - sw);
                int y0 = PlayResY - MarginBottom - FontHeight;

                int kSum = 0;

                for (int iK = 0; iK < kelems.Count; iK++)
                {
                    //if (iK > 3) continue;
                    Console.WriteLine("{0} / {1} : {2} / {3}", iEv + 1, ass_in.Events.Count, iK + 1, kelems.Count);
                    KElement ke = kelems[iK];
                    double   r  = (double)iK / (double)(kelems.Count - 1);
                    this.MaskStyle = ms3;
                    StringMask mask = GetMask(ke.KText, x0, y0);
                    Size       sz   = new Size(mask.Width, mask.Height);

                    double kStart = ev.Start + kSum * 0.01;
                    double kEnd   = kStart + ke.KValue * 0.01;
                    kSum += ke.KValue;

                    /// an5 pos
                    int x = x0 + this.FontSpace + sz.Width / 2;
                    int y = y0 + FontHeight / 2;

                    x0 += this.FontSpace + sz.Width;
                    y0  = y0;

                    if (ke.KText.Trim().Length == 0)
                    {
                        continue;
                    }

                    string col1  = "3CD846";
                    string green = col1;
                    if (iEv == 1)
                    {
                        col1 = "C13BA5";
                    }
                    if (iEv == 2)
                    {
                        col1 = "3E58A6";
                    }
                    if (iEv == 3)
                    {
                        col1 = (iK % 2 == 0) ? "D4004D" : "E79805";
                    }
                    if (iEv == 4)
                    {
                        if (iK <= 7)
                        {
                            col1 = (iK % 2 == 0) ? "D4004D" : "E79805";
                        }
                        else if (iK <= 9)
                        {
                            col1 = "1FBD3E";
                        }
                        else
                        {
                            col1 = "C41426";
                        }
                    }
                    if (iEv == 5)
                    {
                        if (iK >= 8 && iK <= 10)
                        {
                            col1 = "F1D53C";
                        }
                    }
                    if (iEv == 6)
                    {
                        if (iK >= 4 && iK <= 8)
                        {
                            col1 = "F1D53C";
                        }
                        else if (iK >= 10)
                        {
                            col1 = "F25756";
                        }
                    }
                    if (iEv == 7)
                    {
                        if (iK >= 6 && iK <= 10)
                        {
                            col1 = "5D477C";
                        }
                    }
                    if (iEv == 8)
                    {
                        if (iK <= 1)
                        {
                            col1 = "5D477C";
                        }
                    }
                    if (iEv == 9)
                    {
                        col1 = "4399AE";
                    }
                    if (iEv == 10 || iEv == 11)
                    {
                        col1 = "AE4343";
                    }
                    if (iEv == 12)
                    {
                        col1 = "4344AE";
                    }
                    if (iEv == 13)
                    {
                        col1 = (iK % 2 == 0) ? green : "DC49A6";
                    }
                    if (iEv == 14)
                    {
                        col1 = (iK % 2 == 0) ? green : "C13BA5";
                    }
                    if (iEv == 15)
                    {
                        col1 = (iK % 2 == 0) ? green : "3E58A6";
                    }
                    if (iEv == 16)
                    {
                        col1 = (iK % 2 == 0) ? "D4004D" : "E79805";
                    }
                    if (iEv == 17)
                    {
                        if (iK <= 7)
                        {
                            col1 = (iK % 2 == 0) ? "D4004D" : "E79805";
                        }
                        else if (iK <= 9)
                        {
                            col1 = "1FBD3E";
                        }
                        else
                        {
                            col1 = "C41426";
                        }
                    }
                    if (iEv == 18 || iEv == 19)
                    {
                        col1 = (iK % 2 == 0) ? green : "4B84C7";
                    }
                    if (iEv == 20)
                    {
                        col1 = (iK % 2 == 0) ? green : "C3577F";
                    }
                    if (iEv == 21)
                    {
                        col1 = (iK % 2 == 0) ? green : "882DB5";
                    }
                    if (iEv == 22)
                    {
                        if (iK >= 5 && iK <= 10)
                        {
                            col1 = (iK % 2 == 0) ? "D4004D" : "E79805";
                        }
                        else if (iK <= 12)
                        {
                            col1 = "1FBD3E";
                        }
                        else
                        {
                            col1 = "C41426";
                        }
                    }


                    col1 = ASSColor.HtmlToASS(col1);

                    // bezier
                    if (iEv >= 5)
                    {
                        List <ASSPoint> pts = new Bezier(
                            new ASSPoint {
                            X = (iEv % 2 == 0) ? x - 100 : x + 100, Y = y - 50
                        },
                            new ASSPoint {
                            X = x + ((iEv % 2 == 0) ? 50 : -40), Y = y - 50
                        },
                            new ASSPoint {
                            X = x + ((iEv % 2 == 0) ? 50 : -40), Y = y + 30
                        },
                            new ASSPoint {
                            X = (iEv % 2 == 0) ? x - 100 : x + 100, Y = y + 30
                        }
                            ).Create(0.005f);
                        double lastt0 = kStart - 0.3;
                        for (int i = 0; i < pts.Count; i++)
                        {
                            ASSPoint pt = pts[i];
                            double   t0 = kStart - 0.3 + 0.6 * (double)i / (double)pts.Count;
                            double   t1 = t0 + 0.3;
                            ass_out.Events.Add(
                                ev.StartReplace(t0).EndReplace(t1).StyleReplace("pt").LayerReplace(15).TextReplace(
                                    ASSEffect.pos(pt.X, pt.Y) + ASSEffect.c(1, "FFFFFF") + ASSEffect.a(1, "00") +
                                    ASSEffect.c(3, col1) + ASSEffect.a(3, "77") + ASSEffect.bord((iEv >= 0) ? 2 : 1) + ASSEffect.blur((iEv >= 0) ? 2 : 1) + ASSEffect.fad(0, 0.3) +
                                    ASSEffect.t(0, t1 - t0, ASSEffect.c(1, "FFFFFF").t() + ASSEffect.c(3, "FFFFFF").t()) +
                                    @"{\p1}m 0 0 l 1 0 1 1 0 1"));
                            if (t0 - lastt0 >= 0.04 || i + 1 == pts.Count)
                            {
                                string colb = Common.scaleColor(col1, "FFFFFF", 0.3);
                                ass_out.Events.Add(
                                    ev.StartReplace(t0).EndReplace(t0 + 0.04).StyleReplace("pt").LayerReplace(16).TextReplace(
                                        ASSEffect.pos(pt.X, pt.Y) + ASSEffect.c(1, "FFFFFF") + ASSEffect.a(1, "00") +
                                        ASSEffect.c(3, colb) + ASSEffect.a(3, "00") + ASSEffect.bord((iEv >= 0) ? 6 : 4) + ASSEffect.blur((iEv >= 0) ? 5 : 3) +
                                        @"{\p1}m 0 0 l 1 0 1 1 0 1"));
                                lastt0 = t0;
                            }
                        }
                    }

                    //if (iEv <= 2)
                    {
                        double jumpTime            = 0.5;
                        double t0                  = kStart - jumpTime;
                        double t1                  = t0;
                        double dt                  = 0.01;
                        Func <double, double> f_y  = ti => y - 1100.0 * (0.25 * jumpTime * jumpTime - ((ti - t0) - 0.5 * jumpTime) * ((ti - t0) - 0.5 * jumpTime));
                        Func <double, double> f_x  = ti => x;
                        Func <double, int>    f_fs = ti => (int)(1 + Math.Round((ti - kStart + jumpTime) / jumpTime * FontWidth));
                        if (iEv >= 5 && iEv <= 12)
                        {
                            f_y  = ti => y;
                            f_x  = ti => x - 100 * (ti - t0) / jumpTime + 100;
                            f_fs = ti => FontWidth;
                        }
                        double d12 = 0.2;
                        if (iEv > 12)
                        {
                            t0  -= d12;
                            t1   = t0;
                            f_fs = ti => (int)(1 + Math.Round((ti - kStart + d12 + jumpTime) / jumpTime * FontWidth));
                        }
                        for (; t1 <= kStart - ((iEv > 12) ? d12 : 0); t1 += dt)
                        {
                            ass_out.Events.Add(
                                ev.StartReplace(t1 - dt - 0.1).EndReplace(t1 - 0.1).TextReplace(
                                    ASSEffect.pos(f_x(t1), f_y(t1)) + ASSEffect.fs(f_fs(t1)) +
                                    ASSEffect.c(1, (iEv >= 5) ? "555555" : col1) + ASSEffect.c(3, "FFFFFF") +
                                    ke.KText));
                            ass_out.Events.Add(
                                ev.StartReplace(t1 - dt - 0.1).EndReplace(t1 - dt - 0.1 + 0.4).LayerReplace(5).TextReplace(
                                    ASSEffect.pos(f_x(t1), f_y(t1)) + ASSEffect.fs(f_fs(t1)) + ASSEffect.be(1) +
                                    ASSEffect.c(1, "FFFFFF") + ASSEffect.c(3, "FFFFFF") +
                                    ASSEffect.a(1, "AA") + ASSEffect.a(3, "AA") + ASSEffect.fad(0, 0.3) +
                                    ke.KText));
                        }
                        t1 -= dt + 0.1;
                        double t2 = ev.End + r * 1 - 0.9;
                        if (iEv >= 5)
                        {
                            if (iEv >= 9)
                            {
                                ass_out.Events.Add(
                                    ev.StartReplace(kStart - 0.05).EndReplace(t2).LayerReplace(8).TextReplace(
                                        ASSEffect.pos(x, y) + ASSEffect.a(3, "44") + ASSEffect.a(1, "FF") + ASSEffect.c(3, col1) +
                                        ASSEffect.bord((iEv >= 13) ? 8 : 5) + ASSEffect.blur((iEv >= 13) ? 7 : 4) + ASSEffect.fad(0, 0.3) +
                                        ke.KText));
                            }
                            else
                            {
                                ass_out.Events.Add(
                                    ev.StartReplace(kStart - 0.05).EndReplace(t2).LayerReplace(8).TextReplace(
                                        ASSEffect.pos(x, y) + ASSEffect.a(3, "44") + ASSEffect.a(1, "FF") + ASSEffect.c(3, "FFFFFF") +
                                        ASSEffect.bord(3) + ASSEffect.blur(2) + ASSEffect.fad(0, 0.3) +
                                        ke.KText));
                            }
                            ass_out.Events.Add(
                                ev.StartReplace(kStart - 0.05).EndReplace(kStart + ((iEv >= 13) ? 0.3 : 0.15)).LayerReplace(15).TextReplace(
                                    ASSEffect.pos(x, y) + ASSEffect.a(3, "00") + ASSEffect.c(3, "FFFFFF") + ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") +
                                    ASSEffect.bord(5) + ASSEffect.blur(4) +
                                    ASSEffect.fad(0, 0.2) + ke.KText));
                            ass_out.Events.Add(
                                ev.StartReplace(kStart - 0.05).EndReplace(t2).LayerReplace(13).TextReplace(
                                    ASSEffect.pos(x, y) + ASSEffect.a(3, "FF") + ASSEffect.a(1, "00") + ASSEffect.c(1, col1) +
                                    ke.KText));
                        }
                        ass_out.Events.Add(
                            ev.StartReplace(t1).EndReplace(t2).TextReplace(
                                ASSEffect.pos(x, y) +
                                ASSEffect.c(1, (iEv >= 5) ? "555555" : col1) + ASSEffect.c(3, "FFFFFF") +
                                ke.KText));
                        {
                            double ag = Common.RandomDouble(rnd, 0, Math.PI * 2);
                            if (iEv >= 9 && iEv <= 11)
                            {
                                ag = Math.PI * 0.75;
                            }
                            double ra    = 100;
                            double x1    = x + ra * Math.Cos(ag);
                            double y1    = y + ra * Math.Sin(ag);
                            bool   first = true;
                            for (double t3 = t2; t3 < t2 + 0.4; t3 += 0.02)
                            {
                                double t4   = t3 + 0.5;
                                string cole = Common.scaleColor(col1, "FFFFFF", (t3 - t2) / 0.5);
                                if (iEv <= 3)
                                {
                                    cole = "FFFFFF";
                                }
                                if (iEv >= 9 && iEv <= 11)
                                {
                                    cole = "FFFFFF";
                                }
                                ass_out.Events.Add(
                                    ev.StartReplace(t3).EndReplace(t4).LayerReplace(first ? 10 : 5).TextReplace(
                                        ASSEffect.move(x, y, x1, y1) + ASSEffect.fad(0, 0.3) + ASSEffect.be(first ? 0 : 1) +
                                        ASSEffect.c(1, first ? col1 : cole) + ASSEffect.a(1, first ? "00" : "AA") +
                                        ASSEffect.c(3, first ? "FFFFFF" : cole) + ASSEffect.a(3, first ? "00" : "AA") +
                                        ke.KText));
                                first = false;
                            }
                        }
                    }
                }
            }

            for (int iiEv = 23; iiEv <= 45; iiEv++)
            {
                break;
                int iEv = iiEv - 23;
                if (testEv >= 0 && iEv != testEv)
                {
                    continue;
                }
                ASSEvent        ev     = ass_in.Events[iiEv];
                List <KElement> kelems = ev.SplitK(true);

                this.MaskStyle = msc;
                double sw = (iEv % 2 == 0) ? 0 : GetTotalWidth(ev);
                /// an7 pos
                int x0 = (iEv % 2 == 0) ? MarginLeft : (int)(PlayResX - MarginRight - sw);
                int y0 = MarginTop;

                int kSum = 0;

                for (int iK = 0; iK < kelems.Count; iK++)
                {
                    //if (iK > 3) continue;
                    Console.WriteLine("{0} / {1} : {2} / {3}", iiEv + 1, ass_in.Events.Count, iK + 1, kelems.Count);
                    KElement ke = kelems[iK];
                    double   r  = (double)iK / (double)(kelems.Count - 1);
                    this.MaskStyle = ms3;
                    Size sz = GetSize(ke.KText);

                    double kStart = ev.Start + kSum * 0.01;
                    double kEnd   = kStart + ke.KValue * 0.01;
                    kSum += ke.KValue;

                    /// an5 pos
                    int x = x0 + this.FontSpace + sz.Width / 2;
                    int y = y0 + FontHeight / 2;

                    x0 += this.FontSpace + sz.Width;
                    y0  = y0;

                    if (ke.KText.Trim().Length == 0)
                    {
                        continue;
                    }

                    string col1  = "3CD846";
                    string green = col1;
                    if (iEv == 1)
                    {
                        col1 = "C13BA5";
                    }
                    if (iEv == 2)
                    {
                        col1 = "3E58A6";
                    }
                    if (iEv == 3)
                    {
                        col1 = (iK % 2 == 0) ? "D4004D" : "E79805";
                    }
                    if (iEv == 4)
                    {
                        if (iK <= 12)
                        {
                            col1 = (iK % 2 == 0) ? "D4004D" : "E79805";
                        }
                        else if (iK <= 13)
                        {
                            col1 = "1FBD3E";
                        }
                        else
                        {
                            col1 = "C41426";
                        }
                    }
                    if (iEv == 5)
                    {
                        if (iK >= 10)
                        {
                            col1 = "F1D53C";
                        }
                    }
                    if (iEv == 6)
                    {
                        if (iK >= 4 && iK <= 5)
                        {
                            col1 = "F1D53C";
                        }
                        else if (iK >= 10)
                        {
                            col1 = "F25756";
                        }
                    }
                    if (iEv == 7)
                    {
                        if (iK >= 5)
                        {
                            col1 = "5D477C";
                        }
                    }
                    if (iEv == 8)
                    {
                        if (iK >= 3 && iK <= 4)
                        {
                            col1 = "5D477C";
                        }
                    }
                    if (iEv == 9)
                    {
                        col1 = "4399AE";
                    }
                    if (iEv == 10 || iEv == 11)
                    {
                        col1 = "AE4343";
                    }
                    if (iEv == 12)
                    {
                        col1 = "4344AE";
                    }
                    if (iEv == 13)
                    {
                        col1 = (iK % 2 == 0) ? green : "DC49A6";
                    }
                    if (iEv == 14)
                    {
                        col1 = (iK % 2 == 0) ? green : "C13BA5";
                    }
                    if (iEv == 15)
                    {
                        col1 = (iK % 2 == 0) ? green : "3E58A6";
                    }
                    if (iEv == 16)
                    {
                        col1 = (iK % 2 == 0) ? "D4004D" : "E79805";
                    }
                    if (iEv == 17)
                    {
                        if (iK <= 12)
                        {
                            col1 = (iK % 2 == 0) ? "D4004D" : "E79805";
                        }
                        else if (iK <= 13)
                        {
                            col1 = "1FBD3E";
                        }
                        else
                        {
                            col1 = "C41426";
                        }
                    }
                    if (iEv == 18 || iEv == 19)
                    {
                        col1 = (iK % 2 == 0) ? green : "4B84C7";
                    }
                    if (iEv == 20)
                    {
                        col1 = (iK % 2 == 0) ? green : "C3577F";
                    }
                    if (iEv == 21)
                    {
                        col1 = (iK % 2 == 0) ? green : "882DB5";
                    }
                    if (iEv == 22)
                    {
                        if (iK >= 4 && iK <= 11)
                        {
                            col1 = (iK % 2 == 0) ? "D4004D" : "E79805";
                        }
                        else if (iK <= 12)
                        {
                            col1 = "1FBD3E";
                        }
                        else
                        {
                            col1 = "C41426";
                        }
                    }


                    col1 = ASSColor.HtmlToASS(col1);

                    {
                        double jumpTime            = 0.5;
                        double t0                  = kStart - jumpTime;
                        double t1                  = t0;
                        double dt                  = 0.01;
                        Func <double, double> f_y  = ti => y;
                        Func <double, double> f_x  = ti => x - 100 * (ti - t0) / jumpTime + 100;
                        Func <double, int>    f_fs = ti => FontWidth;
                        for (; t1 <= kStart; t1 += dt)
                        {
                            ass_out.Events.Add(
                                ev.StartReplace(t1 - dt - 0.1).EndReplace(t1 - 0.1).TextReplace(
                                    ASSEffect.pos(f_x(t1), f_y(t1)) + ASSEffect.fs(f_fs(t1)) +
                                    ASSEffect.c(1, col1) + ASSEffect.c(3, "FFFFFF") +
                                    ke.KText));
                            ass_out.Events.Add(
                                ev.StartReplace(t1 - dt - 0.1).EndReplace(t1 - dt - 0.1 + 0.4).LayerReplace(5).TextReplace(
                                    ASSEffect.pos(f_x(t1), f_y(t1)) + ASSEffect.fs(f_fs(t1)) + ASSEffect.be(1) +
                                    ASSEffect.c(1, "FFFFFF") + ASSEffect.c(3, "FFFFFF") +
                                    ASSEffect.a(1, "AA") + ASSEffect.a(3, "AA") + ASSEffect.fad(0, 0.3) +
                                    ke.KText));
                        }
                        t1 -= dt + 0.1;
                        double t2 = ev.End + r * 1 - 0.9;
                        ass_out.Events.Add(
                            ev.StartReplace(t1).EndReplace(t2).TextReplace(
                                ASSEffect.pos(x, y) +
                                ASSEffect.c(1, col1) + ASSEffect.c(3, "FFFFFF") +
                                ke.KText));
                        {
                            double ag = Common.RandomDouble(rnd, 0, Math.PI * 2);
                            if (iEv >= 9 && iEv <= 11)
                            {
                                ag = Math.PI * 1.25;
                            }
                            double ra    = 100;
                            double x1    = x + ra * Math.Cos(ag);
                            double y1    = y + ra * Math.Sin(ag);
                            bool   first = true;
                            for (double t3 = t2; t3 < t2 + 0.4; t3 += 0.02)
                            {
                                double t4   = t3 + 0.5;
                                string cole = Common.scaleColor(col1, "FFFFFF", (t3 - t2) / 0.5);
                                if (iEv <= 3)
                                {
                                    cole = "FFFFFF";
                                }
                                if (iEv >= 9 && iEv <= 11)
                                {
                                    cole = "FFFFFF";
                                }
                                ass_out.Events.Add(
                                    ev.StartReplace(t3).EndReplace(t4).LayerReplace(first ? 10 : 5).TextReplace(
                                        ASSEffect.move(x, y, x1, y1) + ASSEffect.fad(0, 0.3) + ASSEffect.be(first ? 0 : 1) +
                                        ASSEffect.c(1, first ? col1 : cole) + ASSEffect.a(1, first ? "00" : "AA") +
                                        ASSEffect.c(3, first ? "FFFFFF" : cole) + ASSEffect.a(3, first ? "00" : "AA") +
                                        ke.KText));
                                first = false;
                            }
                        }
                    }
                }
            }

            ass_out.SaveFile(OutFileName);
            Console.WriteLine("Lines : {0}", ass_out.Events.Count);
        }
        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>();

            for (int iEv = 0; iEv < ass_in.Events.Count; iEv++)
            {
                ASSEvent        ev     = ass_in.Events[iEv];
                List <KElement> kelems = ev.SplitK(false);

                /// an7 pos
                int x0 = (PlayResX - GetTotalWidth(ev)) / 2;
                int y0 = PlayResY - MarginBottom - FontHeight;

                Random rnd = new Random();

                int kSum = 0;

                //ASSColor col1 = Common.RandomColor(rnd, 1, new ASSColor { A = 0, R = 20, B = 20, G = 20 }, new ASSColor { A = 0, R = 235, B = 235, G = 235 });
                //ASSColor col2 = Common.RandomColor(rnd, 1, new ASSColor { A = 0, R = col1.R - 40, B = col1.B - 40, G = col1.G - 40 }, new ASSColor { A = 0, R = col1.R + 40, B = col1.B + 40, G = col1.G + 40 });
                ASSColor col1 = Common.RandomColor(rnd, 1);
                ASSColor col2 = Common.RandomColor(rnd, 1);

                while (Math.Abs(col1.R - col2.R) + Math.Abs(col1.G - col2.G) + Math.Abs(col1.B - col2.B) < 100)
                {
                    col1 = Common.RandomColor(rnd, 1);
                    col2 = Common.RandomColor(rnd, 1);
                }

                for (int iK = 0; iK < kelems.Count; iK++)
                {
                    KElement ke = kelems[iK];
                    double   r  = (double)iK / (double)(kelems.Count - 1);
                    Size     sz = GetSize(ke.KText);

                    string colStr = Common.scaleColor(col1, col2, r);

                    /// an5 pos
                    int x = x0 + this.FontSpace + sz.Width / 2;
                    int y = y0 + FontHeight / 2;
                    x0 += this.FontSpace + sz.Width;
                    y0  = y0;

                    if (iEv % 2 != 0 && ev.Start - ass_in.Events[iEv - 1].End < 0.1)
                    {
                        y -= FontHeight + 3;
                    }

                    double kStart = ev.Start + kSum * 0.01;
                    kSum += ke.KValue;
                    double kEnd = ev.Start + kSum * 0.01;

                    double t0 = ev.Start + r * 0.5 - 1.0;
                    if (iEv % 2 != 0)
                    {
                        t0 = ev.Start - r * 0.5 - 1.0;
                    }
                    double t01 = t0 + 0.5;
                    double t1  = kStart - 0.1;
                    if (t01 > t1)
                    {
                        t01 = t1;
                        t0  = t01 - 0.5;
                    }
                    double t2 = kStart + 0.2;
                    double t3 = kStart + 0.5;
                    double t4 = ev.End + r * 1.0 - 1.0;
                    if (iEv % 2 != 0)
                    {
                        t4 = ev.End - r * 1.0 + 1.0;
                    }
                    if (t4 < t3)
                    {
                        t4 = t3;
                    }
                    double t5 = t4 + 0.5;

                    double speed  = -20;
                    int    StartX = 848;
                    int    EndX   = 0;
                    if (iEv % 2 != 0)
                    {
                        speed  = 20;
                        StartX = 0;
                        EndX   = 848;
                    }

                    GetX_orgX      = x;
                    GetX_Speed     = speed;
                    GetX_StartTime = ev.Start;

                    ass_out.Events.Add(
                        ev.StartReplace(t0).EndReplace(t01).TextReplace(
                            ASSEffect.move(StartX, y, GetX(t01), y) + ASSEffect.a(1, "FF") + ASSEffect.a(3, "AA") + ASSEffect.c(3, "FFFFFF") +
                            ASSEffect.xbord(2) + ASSEffect.ybord(2) + ASSEffect.be(10) +
                            ke.KText));
                    ass_out.Events.Add(
                        ev.StartReplace(t01).EndReplace(t2).TextReplace(
                            ASSEffect.move(GetX(t01), y, GetX(t2), y) + ASSEffect.a(1, "FF") + ASSEffect.a(3, "AA") + ASSEffect.c(3, "FFFFFF") +
                            ASSEffect.xbord(2) + ASSEffect.ybord(2) + ASSEffect.be(10) +
                            ke.KText));
                    ass_out.Events.Add(
                        ev.StartReplace(t2).EndReplace(t3).TextReplace(
                            ASSEffect.move(GetX(t2), y, GetX(t3), y) + ASSEffect.a(1, "FF") + ASSEffect.a(3, "AA") + ASSEffect.c(3, "FFFFFF") +
                            ASSEffect.xbord(2) + ASSEffect.ybord(2) + ASSEffect.be(10) + ASSEffect.t(0, t3 - t2, ASSEffect.a(1, "77").t() + ASSEffect.c(3, colStr).t()) +
                            ke.KText));
                    ass_out.Events.Add(
                        ev.StartReplace(t3).EndReplace(t4).TextReplace(
                            ASSEffect.move(GetX(t3), y, GetX(t4), y) + ASSEffect.a(1, "FF") + ASSEffect.a(3, "77") + ASSEffect.c(3, colStr) +
                            ASSEffect.xbord(2) + ASSEffect.ybord(2) + ASSEffect.be(10) +
                            ke.KText));
                    ass_out.Events.Add(
                        ev.StartReplace(t4).EndReplace(t5).TextReplace(
                            ASSEffect.move(GetX(t4), y, EndX, y) + ASSEffect.a(1, "FF") + ASSEffect.a(3, "77") + ASSEffect.c(3, colStr) +
                            ASSEffect.xbord(2) + ASSEffect.ybord(2) + ASSEffect.be(10) +
                            ke.KText));

                    ass_out.Events.Add(
                        ev.StartReplace(t0).EndReplace(t01).TextReplace(
                            ASSEffect.move(StartX, y, GetX(t01), y) + ASSEffect.fad(t01 - t0, 0) +
                            ke.KText));
                    ass_out.Events.Add(
                        ev.StartReplace(t01).EndReplace(t1).TextReplace(
                            ASSEffect.move(GetX(t01), y, GetX(t1), y) +
                            ke.KText));
                    ass_out.Events.Add(
                        ev.StartReplace(t1).EndReplace(t2).TextReplace(
                            ASSEffect.move(GetX(t1), y, GetX(t2), y - 10) +
                            ASSEffect.t(0, t2 - t1, ASSEffect.frx(180 * 3).t()) +
                            ke.KText));
                    ass_out.Events.Add(
                        ev.StartReplace(t2).EndReplace(t3).TextReplace(
                            ASSEffect.move(GetX(t2), y - 10, GetX(t3), y) + ASSEffect.frx(180) +
                            ASSEffect.t(0, t3 - t2, ASSEffect.frx(360).t() + ASSEffect.c(1, colStr).t()) +
                            ke.KText));
                    ass_out.Events.Add(
                        ev.StartReplace(t3).EndReplace(t4).TextReplace(
                            ASSEffect.move(GetX(t3), y, GetX(t4), y) + ASSEffect.c(1, colStr) +
                            ke.KText));
                    ass_out.Events.Add(
                        ev.StartReplace(t4).EndReplace(t5).TextReplace(
                            ASSEffect.move(GetX(t4), y, EndX, y) + ASSEffect.c(1, colStr) + ASSEffect.fad(0, t5 - t4) +
                            ke.KText));
                }
            }
            ass_out.SaveFile(OutFileName);
        }
예제 #17
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 ms1    = "Style: Default,DFGMaruGothic-Md,30,&H00FF0000,&HFF600D00,&H000000FF,&HFF0A5A84,-1,0,0,0,100,100,0,0,0,2,0,5,20,20,20,128";
            string ms3    = "Style: Default,DFGMaruGothic-Md,30,&H000000FF,&HFF600D00,&H00FF0000,&HFF0A5A84,-1,0,0,0,100,100,0,0,0,2,0,5,20,20,20,128";
            string ptstr  = @"{\p1}m 0 0 l 1 0 1 1 0 1";
            string pt0Str = @"{\blur2\bord3\p4}m 5 5 s 5 -5 -5 -5 -5 5";

            Random rnd = new Random();

            InitBFS();

            for (int iEv = 0; iEv < ass_in.Events.Count; iEv++)
            {
                //if (iEv != 0) continue;
                ASSEvent        ev     = ass_in.Events[iEv];
                List <KElement> kelems = ev.SplitK(false);

                this.MaskStyle = ms3;
                double sw = (iEv % 2 == 0) ? 0 : GetTotalWidth(ev);
                /// an7 pos
                int x0      = (iEv % 2 == 0) ? MarginLeft : (int)(PlayResX - MarginRight - sw);
                int startx0 = x0;
                int y0      = PlayResY - MarginBottom - FontHeight;

                int kSum = 0;

                int           lum0count = 0;
                List <double> lum0x     = new List <double>();
                List <double> lum0y     = new List <double>();
                for (int lumx0 = -20; lumx0 < PlayResX;)
                {
                    lumx0 += Common.RandomInt(rnd, 5, 10);
                    lum0x.Add(lumx0);
                    lum0y.Add(Common.RandomInt(rnd, PlayResY - MarginBottom - FontHeight - 2, PlayResY - MarginBottom + 2));
                    lum0count++;
                }

                int           lumcount = 0;
                List <double> lumx     = new List <double>();
                List <double> lumy     = new List <double>();
                for (int lumx0 = -20; lumx0 < PlayResX;)
                {
                    lumx0 += Common.RandomInt(rnd, 25, 45);
                    lumx.Add(lumx0);
                    lumy.Add(Common.RandomInt(rnd, PlayResY - MarginBottom - FontHeight - 10, PlayResY - MarginBottom + 10));
                    lumcount++;
                }

                string[] lumcol =
                {
                    "003DB8",
                    "003DB8",
                    "000000",
                    "B54F00",
                    "0068B8",
                    "B88000"
                };

                string[] lum3 =
                {
                    "00B88F", //23:49.678
                    "003DB8", //23:50.429
                    "5972B8", //23:51.931
                    "B86459"  //23:54.516
                };
                double[] lum3t =
                {
                    23 * 60 + 49 + 0.65,
                    23 * 60 + 50 + 0.40,
                    23 * 60 + 51 + 0.91,
                    23 * 60 + 54 + 0.49
                };

                string[] lum4 =
                {
                    "003DB8" //24:06.528
                };
                double[] lum4t =
                {
                    24 * 60 + 6 + 0.50
                };


                for (int iK = 0; iK < kelems.Count; iK++)
                {
                    //if (iK > 3) continue;
                    Console.WriteLine("{0} / {1} : {2} / {3}", iEv + 1, ass_in.Events.Count, iK + 1, kelems.Count);
                    KElement ke = kelems[iK];
                    double   r  = (double)iK / (double)(kelems.Count - 1);
                    this.MaskStyle = ms3;
                    StringMask mask = GetMask(ke.KText, x0, y0);
                    Size       sz   = new Size(mask.Width, mask.Height);

                    double kStart = ev.Start + kSum * 0.01;
                    double kEnd   = kStart + ke.KValue * 0.01;
                    kSum += ke.KValue;

                    /// an5 pos
                    int x = x0 + this.FontSpace + sz.Width / 2;
                    int y = y0 + FontHeight / 2;

                    this.MaskStyle = ms1;
                    mask           = GetMask(ke.KText, x, y);

                    int bakx0 = x0;

                    x0 += this.FontSpace + sz.Width;
                    y0  = y0;

                    if (ke.KText.Trim().Length == 0)
                    {
                        continue;
                    }

                    double t0  = ev.Start - 1.0 + r * 2;
                    double t1  = t0 + 1;
                    double t11 = kStart - 0.4;
                    double t2  = ev.End;

                    ass_out.Events.Add(
                        ev.StartReplace(t11).EndReplace(t11 + 0.8).TextReplace(
                            ASSEffect.pos(x, y) + ASSEffect.a(1, "00") + ASSEffect.a(3, "00") + ASSEffect.c(1, "FFFFFF") + ASSEffect.c(3, "FFFFFF") +
                            ASSEffect.fad(0.2, 0.6) + ASSEffect.bord(0) + ASSEffect.blur(0) +
                            ASSEffect.t(0, 1, ASSEffect.bord(5).t() + ASSEffect.blur(5).t()) +
                            ke.KText));
                    ass_out.Events.Add(
                        ev.StartReplace(t11 + 0.4).EndReplace(t2 + 0.5).TextReplace(
                            ASSEffect.pos(x, y) + ASSEffect.a(1, "00") + ASSEffect.a(3, "00") + ASSEffect.c(1, "FFFFFF") + ASSEffect.c(3, "FFFFFF") +
                            ASSEffect.fad(0.4, 1) + ASSEffect.bord(2) + ASSEffect.blur(2) +
                            ke.KText));

                    if (iEv == 3)
                    {
                        ass_out.Events.Add(
                            ev.StartReplace(ev.Start + 0.5).EndReplace(ev.Start + 2.0).LayerReplace(20).TextReplace(
                                ASSEffect.pos(x, y) + ASSEffect.a(1, "00") + ASSEffect.a(3, "00") + ASSEffect.c(1, "FFFFFF") + ASSEffect.c(3, "FFFFFF") +
                                ASSEffect.fad(0, 0.5) + ASSEffect.bord(9) + ASSEffect.blur(8) +
                                ke.KText));
                    }
                    if (iEv == 5)
                    {
                        ass_out.Events.Add(
                            ev.StartReplace(ev.End).EndReplace(ev.End + 1.5).LayerReplace(20).TextReplace(
                                ASSEffect.pos(x, y) + ASSEffect.a(1, "00") + ASSEffect.a(3, "00") + ASSEffect.c(1, "FFFFFF") + ASSEffect.c(3, "FFFFFF") +
                                ASSEffect.fad(0.3, 0.5) + ASSEffect.bord(6) + ASSEffect.blur(6) +
                                ke.KText));
                    }

                    /*for (int i = 1; i <= 5; i++)
                     * {
                     *  ass_out.Events.Add(
                     *      ev.StartReplace(kStart + 0).EndReplace(t2 + 0.5).TextReplace(
                     *      ASSEffect.pos(x, y) + ASSEffect.a(1, "00") + ASSEffect.a(3, "FF") + ASSEffect.c(1, "FFFFFF") +
                     *      ASSEffect.fad(0.4, 1) + ASSEffect.bord(2) + ASSEffect.blur(2) +
                     *      ke.KText));
                     * }*/

                    int[]    ind = CalculateBFSOrder(mask);
                    double[] wt  = new double[mask.Points.Count];
                    double[] wt0 = new double[mask.Points.Count];
                    for (int i = 0; i < ind.Length; i++)
                    {
                        ASSPoint pt = mask.Points[i];
                        double   ag = Common.GetAngle(pt.X, pt.Y, x, y);
                        double   r0 = Common.GetDistance(pt.X, pt.Y, x, y) * 1.0;
                        double   r1 = Common.GetDistance(pt.X, pt.Y, x, y) * 1.3;
                        //double r2 = Common.GetDistance(pt.X, pt.Y, x, y) * 1.1;
                        double ptx0 = pt.X; // (double)x + Math.Cos(ag) * r0;
                        double pty0 = pt.Y; // (double)y - Math.Sin(ag) * r0;
                        double ptx  = (double)x + Math.Cos(ag) * r1;
                        double pty  = (double)y - Math.Sin(ag) * r1;
                        //double ptx2 = (double)x + Math.Cos(ag) * r2;
                        //double pty2 = (double)y - Math.Sin(ag) * r2;
                        string bt  = Common.ToHex2((255 - pt.Brightness) * Common.RandomDouble(rnd, 0.7, 0.9));
                        string bt2 = bt;
                        string bt3 = Common.ToHex2((255 - pt.Brightness * 0.8) * Common.RandomDouble(rnd, 0.7, 0.9));
                        double pt2 = kStart + (kEnd - kStart) * (pt.X - bakx0) / mask.Width + Common.RandomDouble_Gauss(rnd, -0.15, 0.00, 2);
                        wt[i] = 1;
                        for (int j = 0; j < lumcount; j++)
                        {
                            double dis = Common.GetDistance(pt.X, pt.Y, lumx[j], lumy[j]) / 30.0;
                            if (wt[i] > dis)
                            {
                                wt[i] = dis;
                            }
                        }
                        wt0[i] = 1;
                        for (int j = 0; j < lum0count; j++)
                        {
                            double dis = Common.GetDistance(pt.X, pt.Y, lum0x[j], lum0y[j]) / 10.0;
                            if (wt0[i] > dis)
                            {
                                wt0[i] = dis;
                            }
                        }
                        string col0 = Common.scaleColor("222222", "FFFFFF", wt0[i]);
                        if (iEv == 2)
                        {
                            col0 = Common.scaleColor("444444", "FFFFFF", wt0[i]);
                        }
                        if (iEv >= 3)
                        {
                            col0 = Common.scaleColor("777777", "FFFFFF", wt0[i]);
                        }
                        double pt3 = t2 + wt[i] + Common.RandomDouble_Gauss(rnd, -0.08, 0.08, 2);

                        if (iEv >= 2)
                        {
                            ass_out.Events.Add(
                                ev.StartReplace(pt2 - 0.1).EndReplace(pt2).StyleReplace("pt").LayerReplace(15).TextReplace(
                                    ASSEffect.a(1, "CC") + ASSEffect.c(1, "FFFFFF") + ASSEffect.a(3, "CC") + ASSEffect.c(1, "FFFFFF") +
                                    ASSEffect.bord(1) + ASSEffect.be(1) +
                                    ASSEffect.pos(ptx0, pty0) + ptstr));
                        }

                        if (iEv != 3 && iEv != 4)
                        {
                            string ptc = Common.scaleColor("FFFFFF", lumcol[iEv], wt[i]);
                            ass_out.Events.Add(
                                ev.StartReplace(t0).EndReplace(t1).StyleReplace("pt").TextReplace(
                                    ASSEffect.a(1, bt) + ASSEffect.c(1, col0) + ASSEffect.fad(0.1, 0) + ASSEffect.a(3, "FF") +
                                    ASSEffect.move(ptx, pty, ptx0, pty0) + ptstr));
                            ass_out.Events.Add(
                                ev.StartReplace(t1).EndReplace(pt2 + 0.2).StyleReplace("pt").TextReplace(
                                    ASSEffect.a(1, bt) + ASSEffect.c(1, col0) + ASSEffect.a(3, "FF") +
                                    ASSEffect.fad(0, 0.3) +
                                    ASSEffect.pos(ptx0, pty0) + ptstr));
                            ass_out.Events.Add(
                                ev.StartReplace(pt2 - 0.1).EndReplace(pt3).StyleReplace("pt").TextReplace(
                                    ASSEffect.a(1, bt2) + ASSEffect.c(1, ptc) + ASSEffect.a(3, "FF") +
                                    ASSEffect.fad(0.3, 0.3) +
                                    ASSEffect.pos(ptx0, pty0) + ptstr));
                        }
                        else if (iEv == 3)
                        {
                            for (int j = 0; j <= lum3.Length; j++)
                            {
                                string ptc = Common.scaleColor("FFFFFF", (j > 0) ? lum3[j - 1] : lumcol[iEv], wt[i]);
                                double tlo = (j > 0) ? lum3t[j - 1] : t0;
                                double thi = (j < lum3.Length) ? lum3t[j] : pt3;
                                Func <double, double> flo = xx => (xx < tlo) ? tlo : xx;
                                Func <double, double> fhi = xx => (xx > thi) ? thi : xx;
                                ass_out.Events.Add(
                                    ev.StartReplace(flo(t0)).EndReplace(fhi(t1)).StyleReplace("pt").TextReplace(
                                        ASSEffect.a(1, bt) + ASSEffect.c(1, col0) + ASSEffect.fad((j == 0) ? 0.1 : 0, 0) + ASSEffect.a(3, "FF") +
                                        ASSEffect.move(ptx, pty, ptx0, pty0) + ptstr));
                                ass_out.Events.Add(
                                    ev.StartReplace(flo(t1)).EndReplace(fhi(pt2 + 0.2)).StyleReplace("pt").TextReplace(
                                        ASSEffect.a(1, bt) + ASSEffect.c(1, col0) + ASSEffect.a(3, "FF") +
                                        ASSEffect.fad(0, (j == lum3.Length) ? 0.3 : 0) +
                                        ASSEffect.pos(ptx0, pty0) + ptstr));
                                ass_out.Events.Add(
                                    ev.StartReplace(flo(pt2 - 0.1)).EndReplace(fhi(pt3)).StyleReplace("pt").TextReplace(
                                        ASSEffect.a(1, bt) + ASSEffect.c(1, ptc) + ASSEffect.a(3, "FF") +
                                        ASSEffect.fad((j == 0) ? 0.3 : 0, (j == lum3.Length) ? 0.3 : 0) +
                                        ASSEffect.pos(ptx0, pty0) + ptstr));
                            }
                        }
                        else if (iEv == 4)
                        {
                            for (int j = 0; j <= lum4.Length; j++)
                            {
                                string ptc = Common.scaleColor("FFFFFF", (j > 0) ? lum4[j - 1] : lumcol[iEv], wt[i]);
                                double tlo = (j > 0) ? lum4t[j - 1] : t0;
                                double thi = (j < lum4.Length) ? lum4t[j] : pt3;
                                Func <double, double> flo = xx => (xx < tlo) ? tlo : xx;
                                Func <double, double> fhi = xx => (xx > thi) ? thi : xx;
                                ass_out.Events.Add(
                                    ev.StartReplace(flo(t0)).EndReplace(fhi(t1)).StyleReplace("pt").TextReplace(
                                        ASSEffect.a(1, bt) + ASSEffect.c(1, col0) + ASSEffect.fad((j == 0) ? 0.1 : 0, 0) + ASSEffect.a(3, "FF") +
                                        ASSEffect.move(ptx, pty, ptx0, pty0) + ptstr));
                                ass_out.Events.Add(
                                    ev.StartReplace(flo(t1)).EndReplace(fhi(pt2 + 0.2)).StyleReplace("pt").TextReplace(
                                        ASSEffect.a(1, bt) + ASSEffect.c(1, col0) + ASSEffect.a(3, "FF") +
                                        ASSEffect.fad(0, (j == lum4.Length) ? 0.3 : 0) +
                                        ASSEffect.pos(ptx0, pty0) + ptstr));
                                ass_out.Events.Add(
                                    ev.StartReplace(flo(pt2 - 0.1)).EndReplace(fhi(pt3)).StyleReplace("pt").TextReplace(
                                        ASSEffect.a(1, bt) + ASSEffect.c(1, ptc) + ASSEffect.a(3, "FF") +
                                        ASSEffect.fad((j == 0) ? 0.3 : 0, (j == lum4.Length) ? 0.3 : 0) +
                                        ASSEffect.pos(ptx0, pty0) + ptstr));
                            }
                        }

                        if (iEv == 2 && Common.RandomBool(rnd, 0.05))
                        {
                            ass_out.Events.Add(
                                ev.StartReplace(pt2).EndReplace(pt2 + 1.5).StyleReplace("pt").LayerReplace(13).TextReplace(
                                    ASSEffect.move(ptx0, pty0, ptx0, pty0 + FontHeight + MarginBottom) +
                                    ASSEffect.fad(0, 0.6) + ASSEffect.a(1, "CC") + ASSEffect.c(1, "FFFFFF") +
                                    ASSEffect.a(3, "00") + ASSEffect.c(3, "FFFFFF") +
                                    ASSEffect.t(0, Common.RandomDouble(rnd, 1.5, 3), ASSEffect.fry(-720).t()) +
                                    ASSEffect.bord(2) + ASSEffect.blur(2) + CreatePolygon(rnd, 30, 30, 4)));
                        }
                    }

                    if (iEv == 3)
                    {
                        for (int i = 0; i < (int)(Math.Round((kEnd - kStart) * 50)); i++)
                        {
                            ASSPoint pt = new ASSPoint {
                                X = Common.RandomInt(rnd, startx0, startx0 + (int)sw), Y = Common.RandomInt(rnd, y0, y0 + FontHeight)
                            };
                            double pt0 = Common.RandomDouble(rnd, ev.Start, ev.Start + 1.62);
                            double pt1 = pt0 + 0.5;
                            ass_out.Events.Add(
                                ev.StartReplace(pt0).EndReplace(pt1).StyleReplace("pt").TextReplace(
                                    ASSEffect.move(pt.X, pt.Y, Common.RandomInt(rnd, pt.X - 30, pt.X - 50), Common.RandomInt(rnd, pt.Y - 35, pt.Y - 55)) +
                                    ASSEffect.fad(0, 0.3) + ASSEffect.a(1, "CC") + ASSEffect.c(1, "FFFFFF") +
                                    ASSEffect.a(3, "00") + ASSEffect.c(3, "FFFFFF") +
                                    ASSEffect.t(0, Common.RandomDouble(rnd, 0.5, 1.5), ASSEffect.frz(Common.RandomInt(rnd, -500, 500)).t() + ASSEffect.fry(Common.RandomInt(rnd, -500, 500)).t() + ASSEffect.frx(Common.RandomInt(rnd, -500, 500)).t()) +
                                    ASSEffect.bord(3) + ASSEffect.blur(2) + CreatePolygon(rnd, 10, 25, Common.RandomInt(rnd, 5, 7))));
                        }
                        for (int i = 0; i < (int)(Math.Round((kEnd - kStart) * 200)); i++)
                        {
                            ASSPoint pt  = mask.Points[Common.RandomInt(rnd, 0, mask.Points.Count - 1)];
                            double   pt0 = Common.RandomDouble(rnd, kStart, kEnd);
                            double   pt1 = pt0 + 1.5;
                            string   ptc = lumcol[iEv];
                            for (int j = 0; j < lum3t.Length; j++)
                            {
                                if (pt0 >= lum3t[j] - 0.5)
                                {
                                    ptc = lum3[j];
                                }
                            }
                            ptc = Common.scaleColor(ptc, "FFFFFF", 0.75);
                            ass_out.Events.Add(
                                ev.StartReplace(pt0).EndReplace(pt1).StyleReplace("pt").LayerReplace(5).TextReplace(
                                    ASSEffect.move(pt.X, pt.Y, Common.RandomInt(rnd, pt.X + 50, pt.X - 50), Common.RandomInt(rnd, pt.Y + 35, pt.Y - 35)) +
                                    ASSEffect.fad(0, 0.3) + ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") +
                                    ASSEffect.a(3, "00") + ASSEffect.c(3, ptc) +
                                    ASSEffect.bord(2) + ASSEffect.blur(2) + CreatePolygon(rnd, 15, 15, 6)));
                        }
                    }

                    if (iEv == 4)
                    {
                        for (int i = 0; i < (int)(Math.Round((kEnd - kStart) * 200)); i++)
                        {
                            ASSPoint pt  = mask.Points[Common.RandomInt(rnd, 0, mask.Points.Count - 1)];
                            double   pt0 = Common.RandomDouble(rnd, kStart, kEnd);
                            double   pt1 = pt0 + 1.5;
                            string   ptc = lumcol[iEv];
                            if (pt0 >= lum4t[0] - 0.5)
                            {
                                ptc = lum4[0];
                            }
                            ptc = Common.scaleColor(ptc, "FFFFFF", 0.65);
                            ass_out.Events.Add(
                                ev.StartReplace(pt0).EndReplace(pt1).StyleReplace("pt").LayerReplace(5).TextReplace(
                                    ASSEffect.move(pt.X, pt.Y, Common.RandomInt(rnd, pt.X + 50, pt.X - 50), Common.RandomInt(rnd, pt.Y + 35, pt.Y - 35)) +
                                    ASSEffect.fad(0, 0.3) + ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") +
                                    ASSEffect.a(3, "00") + ASSEffect.c(3, ptc) +
                                    ASSEffect.bord(2) + ASSEffect.blur(2) + CreatePolygon(rnd, 15, 15, 6)));
                        }
                    }

                    if (iEv == 5)
                    {
                        for (int i = 0; i < 100; i++)
                        {
                            ASSPoint pt = new ASSPoint {
                                X = Common.RandomInt(rnd, startx0, startx0 + (int)sw), Y = Common.RandomInt(rnd, y0, y0 + FontHeight)
                            };
                            double pt0 = Common.RandomDouble(rnd, ev.End, ev.End + 1.8);
                            double pt1 = pt0 + 0.5;
                            string ptc = Common.scaleColor(lumcol[iEv], "FFFFFF", 0.9);
                            ass_out.Events.Add(
                                ev.StartReplace(pt0).EndReplace(pt1).StyleReplace("pt").TextReplace(
                                    ASSEffect.move(pt.X, pt.Y, Common.RandomInt(rnd, pt.X - 30, pt.X - 50), Common.RandomInt(rnd, pt.Y - 35, pt.Y - 55)) +
                                    ASSEffect.fad(0, 0.3) + ASSEffect.a(1, "CC") + ASSEffect.c(1, "FFFFFF") +
                                    ASSEffect.a(3, "00") + ASSEffect.c(3, ptc) +
                                    ASSEffect.t(0, Common.RandomDouble(rnd, 0.5, 1.5), ASSEffect.frz(Common.RandomInt(rnd, -500, 500)).t() + ASSEffect.fry(Common.RandomInt(rnd, -500, 500)).t() + ASSEffect.frx(Common.RandomInt(rnd, -500, 500)).t()) +
                                    ASSEffect.bord(3) + ASSEffect.blur(2) + CreatePolygon(rnd, 10, 25, Common.RandomInt(rnd, 5, 7))));
                        }
                        for (int i = 0; i < (int)(Math.Round((kEnd - kStart) * 200)); i++)
                        {
                            ASSPoint pt  = mask.Points[Common.RandomInt(rnd, 0, mask.Points.Count - 1)];
                            double   pt0 = Common.RandomDouble(rnd, kStart, kEnd);
                            double   pt1 = pt0 + 1.5;
                            string   ptc = lumcol[iEv];
                            ptc = Common.scaleColor(ptc, "FFFFFF", 0.75);
                            ass_out.Events.Add(
                                ev.StartReplace(pt0).EndReplace(pt1).StyleReplace("pt").LayerReplace(5).TextReplace(
                                    ASSEffect.move(pt.X, pt.Y, Common.RandomInt(rnd, pt.X + 50, pt.X - 50), Common.RandomInt(rnd, pt.Y + 35, pt.Y - 35)) +
                                    ASSEffect.fad(0, 0.3) + ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") +
                                    ASSEffect.a(3, "00") + ASSEffect.c(3, ptc) +
                                    ASSEffect.bord(2) + ASSEffect.blur(2) + CreatePolygon(rnd, 15, 15, 6)));
                        }
                    }
                }
            }

            ass_out.SaveFile(OutFileName);
            Console.WriteLine("Lines : {0}", ass_out.Events.Count);
        }
예제 #18
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>();

            Random rnd = new Random();

            for (int iEv = 0; iEv < ass_in.Events.Count; iEv++)
            {
                ASSEvent        ev     = ass_in.Events[iEv];
                List <KElement> kelems = ev.SplitK(false);

                /// an7 pos
                int x0 = MarginLeft;
                int y0 = PlayResY - MarginBottom - FontHeight;

                int kSum = 0;

                for (int i = 0; i < kelems.Count; i++)
                {
                    KElement ke = kelems[i];
                    double   r  = (double)i / (double)(kelems.Count - 1);
                    double   r0 = 1.0 - r;
                    Size     sz = GetSize(ke.KText);

                    if (Char.IsWhiteSpace(ke.KText[0]))
                    {
                        sz.Width = 15;
                    }

                    double kStart = kSum * 0.01;
                    double kEnd   = kStart + ke.KValue * 0.01;

                    /// an5 pos
                    int x = x0 + FontSpace + sz.Width / 2;
                    int y = y0 + FontHeight / 2;

                    x0 += this.FontSpace + sz.Width;
                    y0  = y0;

                    kSum += ke.KValue;

                    double t0 = ev.Start - r0 * 0.5;
                    double t1 = t0 + 0.2;                // 出现
                    double t2 = ev.Start + kStart - 0.1; // 保持框
                    double t3 = t2 + 0.5;                // K效果
                    double t4 = ev.End - r0 * 0.5;       // 保持
                    double t5 = t4 + 0.2;                // 消失

                    double rect_x0 = x - sz.Width / 2 - 2;
                    double rect_y0 = y - FontHeight / 2 - 2;
                    double rect_x1 = x + sz.Width / 2 + 2;
                    double rect_y1 = y + FontHeight / 2 + 2;
                    if (ke.KText.Length > 1)
                    {
                        rect_x0 -= ke.KText.Length * 1;
                        rect_x1 += ke.KText.Length * 1;
                    }
                    if (ke.KText == "with" || ke.KText == "find" || ke.KText == "world")
                    {
                        rect_x0 -= 2;
                        rect_x1 += 1;
                    }
                    if (ke.KText == "DITE")
                    {
                        rect_x0 -= 3;
                        rect_x1 += 3;
                    }
                    if (ke.KText == "alive")
                    {
                        rect_x0 -= 2;
                        rect_x1 += 2;
                    }

                    double rect_xmid = (rect_x0 + rect_x1) * 0.5;
                    double rect_ymid = (rect_y0 + rect_y1) * 0.5;

                    if (ke.KText.Trim().Length > 0)
                    {
                        ass_out.Events.Add(
                            ev.StartReplace(t0).EndReplace(t1).TextReplace(
                                ASSEffect.move(x + 10, y - 10, x, y) +
                                ASSEffect.fad(t1 - t0, 0) +
                                ke.KText));
                        ass_out.Events.Add(
                            CreateRectangle(t0, t1, "draw1", rect_x0, rect_y0, rect_x1, rect_y1, x, y, ASSEffect.move(x + 10, y - 10, x, y) + ASSEffect.fad(t1 - t0, 0))
                            );

                        int xC = 16;
                        int yC = 16;
                        if (ke.KText.Length > 1)
                        {
                            xC = (int)(Math.Round((double)yC / (rect_y1 - rect_y0) * (rect_x1 - rect_x0)));
                        }
                        switch (iEv)
                        {
                        case 0:
                        case 1:
                            ass_out.Events.Add(
                                ev.StartReplace(t1).EndReplace(t4).TextReplace(
                                    ASSEffect.pos(x, y) +
                                    ke.KText));
                            ass_out.Events.Add(
                                CreateRectangle(t1, t2, "draw1", rect_x0, rect_y0, rect_x1, rect_y1)
                                );

                            ass_out.Events.Add(
                                CreateRectangle(t2, t3, "draw1", rect_x0, rect_y0, rect_xmid, rect_y1, rect_x0, rect_ymid,
                                                ASSEffect.pos((int)Math.Round(rect_x0), (int)Math.Round(rect_ymid)) + ASSEffect.t(0, t3 - t2, ASSEffect.fry(-90).t()) + ASSEffect.fad(0, t3 - t2)
                                                ));
                            ass_out.Events.Add(
                                CreateRectangle(t2, t3, "draw1", rect_xmid, rect_y0, rect_x1, rect_y1, rect_x1, rect_ymid,
                                                ASSEffect.pos((int)Math.Round(rect_x1), (int)Math.Round(rect_ymid)) + ASSEffect.t(0, t3 - t2, ASSEffect.fry(90).t()) + ASSEffect.fad(0, t3 - t2)
                                                ));
                            break;

                        case 2:
                            ass_out.Events.Add(
                                ev.StartReplace(t1).EndReplace(t4).TextReplace(
                                    ASSEffect.pos(x, y) +
                                    ke.KText));
                            ass_out.Events.Add(
                                CreateRectangle(t1, t2, "draw1", rect_x0, rect_y0, rect_x1, rect_y1)
                                );

                            ass_out.Events.Add(
                                CreateRectangle(t2, t3, "draw1", rect_x0, rect_y0, rect_x1, rect_ymid, rect_xmid, rect_y0,
                                                ASSEffect.pos((int)Math.Round(rect_xmid), (int)Math.Round(rect_y0)) + ASSEffect.t(0, t3 - t2, ASSEffect.frx(-90).t()) + ASSEffect.fad(0, t3 - t2)
                                                ));
                            ass_out.Events.Add(
                                CreateRectangle(t2, t3, "draw1", rect_x0, rect_ymid, rect_x1, rect_y1, rect_xmid, rect_y1,
                                                ASSEffect.pos((int)Math.Round(rect_xmid), (int)Math.Round(rect_y1)) + ASSEffect.t(0, t3 - t2, ASSEffect.frx(90).t()) + ASSEffect.fad(0, t3 - t2)
                                                ));
                            break;

                        case 7:
                        case 8:
                            ass_out.Events.Add(
                                ev.StartReplace(t1).EndReplace(t4).TextReplace(
                                    ASSEffect.pos(x, y) +
                                    ke.KText));
                            ass_out.Events.Add(
                                CreateRectangle(t1, t2, "draw1", rect_x0, rect_y0, rect_x1, rect_y1)
                                );

                            for (int jR = 0; jR < yC; jR++)
                            {
                                double yy0    = rect_y0 + (rect_y1 - rect_y0) * (double)jR / (double)yC;
                                double yy1    = yy0 + (rect_y1 - rect_y0) / (double)yC;
                                double rStart = t2 + jR * 0.05;
                                if (iEv == 8)
                                {
                                    rStart = t2 + (yC - jR - 1) * 0.05;
                                }
                                double rEnd  = rStart + 0.2;
                                double yymid = (yy0 + yy1) * 0.5;
                                ass_out.Events.Add(
                                    CreateRectangle(t2, rStart, "draw1", rect_x0, yy0, rect_x1, yy1)
                                    );
                                ass_out.Events.Add(
                                    CreateRectangle(rStart, rEnd, "draw1", rect_x0, yy0, rect_x1, yy1, rect_xmid, yymid,
                                                    ASSEffect.pos(rect_xmid, yymid) + ASSEffect.fad(0, rEnd - rStart)
                                                    ));
                            }
                            break;

                        case 3:
                        case 4:
                        case 5:
                        case 6:
                        default:
                            ass_out.Events.Add(
                                ev.StartReplace(t1).EndReplace(t2).TextReplace(
                                    ASSEffect.pos(x, y) +
                                    ke.KText));
                            ass_out.Events.Add(
                                CreateRectangle(t1, t2, "draw1", rect_x0, rect_y0, rect_x1, rect_y1)
                                );

                            double t3_2 = ev.Start + kEnd;
                            if (t3_2 > t4)
                            {
                                t3_2 = t4;
                            }
                            for (int iR = 0; iR < (int)(Math.Round((t3_2 - t2) / 0.01)); iR++)
                            {
                                double rStart = t2 + iR * 0.01;
                                double rEnd   = rStart + 0.01;
                                ass_out.Events.Add(
                                    ev.StartReplace(rStart).EndReplace(rEnd).TextReplace(
                                        ASSEffect.pos(Common.RandomInt(rnd, x - 3, x + 3), Common.RandomInt(rnd, y - 3, y + 3)) +
                                        ke.KText));
                            }

                            ass_out.Events.Add(
                                ev.StartReplace(t3_2).EndReplace(t4).TextReplace(
                                    ASSEffect.pos(x, y) +
                                    ke.KText));

                            for (int iR = 0; iR < xC; iR++)
                            {
                                for (int jR = 0; jR < yC; jR++)
                                {
                                    double xx0 = rect_x0 + (rect_x1 - rect_x0) * (double)iR / (double)xC;
                                    double yy0 = rect_y0 + (rect_y1 - rect_y0) * (double)jR / (double)yC;
                                    double xx1 = xx0 + (rect_x1 - rect_x0) / (double)xC;
                                    double yy1 = yy0 + (rect_y1 - rect_y0) / (double)yC;
                                    double dx  = rnd.Next() % 20 + 8;
                                    double dy  = rnd.Next() % 20 + 8;
                                    double xx2 = xx0;
                                    double yy2 = yy0;
                                    if (Common.RandomInt_Gauss2(rnd, xC, iR) <= xC / 2)
                                    {
                                        xx2 -= dx;
                                    }
                                    else
                                    {
                                        xx2 += dx;
                                    }
                                    if (Common.RandomInt_Gauss2(rnd, yC, jR) <= yC / 2)
                                    {
                                        yy2 -= dy;
                                    }
                                    else
                                    {
                                        yy2 += dy;
                                    }
                                    double rEnd = Common.RandomDouble(rnd, t2 + 0.3, t2 + 1.5);
                                    ass_out.Events.Add(
                                        CreateRectangle(t2, rEnd, "draw1", xx0, yy0, xx1, yy1, xx0, yy0,
                                                        ASSEffect.move(xx0, yy0, xx2, yy2) + ASSEffect.fad(0, rEnd - t2)
                                                        ));
                                }
                            }
                            break;
                        }

                        ass_out.Events.Add(
                            ev.StartReplace(t4).EndReplace(t5).TextReplace(
                                ASSEffect.move(x, y, x - 10, y + 10) +
                                ASSEffect.fad(0, t5 - t4) +
                                ke.KText));
                    }
                }
            }

            ass_out.SaveFile(OutFileName);
        }
예제 #19
0
        public override void Run()
        {
            string ptstr = @"{\p1}m 0 0 l 1 0 1 1 0 1";

            ASS ass_in  = ASS.FromFile(this.InFileName);
            ASS ass_out = new ASS();

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

            int    ox    = 300;
            int    oy    = 300;
            double r     = 30;
            Random rnd   = new Random();
            int    sz    = 3;
            int    maxsz = 5;
            string cb    = "44";
            string cb2   = "11";
            string eb    = "55";
            string eb2   = "22";
            string col1  = "FFFC94";
            string col2  = "FF94D1";

            ASSPoint[] pt2 = new ASSPoint[10];
            for (int i = 0; i < pt2.Length; i++)
            {
                pt2[i] = new ASSPoint {
                    X = Common.RandomInt(rnd, ox - 15, ox + 15), Y = Common.RandomInt(rnd, oy - 70, oy - 40)
                }
            }
            ;

            for (double ag = 0; ag < Math.PI * 2; ag += 0.05)
            {
                double t0 = 2 + ag * 0.3;
                double t1 = 2 + Math.PI * 2 * 0.3 + Common.RandomDouble(rnd, 0, 0.3);
                double t2 = 2 + Math.PI * 2 * 0.3 + 1 + Common.RandomDouble(rnd, 0, 0.7);
                double t3 = t2 + 0.8;
                if (Common.RandomBool(rnd, (0.25 + 0.5 * (1.0 - (double)(sz - 1) / (double)(maxsz - 1)))))
                {
                    sz++;
                }
                else
                {
                    sz--;
                }
                if (sz < 1)
                {
                    sz = 1;
                }
                if (sz > maxsz)
                {
                    sz = maxsz;
                }
                double x = ox + r * Math.Cos(ag);
                double y = oy + r * Math.Sin(ag);

                double r1  = Common.RandomDouble(rnd, 0, 10);
                double ag1 = Common.RandomDouble(rnd, 0, Math.PI * 2);
                double x1  = ox + r1 * Math.Cos(ag1);
                double y1  = oy + r1 * Math.Sin(ag1);

                int    pt2i = Common.RandomInt(rnd, 0, pt2.Length - 1);
                double x2   = pt2[pt2i].X;
                double y2   = pt2[pt2i].Y;

                ass_out.AppendEvent(10, "pt", t0, t1,
                                    ASSEffect.pos(x, y) +
                                    ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") +
                                    ASSEffect.a(3, cb) + ASSEffect.c(3, "FFFFFF") +
                                    ASSEffect.bord(1) + ASSEffect.be(1) +
                                    ASSEffect.t(0, (t1 - t0) * 1, ASSEffect.bord(sz).t() + ASSEffect.be(sz).t()) +
                                    ptstr);
                ass_out.AppendEvent(5, "pt", t0, t1,
                                    ASSEffect.pos(x, y) +
                                    ASSEffect.a(1, "FF") +
                                    ASSEffect.a(3, eb) + ASSEffect.c(3, col1) +
                                    ASSEffect.bord(2) + ASSEffect.blur(2) +
                                    ASSEffect.t(0, (t1 - t0) * 1, ASSEffect.bord(sz + 1).t() + ASSEffect.blur(sz + 1).t()) +
                                    ASSEffect.t(0, (t1 - t0) * 0.5, ASSEffect.c(3, col2).t()) +
                                    ASSEffect.t((t1 - t0) * 0.5, t1, ASSEffect.c(3, col1).t()) +
                                    ptstr);

                string ctmp = Common.scaleColor(col1, col2, Common.RandomDouble(rnd, 0, 1));
                ass_out.AppendEvent(10, "pt", t1, t2,
                                    ASSEffect.move(x, y, x1, y1) +
                                    ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") +
                                    ASSEffect.a(3, cb) + ASSEffect.c(3, "FFFFFF") +
                                    ASSEffect.bord(sz) + ASSEffect.be(sz) +
                                    ptstr);
                ass_out.AppendEvent(5, "pt", t1, t2,
                                    ASSEffect.move(x, y, x1, y1) +
                                    ASSEffect.a(1, "FF") +
                                    ASSEffect.a(3, eb) + ASSEffect.c(3, col1) +
                                    ASSEffect.bord(sz + 1) + ASSEffect.blur(sz + 1) +
                                    ASSEffect.t(0, t2 - t1, ASSEffect.c(3, ctmp).t()) +
                                    ptstr);

                ass_out.AppendEvent(10, "pt", t2, t3,
                                    ASSEffect.fad(0, 0.5) +
                                    ASSEffect.move(x1, y1, x2, y2) +
                                    ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") +
                                    ASSEffect.a(3, cb2) + ASSEffect.c(3, "FFFFFF") +
                                    ASSEffect.bord(sz) + ASSEffect.be(sz) +
                                    ASSEffect.t(0, (t3 - t2) * 0.5, ASSEffect.bord(0).t() + ASSEffect.be(1).t()) +
                                    ptstr);
                ass_out.AppendEvent(5, "pt", t2, t3,
                                    ASSEffect.fad(0, 0.2) +
                                    ASSEffect.move(x1, y1, x2, y2) +
                                    ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") +
                                    ASSEffect.a(3, eb2) + ASSEffect.c(3, ctmp) +
                                    ASSEffect.bord(sz + 1) + ASSEffect.blur(sz + 1) +
                                    ASSEffect.t(0, (t3 - t2) * 0.5, ASSEffect.bord(1).t() + ASSEffect.blur(1).t()) +
                                    ptstr);
            }

            ass_out.SaveFile(OutFileName);
        }
    }
예제 #20
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>();

            Particle2 Par;

            string[] colList =
            {
                "05C1FF",
                "05C1FF",
                "0505FF",
                "0505FF",
                "FF6305",
                "FF0528",
                "0505FF",
                "FF6305",
                "FF6305",
                "FF6305",
                "FF6305",
                "FF6305",
            };

            for (int iEv = 0; iEv < ass_in.Events.Count; iEv++)
            {
                //if (iEv > 1) continue;
                ASSEvent        ev     = ass_in.Events[iEv];
                List <KElement> kelems = ev.SplitK(false);

                double sw = GetTotalWidth(ev);
                /// an7 pos
                int x0 = (iEv % 2 == 0) ? MarginLeft : (PlayResX - MarginRight - (int)sw);
                int y0 = PlayResY - MarginBottom - FontHeight;

                int kSum = 0;

                int bak_x0 = x0;

                string col1 = colList[iEv];
                string col3 = col1;

                for (int i = 0; i < kelems.Count; i++)
                {
                    KElement ke = kelems[i];
                    double   r  = (double)i / (double)(kelems.Count - 1);
                    Size     sz = GetSize(ke.KText);

                    double kStart = kSum * 0.01;
                    double kEnd   = kStart + ke.KValue * 0.01;
                    kSum += ke.KValue;

                    /// an5 pos
                    int x = x0 + this.FontSpace + sz.Width / 2;
                    int y = y0 + FontHeight / 2;

                    x0 += this.FontSpace + sz.Width;
                    y0  = y0;

                    if (ke.KText.Trim().Length == 0)
                    {
                        continue;
                    }

                    double t0 = ev.Start + r * 0.6 - 0.9;
                    if (iEv % 2 == 1)
                    {
                        t0 = ev.Start - r * 0.6 - 0.3;
                    }
                    double t1 = t0 + 0.3;
                    double t2 = ev.Start + kStart;
                    if (t1 > t2)
                    {
                        t2 = t1;
                    }
                    double t3 = t2 + 0.3;
                    double t4 = ev.End + r * 0.6 - 0.6;
                    if (iEv % 2 == 1)
                    {
                        t4 = ev.End - r * 0.6;
                    }
                    double t5 = t4 + 0.3;

                    string colBak = col1;
                    for (int yScan = y0; yScan <= y0 + FontHeight; yScan++)
                    {
                        col1 = col3 = Common.scaleColor(colBak, "FFFFFF", y0, y0 + FontHeight, yScan);
                        string colb = Common.scaleColor("000000", "777777", y0, y0 + FontHeight, yScan);
                        for (int j = -5; j <= 5; j++)
                        {
                            ass_out.Events.Add(
                                ev.StartReplace(t0).EndReplace(t1).TextReplace(
                                    ASSEffect.clip(0, yScan, PlayResX, yScan + 1) +
                                    ASSEffect.move(x + j * 5, y, x, y) + ASSEffect.a(1, Common.ToHex2(Math.Abs(j) * 40)) + ASSEffect.fad(t1 - t0, 0) + ASSEffect.c(1, colb) +
                                    ke.KText));
                        }
                        ass_out.Events.Add(
                            ev.StartReplace(t0).EndReplace(t2).TextReplace(
                                ASSEffect.clip(0, yScan, PlayResX, yScan + 1) +
                                ASSEffect.pos(x, y) + ASSEffect.a(1, "00") + ASSEffect.fad(t1 - t0, 0) + ASSEffect.c(1, colb) +
                                ke.KText));
                        ass_out.Events.Add(
                            ev.StartReplace(t2).EndReplace(t3).TextReplace(
                                ASSEffect.clip(0, yScan, PlayResX, yScan + 1) +
                                //                        ASSEffect.pos(x, y) + ASSEffect.a(1, "00") + ASSEffect.c(1, "111111") + ASSEffect.t(0, t3 - t2, ASSEffect.c(1, col1).t() + ASSEffect.a(1, "FF").t() + ASSEffect.a(3, "00").t() + ASSEffect.blur(2).t()) + ASSEffect.c(3, col3) +
                                ASSEffect.pos(x, y) + ASSEffect.a(1, "00") + ASSEffect.c(1, "111111") + ASSEffect.t(0, t3 - t2, ASSEffect.c(1, col1).t()) +
                                ke.KText));
                        ass_out.Events.Add(
                            ev.StartReplace(t3).EndReplace(t4).TextReplace(
                                ASSEffect.clip(0, yScan, PlayResX, yScan + 1) +
                                //ASSEffect.pos(x, y) + ASSEffect.a(1, "FF") + ASSEffect.blur(2) + ASSEffect.a(3, "00") + ASSEffect.c(3, col3) +
                                ASSEffect.pos(x, y) + ASSEffect.a(1, "00") + ASSEffect.c(1, col1) +
                                ke.KText));
                        for (int j = -5; j <= 5; j++)
                        {
                            ass_out.Events.Add(
                                ev.StartReplace(t4).EndReplace(t5).LayerReplace(5).TextReplace(
                                    ASSEffect.clip(0, yScan, PlayResX, yScan + 1) +
                                    //ASSEffect.move(x, y, x + j * 5, y) + ASSEffect.a(1, Common.ToHex2(Math.Abs(j) * 40)) + ASSEffect.c(1, col1) + ASSEffect.fad(0, t1 - t0) + ASSEffect.blur(2) + ASSEffect.a(3, "00") + ASSEffect.c(3, col3) +
                                    ASSEffect.move(x, y, x + j * 5, y) + ASSEffect.a(1, Common.ToHex2(Math.Abs(j) * 40)) + ASSEffect.c(1, col1) + ASSEffect.fad(0, t1 - t0) +
                                    ke.KText));
                        }
                        ass_out.Events.Add(
                            ev.StartReplace(t4).EndReplace(t5).TextReplace(
                                ASSEffect.clip(0, yScan, PlayResX, yScan + 1) +
                                //ASSEffect.pos(x, y) + ASSEffect.a(1, "FF") + ASSEffect.fad(0, t5 - t4) + ASSEffect.blur(2) + ASSEffect.c(3, col3) +
                                ASSEffect.pos(x, y) + ASSEffect.a(1, "00") + ASSEffect.fad(0, t5 - t4) + ASSEffect.c(1, col1) +
                                ke.KText));
                    }
                    col1 = col3 = colBak;
                    for (int j = 1; j <= 5; j++)
                    {
                        ass_out.Events.Add(
                            ev.StartReplace(t2 + j * 0.04).EndReplace(t3 + j * 0.04).TextReplace(
                                ASSEffect.move(x, y, x, y - 20) + ASSEffect.c(1, "FFFFFF") + ASSEffect.a(1, Common.ToHex2(Math.Abs(j) * 40)) + ASSEffect.fsc(100 + j * 8, 100 + j * 8) + ASSEffect.t(0, t3 - t2, ASSEffect.fsc(100 + j * 8 + 20, 100 + j * 8 + 20).t()) +
                                ke.KText));
                    }
                    ass_out.Events.Add(
                        ev.StartReplace(t2 + 0.15).EndReplace(t2 + 1).TextReplace(
                            ASSEffect.move(x, y, x, y + 30) + ASSEffect.a(1, "77") + ASSEffect.c(1, col1) + ASSEffect.fad(0, 0.5) + ASSEffect.fsc(70, 70) +
                            ke.KText));

                    Par = new Particle2("FFDE7D", "FFCC33", t2, t2 + 0.3, 0.001, 1, -15, 15, -15, 15, 1, 2)
                    {
                        Star = false, Pt0Size = 2
                    };
                    ass_out.Events.AddRange(Par.Create(new MovingRound(t2, t2 + 0.3, x, y, 30, -Math.PI)
                    {
                        MinDX = -2, MaxDX = 2, MinDY = 2, MaxDY = 2
                    }));
                }
                x0 = bak_x0;
                string arcCol = "FFFFFF";
                if (iEv % 2 == 0)
                {
                    Par = new Particle2(arcCol, "FFCC33", ev.Start - 0.6 - 0.3, ev.Start - 0.3, 0.005, 8, sw / 0.6 - 40, sw / 0.6 + 40, -10, 10, 2, 5)
                    {
                        Star = false, Pt0Size = 2
                    };
                    ass_out.Events.AddRange(Par.Create(new MovingArc(ev.Start - 0.6 - 0.3, ev.Start - 0.3, x0 - 80, y0 + FontHeight / 2, x0 + sw - 80, y0 + FontHeight / 2, 60, -1.2, 1.2)
                    {
                        GaussRnd = 2
                    }));
                }
                else
                {
                    Par = new Particle2(arcCol, "FFCC33", ev.Start - 0.6 - 0.3, ev.Start - 0.3, 0.005, 8, -sw / 0.6 - 40, -sw / 0.6 + 40, -10, 10, 2, 5)
                    {
                        Star = false, Pt0Size = 2
                    };
                    ass_out.Events.AddRange(Par.Create(new MovingArc(ev.Start - 0.6 - 0.3, ev.Start - 0.3, x0 + sw + 80, y0 + FontHeight / 2, x0 + 80, y0 + FontHeight / 2, 60, Math.PI - 1.2, Math.PI + 1.2)
                    {
                        GaussRnd = 2
                    }));
                }
            }

            ass_out.SaveFile(OutFileName);
        }
예제 #21
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>();

            this.Font = new System.Drawing.Font("FA 瑞筆行書M", 13);

            Particle pt = new Particle
            {
                AreaHeight    = 80,
                AreaWidth     = 200,
                IsRandomColor = true,
                Color         = new ASSColor {
                    A = 0, R = 255, G = 255, B = 255, Index = 1
                },
                Color1 = new ASSColor {
                    A = 0, R = 255, G = 255, B = 255, Index = 1
                },
                Color2 = new ASSColor {
                    A = 0, R = 0xEF, G = 0xF7, B = 0xFB, Index = 1
                },
                Count           = 100,
                FontSize        = this.FontHeight,
                MinLast         = 1,
                MaxLast         = 2,
                IsMove          = true,
                MoveStyle       = 2,
                IsPatternScale  = false,
                PatternScaleX   = 250,
                PatternScaleY   = 250,
                ParticlePattern = ParticlePatternType.o,
                Style           = "pt",
                XOffset         = 0,
                YOffset         = 0,
                IsRotate        = true,
                BE = 1
            };

            for (int i = 0; i < 20; i++)
            {
                if (i >= 10)
                {
                    this.Font = new System.Drawing.Font("華康行書體(P)", 13);
                }
                ASSEvent        ev     = ass_in.Events[i];
                List <KElement> kelems = ev.SplitK(false);
                int             sumw   = GetTotalWidth(ev);
                int             x0     = (PlayResX - MarginLeft - MarginRight - sumw) / 2 + MarginLeft;
                int             kSum   = 0;
                for (int ik = 0; ik < kelems.Count; ik++)
                {
                    KElement elem = kelems[ik];
                    Size     sz   = this.GetSize(elem.KText);
                    int      x    = x0;
                    x0 += sz.Width + this.FontSpace;
                    int y = PlayResY - MarginBottom;
                    if (i >= 10)
                    {
                        y = MarginTop + FontHeight;
                    }
                    double kStart = (double)kSum * 0.01;
                    double kEnd   = (double)(kSum + elem.KValue) * 0.01;
                    kEnd = kStart + 0.6;
                    double kMid = (kStart + kEnd) * 0.5;
                    double kQ1  = kStart + (kEnd - kStart) * 0.1;

                    double r  = (double)ik / (double)(kelems.Count - 1);
                    double r0 = 1.0 - r;

                    int fd_xof = (int)((double)(ik - (kelems.Count - 1) / 2) / (double)(kelems.Count - 1) * (double)PlayResX * 0.2);

                    // particle need an7 position
                    pt.X     = x;
                    pt.Y     = y - FontHeight;
                    pt.Start = ev.Start + kStart;
                    pt.End   = ev.Start + kEnd;

                    // an7 -> an5
                    x += FontWidth / 2;
                    y -= FontHeight / 2;

                    // 提前1秒出现
                    ass_out.Events.Add(ev.StartReplace(ev.Start - r0 * 1.0).TextReplace(
                                           ASSEffect.fad(0.3, 0) + ASSEffect.be(1) +
                                           ASSEffect.pos(x, y) + ASSEffect.an(5) +
                                           ASSEffect.t(kStart + r0 * 1.0, kEnd + r0 * 1.0, ASSEffect.be(10).t() + ASSEffect.a(1, "FF").t()) +
                                           ASSEffect.t(kStart + r0 * 1.0 + 0.2, kEnd + r0 * 1.0, ASSEffect.a(3, "FF").t()) +
                                           elem.KText));

                    ass_out.Events.AddRange(pt.Create());

                    kSum += elem.KValue;
                }
            }

            ass_out.SaveFile(OutFileName);
        }
예제 #22
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>();

            Random rnd = new Random();

            int mask_xOffset = -4;

            double pp = 0.6;

            for (int iEv = 0; iEv < ass_in.Events.Count; iEv++)
            {
                ASSEvent        ev     = ass_in.Events[iEv];
                List <KElement> kelems = ev.SplitK(false);

                /// an7 pos
                int x0 = MarginLeft;
                int y0 = PlayResY - MarginBottom - FontHeight;

                int kSum = 0;

                for (int i = 0; i < kelems.Count; i++)
                {
                    KElement ke = kelems[i];
                    double   r  = (double)i / (double)(kelems.Count - 1);
                    double   r0 = 1.0 - r;
                    //Size sz = GetSize(ke.KText);
                    StringMask mask = GetMask(ke.KText, x0 + FontSpace, y0);
                    Size       sz   = new Size(mask.Width, mask.Height);

                    double kStart = kSum * 0.01;
                    double kEnd   = kStart + ke.KValue * 0.01;

                    /// an5 pos
                    int x = x0 + FontSpace + sz.Width / 2;
                    int y = y0 + FontHeight / 2;

                    x0 += this.FontSpace + sz.Width;
                    y0  = y0;

                    kSum += ke.KValue;

                    double t0 = ev.Start - r0 * 0.5;
                    double t1 = t0 + 0.2;          // 出现
                    double t2 = ev.Start + kStart; // 保持
                    double t3 = t2 + 0.2;          // K效果
                    double t4 = ev.End - r0 * 0.5; // 保持
                    double t5 = t4 + 0.2;          // 消失

                    ass_out.Events.Add(
                        ev.StartReplace(t0).EndReplace(t1).TextReplace(
                            ASSEffect.pos(x, y) + ASSEffect.be(100) +
                            ASSEffect.fad(t1 - t0, 0) + ASSEffect.t(0, t1 - t0, ASSEffect.be(1).t()) +
                            ke.KText));

                    ass_out.Events.Add(
                        ev.StartReplace(t1).EndReplace(t2).TextReplace(
                            ASSEffect.pos(x, y) + ASSEffect.be(1) +
                            ke.KText));

                    ass_out.Events.Add(
                        ev.StartReplace(t2).EndReplace(t4).TextReplace(
                            ASSEffect.pos(x, y) + ASSEffect.be(1) + ASSEffect.a(1, "FF") + ASSEffect.c(3, "FFFFFF") +
                            ke.KText));

                    foreach (ASSPoint pt in mask.Points)
                    {
                        if (!Common.RandomBool(rnd, pp))
                        {
                            continue;
                        }
                        double rStart = t2;
                        double rEnd   = t2 + Common.RandomDouble(rnd, 0.1, 1.5);
                        int    dx     = rnd.Next() % 20 + 8;
                        int    dy     = rnd.Next() % 20 + 8;
                        int    xx2    = pt.X;
                        int    yy2    = pt.Y;
                        if (Common.RandomBool(rnd, (double)(pt.X - mask.X0) / (double)mask.Width))
                        {
                            xx2 += dx;
                        }
                        else
                        {
                            xx2 -= dx;
                        }
                        if (Common.RandomBool(rnd, (double)(pt.Y - mask.Y0) / (double)mask.Height))
                        {
                            yy2 += dy;
                        }
                        else
                        {
                            yy2 -= dy;
                        }
                        ass_out.Events.Add(
                            ev.StartReplace(rStart).EndReplace(rEnd).StyleReplace("pt").TextReplace(
                                ASSEffect.move(pt.X, pt.Y, xx2, yy2) + ASSEffect.fad(0, rEnd - rStart) +
                                "o"));
                    }

                    ass_out.Events.Add(
                        ev.StartReplace(t4).EndReplace(t5).TextReplace(
                            ASSEffect.pos(x, y) + ASSEffect.be(1) + ASSEffect.a(1, "FF") + ASSEffect.c(3, "FFFFFF") +
                            ASSEffect.fad(0, t5 - t4) + ASSEffect.t(0, t5 - t4, ASSEffect.be(100).t()) +
                            ke.KText));
                }
            }

            ass_out.SaveFile(OutFileName);
        }