Exemplo n.º 1
0
        public override void Run()
        {
            ASS ass_in  = ASS.FromFile(this.InFileName);
            ASS ass_out = new ASS();

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

            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);
        }
Exemplo n.º 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>();

            ass_out.Events.Add(ass_in.Events[0]);

            this.Font = new System.Drawing.Font("DFGRuLeiA-W5", 13);
            Particle pt = new Particle
            {
                AreaHeight    = 50,
                AreaWidth     = 100,
                IsRandomColor = false,
                Color         = new ASSColor {
                    A = 0, R = 255, G = 255, B = 255, Index = 1
                },
                Count           = 10,
                FontSize        = this.FontHeight,
                MinLast         = 1,
                MaxLast         = 2,
                IsMove          = true,
                IsPatternScale  = true,
                PatternScaleX   = 250,
                PatternScaleY   = 250,
                ParticlePattern = ParticlePatternType.Circle,
                Style           = "particle",
                XOffset         = 0,
                YOffset         = 0,
                IsRotate        = false,
            };

            for (int i = 1; i <= 15; i++)
            {
                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      = MarginTop;
                    string color  = Common.scaleColor("7A93EB", "6939C8", (double)ik / (double)(kelems.Count - 1));
                    double kStart = (double)kSum * 0.01;
                    double kEnd   = (double)(kSum + elem.KValue) * 0.01;
                    double kMid   = (kStart + kEnd) * 0.5;
                    double kQ1    = kStart + (kEnd - kStart) * 0.25;

                    // an7 -> an5
                    int x5 = x + sz.Width / 2;
                    int y5 = y + sz.Height / 2;

                    ass_out.Events.Add(ev.TextReplace(ASSEffect.pos(x5, y5) + ASSEffect.c(1, color) +
                                                      ASSEffect.t(0, 0.001, ASSEffect.c(1, "555555").t()) +
                                                      ASSEffect.t(kStart, kQ1, ASSEffect.c(1, "FFFFFF").t() + ASSEffect.fsc(170, 170).t()) +
                                                      ASSEffect.t(kQ1, kEnd, ASSEffect.c(1, color).t() + ASSEffect.fsc(100, 100).t()) +
                                                      elem.KText));

                    pt.X     = x;
                    pt.Y     = y;
                    pt.Start = ev.Start + kStart;
                    pt.End   = ev.Start + kEnd;

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

                    kSum += elem.KValue;
                }
            }

            for (int i = 16; i <= 30; i++)
            {
                ass_out.Events.Add(ass_in.Events[i]);
            }

            ass_out.SaveFile(this.OutFileName);
        }
Exemplo n.º 3
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", 26, GraphicsUnit.Pixel);
            this.MaskStyle = "Style: Default,FA 瑞筆行書M,26,&H00FFCEE7,&HFF0000FF,&H00FF2D49,&HFF0A5A84,-1,0,0,0,100,100,1,0,1,2,0,5,20,20,10,128";

            for (int i = 0; i < 21; i++)
            {
                ASSEvent        ev     = ass_in.Events[i];
                List <KElement> kelems = ev.SplitK(true);
                if (i >= 11)
                {
                    this.Font      = new System.Drawing.Font("華康行書體(P)", 26, GraphicsUnit.Pixel);
                    this.MaskStyle = "Style: Default,華康行書體(P),26,&H00FFCEE7,&HFF0000FF,&H00FF2D49,&HFF0A5A84,-1,0,0,0,100,100,1,0,1,2,0,5,20,20,10,136";
                }
                int sumw = GetTotalWidth(ev);
                int x0   = (PlayResX - MarginLeft - MarginRight - sumw) / 2 + MarginLeft;
                int kSum = 0;
                for (int ik = 0; ik < kelems.Count; ik++)
                {
                    Console.WriteLine("{0} / {1} : {2} / {3}", i + 1, ass_in.Events.Count, ik + 1, kelems.Count);
                    KElement elem = kelems[ik];
                    Size     sz   = this.GetSize(elem.KText);
                    int      x    = x0;
                    x0 += sz.Width + this.FontSpace;
                    int y = PlayResY - MarginBottom;
                    if (i == 5)
                    {
                        y -= FontHeight + 10;
                    }
                    if (i >= 11)
                    {
                        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);

                    // an7 -> an5
                    x += sz.Width / 2;
                    y -= FontHeight / 2;

                    // 0.5秒内出现
                    ass_out.Events.Add(ev.StartReplace(ev.Start - r0 * 0.5).EndReplace(ev.Start - r0 * 0.5 + 0.3).TextReplace(
                                           ASSEffect.move(x + fd_xof, y, x, y) + ASSEffect.an(5) + ASSEffect.be(1) + ASSEffect.a(1, "FF") + ASSEffect.a(3, "FF") + ASSEffect.fsc(400, 400) +
                                           ASSEffect.t(0, 0.3, ASSEffect.fsc(100, 100).t() + ASSEffect.a(1, "00").t() + ASSEffect.a(3, "00").t() + ASSEffect.fry(-360).t()) +
                                           elem.KText));

                    double newStart = ev.Start;
                    if (ev.Start - r0 * 0.5 + 0.3 > ev.Start)
                    {
                        newStart = ev.Start - r0 * 0.5 + 0.3;
                    }
                    else
                    {
                        ass_out.Events.Add(ev.StartReplace(ev.Start - r0 * 0.5 + 0.3).EndReplace(ev.Start).TextReplace(
                                               ASSEffect.pos(x, y) + ASSEffect.an(5) + ASSEffect.be(1) + elem.KText));
                    }

                    //ass_out.Events.Add(ev.TextReplace(
                    //  ASSEffect.pos(x, y) + ASSEffect.an(5) + elem.KText));
                    if (i < 11)
                    {
                        ass_out.Events.Add(ev.StartReplace(newStart).EndReplace(ev.Start + kStart).TextReplace(
                                               ASSEffect.pos(x, y) + ASSEffect.an(5) + ASSEffect.be(1) + elem.KText));
                        ass_out.Events.Add(ev.StartReplace(ev.Start + kStart).EndReplace(ev.Start + kEnd).TextReplace(
                                               ASSEffect.pos(x, y) + ASSEffect.an(5) + ASSEffect.be(1) +
                                               ASSEffect.t(0, kQ1 - kStart, ASSEffect.c(1, "FFFFFF").t() + ASSEffect.c(1, "FFFFFF").t() + ASSEffect.fsc(200, 200).t()) +
                                               ASSEffect.t(kQ1 - kStart, kEnd - kStart, ASSEffect.c(3, "A4CEE7").t() + ASSEffect.c(1, "072D49").t() + ASSEffect.fsc(100, 100).t()) +
                                               elem.KText));
                        ass_out.Events.Add(ev.StartReplace(ev.Start + kEnd).EndReplace(ev.End).TextReplace(
                                               ASSEffect.pos(x, y) + ASSEffect.an(5) + ASSEffect.be(1) + ASSEffect.c(1, "072D49") + ASSEffect.c(3, "A4CEE7") + elem.KText));
                    }
                    else
                    {
                        ass_out.Events.Add(ev.StartReplace(newStart).TextReplace(
                                               ASSEffect.pos(x, y) + ASSEffect.an(5) + ASSEffect.be(1) + elem.KText));
                    }

                    // 0.5秒内消失
                    if (i < 11)
                    {
                        ass_out.Events.Add(ev.StartReplace(ev.End + r * 0.5).EndReplace(ev.End + r * 0.5 + 0.3).TextReplace(
                                               ASSEffect.move(x, y, x + fd_xof, y) + ASSEffect.be(1) + ASSEffect.an(5) + ASSEffect.c(1, "072D49") + ASSEffect.c(3, "A4CEE7") +
                                               ASSEffect.t(0, 0.3, ASSEffect.fsc(400, 400).t() + ASSEffect.a(1, "FF").t() + ASSEffect.a(3, "FF").t() + ASSEffect.fry(-360).t()) +
                                               elem.KText));
                        ass_out.Events.Add(ev.StartReplace(ev.End).EndReplace(ev.End + r * 0.5).TextReplace(
                                               ASSEffect.pos(x, y) + ASSEffect.an(5) + ASSEffect.be(1) + ASSEffect.c(1, "072D49") + ASSEffect.c(3, "A4CEE7") + elem.KText));
                    }
                    else
                    {
                        ass_out.Events.Add(ev.StartReplace(ev.End + r * 0.5).EndReplace(ev.End + r * 0.5 + 0.3).TextReplace(
                                               ASSEffect.move(x, y, x + fd_xof, y) + ASSEffect.be(1) + ASSEffect.an(5) +
                                               ASSEffect.t(0, 0.3, ASSEffect.fsc(400, 400).t() + ASSEffect.a(1, "FF").t() + ASSEffect.a(3, "FF").t() + ASSEffect.fry(-360).t()) +
                                               elem.KText));
                        ass_out.Events.Add(ev.StartReplace(ev.End).EndReplace(ev.End + r * 0.5).TextReplace(
                                               ASSEffect.pos(x, y) + ASSEffect.an(5) + ASSEffect.be(1) + elem.KText));
                    }

                    kSum += elem.KValue;
                }
            }

            ass_out.SaveFile(OutFileName);
        }
Exemplo n.º 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>();

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