コード例 #1
0
        public override void Run()
        {
            for (int i = 0; i < 3; i++)
            {
                ParticleIllusionExporter pie = new ParticleIllusionExporter();
                pie.Init();
                CompositeCurve curve = new CompositeCurve {
                    MinT = 0, MaxT = 10
                };
                Circle circle = new Circle {
                    MinT = 0 + (double)i * Math.PI * 2.0 / 3.0, MaxT = Math.PI * 2 * 10 + (double)i * Math.PI * 2.0 / 3.0, R = 100, X0 = 0, Y0 = 0
                };
                CompositeCurve path = new CompositeCurve {
                    MinT = 0, MaxT = 10
                };

/*                path.AddCurve(0, 2.5, new Line { X0 = 100, Y0 = 100, X1 = 500, Y1 = 100 });
 *              path.AddCurve(2.5, 5, new Line { X0 = 500, Y0 = 100, X1 = 500, Y1 = 300 });
 *              path.AddCurve(5, 7.5, new Line { X0 = 500, Y0 = 300, X1 = 100, Y1 = 300 });
 *              path.AddCurve(7.5, 10, new Line { X0 = 100, Y0 = 300, X1 = 100, Y1 = 100 });*/
                path.AddCurve(0, 10, new Circle {
                    X0 = 250, Y0 = 250, R = 130
                });
                CompoundCurve cc = new CompoundCurve {
                    MinT = 0, MaxT = 10
                };
                cc.AddCurve(0, 10, circle);
                cc.AddCurve(0, 10, path);
                curve.AddCurve(curve.MinT, curve.MaxT, cc);
                foreach (ASSPointF pt in curve.GetPath_DT(0.01))
                {
                    pie.Add(pt.T, pt);
                }
                pie.SaveToFile(@"g:\workshop\test\" + i + ".txt");
            }
        }
コード例 #2
0
        public override void Run()
        {
            ASS ass_in  = ASS.FromFile(this.InFileName);
            ASS ass_out = new ASS()
            {
                Header = ass_in.Header, 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);
                int             sw     = GetTotalWidth(ev);
                int             x0     = (PlayResX - sw) / 2;
                int             xxx    = x0;
                int             y0     = PlayResY - MarginBottom - FontHeight;
                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];
                    Size     sz     = GetSize(ke.KText);
                    double   kStart = ev.Start + kSum * 0.01;
                    double   kEnd   = kStart + ke.KValue * 0.01;
                    kSum += ke.KValue;
                    int        x     = x0 + this.FontSpace + sz.Width / 2;
                    int        y     = y0 + FontHeight / 2;
                    int        x_an7 = x0;
                    int        y_an7 = y0;
                    StringMask mask  = GetMask(ke.KText, x, y);
                    x0 += this.FontSpace + sz.Width;
                    if (ke.KText.Trim().Length == 0)
                    {
                        continue;
                    }

                    double t0 = ev.Start - 0.5 + iK * 0.05;
                    double t1 = t0 + 0.3;
                    double t2 = kStart - 0.07;
                    double t3 = kEnd;
                    double t4 = ev.End - 0.5 + iK * 0.05;
                    double t5 = t4 + 0.3;

                    Func <double, string> fMainColor = ti => (ti < t2) ? Common.scaleColor("FFFFFF", "000000", (ti - t1) / 0.2) : "FFFFFF";
                    Func <double, string> fMainAlpha = ti => (ti < t2) ? "55" : "00";

                    ass_out.AppendEvent(60, "jp", t0, t1,
                                        move(x - 100, y, x, y) + a(1, "55") + fsc(150, 150) + fad(t1 - t0, 0) +
                                        frx(Common.RandomInt(rnd, 200, 500)) +
                                        fry(Common.RandomInt(rnd, 200, 500)) +
                                        frz(Common.RandomInt(rnd, 200, 500)) +
                                        t(frx(0).t() + fry(0).t() + frz(0).t() + fsc(100, 100).t()) +
                                        ke.KText);
                    ass_out.AppendEvent(55, "jp", t2, t2 + 0.25,
                                        pos(x, y) + a(1, "00") + bord(8) + blur(8) + fad(0, 0.18) + a(3, "00") +
                                        ke.KText);
                    {
                        double ti = t1;
                        while (ti < t4)
                        {
                            double ti1 = ti + 0.04;
                            ass_out.AppendEvent(50, "jp", ti, ti1 + 0.04,
                                                pos(Common.RandomInt(rnd, x - 3, x + 3), Common.RandomInt(rnd, y - 3, y + 3)) + a(1, fMainAlpha(ti)) + fad(0, Common.RandomDouble(rnd, 0.04, 0.09)) +
                                                c(1, fMainColor(ti)) +
                                                ke.KText);
                            ti = ti1;
                        }
                        ass_out.AppendEvent(60, "jp", ti, t5,
                                            move(x, y, x + 100, y) + a(1, "00") + fad(0, t5 - ti) + c(1, "FFFFFF") +
                                            t(frx(Common.RandomInt(rnd, 200, 500)).t() + fry(Common.RandomInt(rnd, 200, 500)).t() + frz(Common.RandomInt(rnd, 200, 500)).t() + fsc(150, 150).t()) +
                                            ke.KText);
                    }

                    string cShad = "000000";
                    for (int i = 0; i < 2; i++)
                    {
                        ass_out.AppendEvent(40, "jp", t1, t4,
                                            pos(x, y) + a(1, "00") + blur(2) + c(1, cShad) +
                                            ke.KText);
                    }

                    {
                        CompositeCurve curve = new CompositeCurve {
                            MinT = t2 - 0.1, MaxT = t2 + 0.1
                        };
                        double ptag = Common.RandomDouble(rnd, 0, Math.PI);
                        double ptr  = 100;
                        double ptx0 = x + Math.Cos(ptag) * ptr;
                        double pty0 = y - Math.Sin(ptag) * ptr;
                        double ptx1 = x - Math.Cos(ptag) * ptr;
                        double pty1 = y + Math.Sin(ptag) * ptr;
                        Line   line = new Line {
                            X0 = ptx0, Y0 = pty0, X1 = ptx1, Y1 = pty1
                        };
                        curve.AddCurve(curve.MinT, curve.MaxT, line);
                        List <ASSPointF> pts = curve.GetPath_Dis(1, 1.2);
                        foreach (ASSPointF pt in pts)
                        {
                            if (!Common.InRange(0, PlayResX, pt.X) || !Common.InRange(0, PlayResY, pt.Y))
                            {
                                continue;
                            }
                            ass_out.AppendEvent(30, "pt", pt.T, pt.T + 0.25,
                                                pos(pt.X, pt.Y) + a(1, "00") + a(3, "77") + c(1, "FFD9A1") + c(3, "FFD9A1") + fad(0, 0.1) +
                                                bord(4) + blur(4) + t(bord(2).t() + blur(2).t()) +
                                                p(1) + "m 0 0 l 1 0 1 1 0 1");
                            ass_out.AppendEvent(32, "pt", pt.T, pt.T + 0.25,
                                                pos(pt.X, pt.Y) + a(1, "00") + a(3, "44") + c(1, "FFFFFF") + c(3, "FFFFFF") + fad(0, 0.1) +
                                                bord(2.5) + blur(2.5) + t(bord(1.3).t() + blur(1.3).t()) +
                                                p(1) + "m 0 0 l 1 0 1 1 0 1");
                        }
                        pts = curve.GetPath_DT(0.01);
                        foreach (ASSPointF pt in pts)
                        {
                            if (!Common.InRange(0, PlayResX, pt.X) || !Common.InRange(0, PlayResY, pt.Y))
                            {
                                continue;
                            }
                            ass_out.AppendEvent(35, "pt", pt.T, pt.T + 0.01,
                                                pos(pt.X, pt.Y) + a(1, "00") + a(3, "00") + c(1, "FFFFFF") + c(3, "FFFFFF") +
                                                bord(13) + blur(13) +
                                                p(1) + "m 0 0 l 1 0 1 1 0 1");
                        }
                    }
                }
            }

            Console.WriteLine(ass_out.Events.Count);
            ass_out.SaveFile(this.OutFileName);
        }
コード例 #3
0
        public override void Run()
        {
            ASS ass_in  = ASS.FromFile(this.InFileName);
            ASS ass_out = new ASS()
            {
                Header = ass_in.Header, Events = new List <ASSEvent>()
            };

            for (int iEv = 0; iEv < ass_in.Events.Count; iEv++)
            {
                bool isJp = iEv <= 13;
                //if (isJp) continue;
                //if (iEv != 5 && iEv != 6) continue;
                ASSEvent        ev     = ass_in.Events[iEv];
                List <KElement> kelems = ev.SplitK(true);
                int             x0     = MarginLeft;
                if (!isJp)
                {
                    int totalWidth = 0;
                    foreach (KElement ke in kelems)
                    {
                        this.MaskStyle = "Style: Default,宋体,40,&H00FFFFFF,&HFFFFFFFF,&HFFFFFFFF,&HFFFFFFFF,0,0,0,0,100,100,0,0,0,0,0,7,0,0,0,0";
                        string outlineFontname = isJp ? "DFGMaruMoji-SL" : "華康少女文字W5(P)";
                        int    outlineEncoding = isJp ? 128 : 136;
                        int    yoffset         = 279;
                        int    ox_offset       = 0;
                        string outlineString   = GetOutline(10, 10, ke.KText[0], outlineFontname, outlineEncoding, FontHeight, 0, yoffset);
                        Size   sz = GetMask(p(4) + outlineString, 0, 0).GetSize();
                        if (ke.KText.Trim().Length == 0)
                        {
                            sz.Width = this.FontHeight;
                        }
                        totalWidth += sz.Width + FontSpace;
                    }
                    x0 = PlayResX - MarginRight - totalWidth;
                }
                int    bakx0      = x0;
                int    y0         = (!isJp) ? (PlayResY - MarginBottom - FontHeight) : MarginTop;
                int    kSum       = 0;
                string outlines   = "";
                double lastKStart = -1;
                double lastx0     = 0;
                double lastt0     = 0;
                for (int iK = 0; iK < kelems.Count; iK++)
                {
                    if (iK == 15)
                    {
                        int asfasd = 2;
                    }
                    Console.WriteLine("{0} / {1} : {2} / {3}", iEv + 1, ass_in.Events.Count, iK + 1, kelems.Count);
                    KElement ke = kelems[iK];

                    /*this.MaskStyle = isJp ?
                     *  "Style: Default,DFGMaruMoji-SL,40,&H00FFFFFF,&HFFFFFFFF,&HFFFFFFFF,&HFFFFFFFF,0,0,0,0,100,100,0,0,0,0,0,5,0,0,0,128" :
                     *  "Style: Default,方正准圆_GBK,40,&H00FFFFFF,&HFFFFFFFF,&HFFFFFFFF,&HFFFFFFFF,0,0,0,0,100,100,0,0,0,0,0,5,0,0,0,134";*/
                    this.MaskStyle = "Style: Default,宋体,40,&H00FFFFFF,&HFFFFFFFF,&HFFFFFFFF,&HFFFFFFFF,0,0,0,0,100,100,0,0,0,0,0,7,0,0,0,0";
                    string outlineFontname = isJp ? "DFGMaruMoji-SL" : "華康少女文字W5(P)";
                    int    outlineEncoding = isJp ? 128 : 136;
                    int    yoffset         = 279;
                    int    ox_offset       = 0;
                    string outlineString   = "";
                    Size   sz = new Size();
                    if (ke.KText.Trim().Length == 0)
                    {
                        sz = new Size {
                            Width = FontHeight, Height = FontHeight
                        };
                    }
                    else
                    {
                        outlineString = GetOutline(10, 10, ke.KText[0], outlineFontname, outlineEncoding, FontHeight, 0, yoffset);
                        sz            = GetMask(p(4) + outlineString, 0, 0).GetSize();
                    }
                    double kStart = ev.Start + kSum * 0.01;
                    if (ke.IsSplit)
                    {
                        if (lastKStart >= 0)
                        {
                            kStart = lastKStart;
                        }
                        else
                        {
                            lastKStart = kStart;
                        }
                    }
                    else
                    {
                        lastKStart = -1;
                    }
                    double kEnd = kStart + ke.KValue * 0.01;
                    kSum += ke.KValue;
                    int x     = x0 + this.FontSpace + sz.Width / 2;
                    int y     = y0 + FontHeight / 2;
                    int x_an7 = x0;
                    int y_an7 = y0;
                    x0    += this.FontSpace + sz.Width;
                    lastx0 = x0;
                    if (ke.KText.Trim().Length == 0)
                    {
                        continue;
                    }
                    if (!isJp)
                    {
                        if (ke.KText == "(")
                        {
                            x -= 19;
                        }
                        if (ke.KText == ")")
                        {
                            x -= 2;
                        }
                        if (ke.KText == "!")
                        {
                            x -= 10;
                        }
                    }
                    outlineString = GetOutline(ox_offset + x - sz.Width / 2, y - FontHeight / 2, ke.KText[0], outlineFontname, outlineEncoding, FontHeight, 0, yoffset);
                    outlines     += outlineString;
                    double perc = (double)iK / (double)(kelems.Count - 1);

                    double t0 = ev.Start - 0.5 + iK * 0.04;
                    lastt0 = t0;
                    double t1 = t0 + 0.3;
                    double t2 = kStart - 0.02;
                    double t3 = t2 + 0.4;
                    double t4 = ev.End - 0.5 + iK * 0.04;
                    //t3 = (t4 - t2) * (1 - (1 - perc) * 0.25) + t2;
                    if (t3 > t4)
                    {
                        t3 = t4;
                    }
                    double t5 = t4 + 0.3;

                    if (!isJp)
                    {
                        t2 = ev.Start + (x0 - bakx0) / 600.0 + 0.3;
                    }

                    string mainColor   = Common.scaleColor("3F40FF", "3F68FF", perc);
                    string shadowColor = Common.scaleColor("3F40FF", "3F68FF", 1 - perc);

                    for (int i = -4; i <= 4; i++)
                    {
                        ass_out.AppendEvent(70, "pt", t0, t1,
                                            move(0 + i * 5, 0, 0, 0) + fad(0.15, 0) + a(1, "DD") + a(3, "DD") + c(1, mainColor) +
                                            ybord(0) + xbord(10 + Math.Abs(i) * 1) + blur(8 + Math.Abs(i) * 1) +
                                            t(bord(2).t() + blur(0).t()) +
                                            p(4) + outlineString);
                    }
                    ass_out.AppendEvent(49, "pt", t1 - 0.3, t4,
                                        pos(0, 0) + a(1, "FF") + a(3, "00") + c(3, shadowColor) + bord(5) + blur(5) + fad(0.3, 0) +
                                        p(4) + outlineString);
                    if (isJp)
                    {
                        ass_out.AppendEvent(70, "pt", t2, t3,
                                            pos(0, 0) + a(1, "00") + a(3, "00") + c(3, mainColor) + bord(2) + fad(0, t3 - t2) +
                                            p(4) + outlineString);
                        ass_out.AppendEvent(69, "pt", t2, t3,
                                            pos(0, 0) + a(1, "FF") + a(3, "00") + bord(8) + fad(0, t3 - t2) + blur(8) +
                                            p(4) + outlineString);
                    }
                    ass_out.AppendEvent(50, "pt", t1, t4,
                                        pos(0, 0) + fad(0.3, 0) + a(1, "00") + a(3, "00") + c(1, mainColor) + bord(2) +
                                        p(4) + outlineString);

                    //if (isJp)
                    {
                        double dt = 1.7;
                        for (double ptt0 = t2; ptt0 < t4; ptt0 += dt)
                        {
                            double fadeout = 0.5;
                            double fadein  = 0.5;
                            if (ptt0 == t2)
                            {
                                fadein = 0.2;
                            }
                            double ptt1 = ptt0 + dt;
                            if (ptt1 > t4)
                            {
                                ptt1    = t4;
                                fadeout = 0.2;
                            }
                            string s  = "";
                            double r1 = 40;
                            double r2 = 40;
                            for (int i = 0; i < 20; i++)
                            {
                                double ag  = Common.RandomDouble(rnd, 0, 2 * Math.PI);
                                double ptx = Math.Cos(ag) * r1;
                                double pty = Math.Sin(ag) * r2;
                                if (i == 0)
                                {
                                    s += "m";
                                }
                                if (i == 1)
                                {
                                    s += " l";
                                }
                                s += string.Format(" {0} {1}", (int)ptx, (int)pty);
                            }
                            ass_out.AppendEvent(80, "pt", ptt0 - fadein, ptt1 + fadeout,
                                                clip(4, outlineString) + pos(x + 5, y) + org(x, y) + a(1, "22") + fad(fadein, fadeout) +
                                                t(frz((int)((ptt0 - ptt1) * 360 / dt)).t()) + blur(3) +
                                                p(1) + s);
                        }
                    }

                    for (int i = 0; i < 10; i++)
                    {
                        string moveString = move(0, 0, 0 - 100, 0);
                        if (iEv == 2 || iEv == 4)
                        {
                            moveString = move(0, 0, 0, 0 + 100);
                        }
                        if (iEv == 5 || iEv == 6)
                        {
                            moveString = move(0, 0, 0, 0 + 100);
                        }
                        ass_out.AppendEvent(60 - i, "pt", t4 + i * 0.01, t5 + i * 0.01,
                                            moveString + fad(0, 0.2) + a(1, "00") + a(3, "77") + c(1, mainColor) + bord(2) +
                                            t(blur(5).t()) + t(0, 0.05, a(1, "DD").t() + a(3, "DD").t()) + t(0.25, 0.3, a(1, "00").t()) +
                                            p(4) + outlineString);
                        ass_out.AppendEvent(50 - i, "pt", t4 + i * 0.01, t5 + i * 0.01,
                                            moveString + move(x, y, x - 100, y) + fad(0, 0.2) + a(1, "FF") + a(3, "CC") + c(3, shadowColor) + bord(5) + blur(5) +
                                            p(4) + outlineString);
                    }
                }

                if (iEv == 0 || iEv == 3 || true)
                {
                    double xstart = 0;
                    double xend   = lastx0 + FontHeight;
                    if (!isJp)
                    {
                        xstart = bakx0 - FontHeight;
                        xend   = PlayResX;
                    }
                    ass_out.AppendEvent(200, "pt", ev.Start, ev.Start + (xend - xstart) / 600.0,
                                        clip(4, outlines) + move(xstart, y0 + FontHeight / 2, xend, y0 + FontHeight / 2) +
                                        a(1, "00") + frz(-45) + blur(8) + fscx(200) +
                                        p(1) + "m 10 -50 l 10 50 -10 50 -10 -50");
                }

                if (!isJp)
                {
                    continue;
                }

                string[] SS =
                {
                    "xxxxxxxxx.xx.x",
                    "xx.x...xxxxxx."
                };
                for (int i = 0; i < 2; i++)
                {
                    if (SS[1 - i][iEv] == '.')
                    {
                        continue;
                    }

                    Line line = new Line {
                        X0 = lastx0 + 5, Y0 = y0 + FontHeight + 7, X1 = MarginLeft
                    };
                    if (i == 1)
                    {
                        line.X0 = MarginLeft;
                        line.X1 = lastx0 + 5;
                        line.Y0 = y0 - 8;
                    }
                    line.Y1 = line.Y0;
                    CompositeCurve curve = new CompositeCurve {
                        MinT = ev.End - 0.5
                    };
                    if (i == 1)
                    {
                        curve.MinT = ev.Start - 0.5;
                    }
                    curve.MaxT = curve.MinT + Math.Abs(line.X0 - line.X1) / 1000.0;
                    curve.AddCurve(curve.MinT, curve.MaxT, line);
                    List <ASSPointF> pts = curve.GetPath_DT(1.0 / 1000.0);
                    foreach (ASSPointF pt in pts)
                    {
                        ass_out.AppendEvent(8, "pt", pt.T, pt.T + 0.8,
                                            pos(pt.X, pt.Y) + a(1, "77") + a(3, "F4") + bord(1) + blur(1) + c(3, "FF973F") + c(1, "FF973F") +
                                            t(0, 0.2, bord(6).t() + blur(6).t()) +
                                            t(0.6, 0.8, bord(1).t() + blur(1).t()) +
                                            p(1) + "m 0 0 l 1 0 1 1 0 1");
                        ass_out.AppendEvent(9, "pt", pt.T, pt.T + 0.8,
                                            pos(pt.X, pt.Y) + a(1, "77") + a(3, "AA") + bord(1) + blur(1) + c(3, "FF973F") + c(1, "FF973F") +
                                            t(0, 0.1, bord(1.8).t() + blur(1.8).t()) +
                                            t(0.1, 0.2, bord(2.3).t() + blur(2.3).t()) +
                                            t(0.2, 0.6, bord(1.8).t() + blur(1.8).t()) +
                                            t(0.6, 0.8, bord(1).t() + blur(1).t()) +
                                            p(1) + "m 0 0 l 1 0 1 1 0 1");
                        ass_out.AppendEvent(10, "pt", pt.T, pt.T + 0.8,
                                            pos(pt.X, pt.Y) + a(1, "77") + a(3, "AA") + bord(0.7) + blur(0.7) +
                                            t(0, 0.1, bord(1.6).t() + blur(1.6).t()) +
                                            t(0.1, 0.2, bord(2.1).t() + blur(2.1).t()) +
                                            t(0.2, 0.6, bord(1.6).t() + blur(1.6).t()) +
                                            t(0.6, 0.8, bord(0.8).t() + blur(0.8).t() + a(3, "FF").t()) +
                                            p(1) + "m 0 0 l 1 0 1 1 0 1");
                    }
                }
            }

            Console.WriteLine(ass_out.Events.Count);
            ass_out.SaveFile(this.OutFileName);
        }
コード例 #4
0
        public override void Run()
        {
            ASS ass_in  = ASS.FromFile(this.InFileName);
            ASS ass_out = new ASS()
            {
                Header = ass_in.Header, Events = new List <ASSEvent>()
            };

            ParticleIllusionExporter pie = new ParticleIllusionExporter();

            for (int iEv = 0; iEv < ass_in.Events.Count; iEv++)
            {
                bool isJp = iEv <= 13;
                int  iiEv = isJp ? iEv : iEv - 14;
                //if (iiEv !=4 && iiEv != 5) continue;
                this.MaskStyle = isJp ?
                                 "Style: Default,HGSGyoshotai,26,&H00FFFFFF,&HFFFFFFFF,&HFFFFFFFF,&HFFFFFFFF,0,0,0,0,100,100,0,0,0,0,0,5,0,0,0,128" :
                                 "Style: Default,方正行楷简体,30,&H00FFFFFF,&HFFFFFFFF,&HFFFFFFFF,&HFFFFFFFF,0,0,0,0,100,100,0,0,0,0,0,5,0,0,0,134";
                ASSEvent        ev       = ass_in.Events[iEv];
                List <KElement> kelems   = ev.SplitK(true);
                int             sw       = GetTotalWidth(ev);
                int             x0       = (isJp) ? MarginLeft : PlayResX - MarginRight - sw;
                int             y0       = (!isJp) ? (PlayResY - MarginBottom - FontHeight) : MarginTop;
                int             startx0  = x0;
                int             kSum     = 0;
                string          outlines = "";
                for (int iK = 0; iK < kelems.Count; iK++)
                {
                    Console.WriteLine("{0} / {1} : {2} / {3}", iEv + 1, ass_in.Events.Count, iK + 1, kelems.Count);
                    string   evStyle = isJp ? "jp" : "cn";
                    string   ptStyle = "pt";
                    KElement ke      = kelems[iK];
                    Size     sz      = GetSize(ke.KText);
                    double   kStart  = ev.Start + kSum * 0.01;
                    double   kEnd    = kStart + ke.KValue * 0.01;
                    kSum += ke.KValue;
                    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;
                    if (ke.KText.Trim().Length == 0)
                    {
                        continue;
                    }

                    double t0 = ev.Start - 1 + (double)(x0 - startx0 - sz.Width) / 300.0;
                    double t1 = t0 + 1;
                    double t2 = kStart;
                    //if (iEv <= 3) t2 = ke.KStart_NoSplit;
                    double t3 = kEnd;
                    double t4 = ev.End - 1 + (double)(x0 - startx0 - sz.Width) / 300.0;
                    if (t4 < t3)
                    {
                        t4 = t3;
                    }
                    double t5 = t4 + 1;

                    if (iEv == 4 && iK == 0)
                    {
                        pie.Add(t2 - 0.35, new ASSPointF(0, y));
                    }
                    if (iEv >= 4 && isJp)
                    {
                        double last = ke.KValue * 0.01;
                        pie.Add(t2, new ASSPointF(x, y));
                        if (last > 0.23 && !Common.IsLetter(ke.KText[0]))
                        {
                            pie.Add(t2 + last - 0.23, new ASSPointF(x, y));
                        }
                    }

                    if (!isJp)
                    {
                        ass_out.AppendEvent(40, evStyle, t0, t5,
                                            pos(x + 1, y + 1) + fad(0.5, 0.5) + a(1, "00") + c(1, "000000") + blur(1) +
                                            ke.KText);
                        ass_out.AppendEvent(50, evStyle, t0, t5,
                                            pos(x, y) + fad(0.5, 0.5) + a(1, "00") +
                                            ke.KText);
                        continue;
                    }

                    {
                        CompositeCurve curve = new CompositeCurve {
                            MinT = t0, MaxT = t1
                        };
                        curve.AddCurve(t0, t1, new Curve1 {
                            X0 = x, Y0 = y, R = 30
                        });
                        foreach (ASSPointF pt in curve.GetPath_DT(0.007))
                        {
                            double tmp = pt.Theta * 100;
                            ass_out.AppendEvent(70, evStyle, pt.T, pt.T + 0.4,
                                                pos(pt.X, pt.Y) + fad(0, 0.3) + a(1, "00") + be(1) +
                                                fsc((int)tmp, (int)tmp) +
                                                ke.KText);
                            ass_out.AppendEvent(60, evStyle, pt.T, pt.T + 0.4,
                                                pos(pt.X + 1, pt.Y + 1) + fad(0, 0.3) + a(1, "DD") + c(1, "000000") + be(1) +
                                                fsc((int)tmp, (int)tmp) +
                                                ke.KText);
                        }

                        {
                            ass_out.AppendEvent(40, evStyle, t1, t5,
                                                pos(x + 1, y + 1) + fad(0.3, 0.5) + a(1, "00") + c(1, "000000") + blur(1) +
                                                ke.KText);
                            ass_out.AppendEvent(50, evStyle, t1, t5,
                                                pos(x, y) + fad(0.3, 0.5) + a(1, "00") +
                                                ke.KText);
                        }

                        if (iEv <= 3 || Common.IsLetter(ke.KText[0]))
                        {
                            for (double ti = ke.KStart_NoSplit; ti <= ke.KEnd_NoSplit; ti += 0.01)
                            {
                                ass_out.AppendEvent(70, evStyle, ti, ti + 0.35,
                                                    move(x, y, Common.RandomDouble(rnd, x - 5, x + 5), Common.RandomDouble(rnd, y - 5, y + 5)) +
                                                    fad(0, 0.2) + blur(1) + a(1, "AA") +
                                                    ke.KText);
                            }
                        }
                        else
                        {
                            for (double ti = t2; ti <= t3; ti += 0.01)
                            {
                                ass_out.AppendEvent(70, evStyle, ti, ti + 0.35,
                                                    move(x, y, Common.RandomDouble(rnd, x - 5, x + 5), Common.RandomDouble(rnd, y - 5, y + 5)) +
                                                    fad(0, 0.2) + blur(1) + a(1, "AA") +
                                                    ke.KText);
                            }
                        }
                    }
                }
            }

            pie.SaveToFile(@"G:\Workshop\hanasakeru\op\pi_export.txt");

            Console.WriteLine(ass_out.Events.Count);
            ass_out.SaveFile(this.OutFileName);
        }
コード例 #5
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++)
            {
                //if (iEv != 15) continue;
                ASSEvent        ev     = ass_in.Events[iEv];
                List <KElement> kelems = ev.SplitK(false);

                this.MaskStyle   = "Style: Default,TT-曲水B,44,&H00FFFFFF,&HFFFFFFFF,&HFFFFFFFF,&HFFFFFFFF,0,0,0,0,100,100,0,0,0,0,0,5,0,0,0,128";
                this.FontName    = "TT-曲水B";
                this.FontCharset = 128;
                this.FontHeight  = 44;
                int totalWidth = GetTotalWidth(ev);
                int x0         = (PlayResX - MarginLeft - MarginRight - totalWidth) / 2 + MarginLeft;
                int x0_start   = x0;
                int y0         = PlayResY - MarginBottom - FontHeight;
                int kSum       = 0;

                CompositeCurve curve = new CompositeCurve {
                    MinT = ev.Start - 0.5, MaxT = ev.End
                };
                double curve_x0 = x0_start - FontHeight;
                double curve_y0 = y0 + 0.5 * FontHeight;
                double curve_t0 = curve.MinT;

                string[] mainColors =
                {
                    "21184E", // red
                    "4E1842", // purple
                    "4E181A", // blue
                    "184E1E", // green
                    "184E4D", // yellow
                    "393F15"  // another blue...
                };
                string mainColor = mainColors[2];
                if (iEv >= 4 && iEv <= 7)
                {
                    mainColor = mainColors[0];
                }
                if (iEv >= 8 && iEv <= 10)
                {
                    mainColor = mainColors[1];
                }
                if (iEv >= 11)
                {
                    mainColor = mainColors[5];
                }

                mainColor = "000000";

                string[] ptColors =
                {
                    "3600FF", // red
                    "FF00B0", // purple
                    "FF1C00", // blue
                    "00FFFF", // yellow
                    "00FF08", // green
                    "DCFF00"  // another blue...
                };
                string ptColor = ptColors[2];
                if (iEv > 10)
                {
                    ptColor = ptColors[5];
                }
                string ringColor = ptColors[1];
                if (iEv >= 11)
                {
                    ringColor = ptColors[5];
                }
                if (iEv >= 13)
                {
                    ringColor = "FFB100";
                }
                string torchColor = ptColors[1];
                if (iEv >= 11)
                {
                    torchColor = "FF7C00";
                }

                if (iEv == 3)
                {
                    ptColor = Common.scaleColor(ptColor, "FFFFFF", 0.7);
                }
                else
                {
                    ptColor = Common.scaleColor(ptColor, "FFFFFF", 0.5);
                }
                ringColor  = Common.scaleColor(ringColor, "FFFFFF", 0.5);
                torchColor = Common.scaleColor(torchColor, "FFFFFF", 0.5);

                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];
                    Size     sz     = GetSize(ke.KText);
                    double   kStart = ev.Start + kSum * 0.01;
                    double   kEnd   = kStart + ke.KValue * 0.01;
                    kSum += ke.KValue;
                    double     x     = x0 + this.FontSpace + sz.Width / 2;
                    double     y     = y0 + FontHeight / 2;
                    int        x_an7 = x0;
                    int        y_an7 = y0;
                    StringMask mask  = GetMask(ke.KText, (int)x, (int)y);
                    x0 += this.FontSpace + sz.Width;
                    if (ke.KText.Trim().Length == 0)
                    {
                        continue;
                    }

                    curve.AddCurve(curve_t0, kStart, new Line {
                        X0 = curve_x0, Y0 = curve_y0, X1 = x, Y1 = y
                    });
                    curve_x0 = x;
                    curve_y0 = y;
                    curve_t0 = kStart;

                    string evStyle = "op_jp";

                    ass_out.AppendEvent(49, evStyle, ev.Start - 0.3, ev.End + 0.3,
                                        pos(x + 1, y + 1) + fad(0.3, 0.3) +
                                        a(1, "77") + c(1, "000000") + blur(1) +
                                        ke.KText);
                    ass_out.AppendEvent(50, evStyle, ev.Start - 0.3, ev.End + 0.3,
                                        pos(x, y) + fad(0.3, 0.3) +
                                        a(1, "00") +
                                        ke.KText);
                    ass_out.AppendEvent(51, evStyle, ev.Start - 0.3, ev.End + 0.3,
                                        pos(x + 2, y + 2) + fad(0.3, 0.3) +
                                        a(1, "22") + c(1, mainColor) + blur(1) +
                                        ke.KText);

                    double remainStr = 0;
                    if (iEv == 3)
                    {
                        remainStr = 0.5;
                    }
                    if (iEv == 18)
                    {
                        remainStr = 0.5;
                    }

                    // light
                    double lastStr = 0.1;

                    // ring particle
                    if (iEv >= 8)
                    {
                        ass_out.AppendEvent(70, "pt", kStart, kStart + 0.4,
                                            pos(x, y) + fad(0.04, 0.25) +
                                            a(1, "77") + blur(1) +
                                            CreateCircle(50.5, 52.5));
                        ass_out.AppendEvent(70, "pt", kStart, kStart + 0.4,
                                            pos(x, y) + fad(0.04, 0.25) +
                                            a(1, "77") + blur(2) +
                                            CreateCircle(49, 54));

                        int ptCount = 150;
                        if (iEv >= 10)
                        {
                            ptCount = 250;
                        }
                        int ptRange = 12;
                        if (iEv >= 10)
                        {
                            ptRange = 20;
                        }
                        for (int iPt = 0; iPt < ptCount; iPt++)
                        {
                            double ptag = Common.RandomDouble(rnd, 0, Math.PI * 2);
                            double ptx0 = x + 51.5 * Math.Cos(ptag);
                            double pty0 = y + 51.5 * Math.Sin(ptag);
                            double ptx1 = Common.RandomDouble(rnd, ptx0 - ptRange, ptx0 + ptRange);
                            double pty1 = Common.RandomDouble(rnd, pty0 - ptRange, pty0 + ptRange);
                            double ptt  = 0.7;

                            double ptSize = 1;

                            ass_out.AppendEvent(81, "pt", kStart, kStart + ptt,
                                                move(ptx0, pty0, ptx1, pty1) + fad(0.04, 0.35) +
                                                a(1, "00") + blur(1) + fsc((int)(ptSize * 200)) +
                                                p(1) + "m 0 0 l 1 0 1 1 0 1");
                            ass_out.AppendEvent(80, "pt", kStart, kStart + ptt,
                                                move(ptx0, pty0, ptx1, pty1) + fad(0.04, 0.35) +
                                                a(1, "33") + blur(2) + fsc((int)(ptSize * 300)) + c(1, ringColor) +
                                                p(1) + "m 0 0 l 1 0 1 1 0 1");
                        }
                    }

                    // torch light
                    if (iEv >= 10)
                    {
                        ass_out.AppendEvent(70, "pt", kStart, kStart + 0.4,
                                            pos(x, y) + fad(0.04, 0.45) +
                                            a(1, "CC") + blur(1) + fsc(80) + t(fsc(160).t()) +
                                            CreateCircle(50.5, 52.5));
                        ass_out.AppendEvent(70, "pt", kStart, kStart + 0.4,
                                            pos(x, y) + fad(0.04, 0.45) +
                                            a(1, "CC") + blur(2) + fsc(80) + t(fsc(160).t()) +
                                            CreateCircle(49, 54));
                        ass_out.AppendEvent(70, "pt", kStart, kStart + 0.4,
                                            pos(x, y) + fad(0.04, 0.45) +
                                            a(1, "AA") + blur(1) + fsc(80) + t(fsc(20).t()) +
                                            CreateCircle(50.5, 52.5));
                        ass_out.AppendEvent(70, "pt", kStart, kStart + 0.4,
                                            pos(x, y) + fad(0.04, 0.45) +
                                            a(1, "AA") + blur(2) + fsc(80) + t(fsc(20).t()) +
                                            CreateCircle(49, 54));

                        if ((iEv == 10 && iK + 1 == kelems.Count) || iEv >= 15)
                        {
                            double tStep = 0.02;
                            for (double ptt0 = kStart - 0.1; ptt0 < kEnd; ptt0 += tStep)
                            {
                                int startag = Common.RandomInt(rnd, 0, 359);
                                int endag   = startag + Common.RandomSig(rnd) * Common.RandomInt(rnd, 50, 100);
                                ass_out.AppendEvent(20, "pt", ptt0, ptt0 + 1,
                                                    pos(x, y) + fad(0.3, 0.3) +
                                                    a(1, "00") + be(1) + c(1, torchColor) +
                                                    frz(startag) + t(frz(endag).t()) +
                                                    CreateLight1(rnd));
                                ass_out.AppendEvent(21, "pt", ptt0, ptt0 + 1,
                                                    pos(x, y) + fad(0.3, 0.3) +
                                                    a(1, "11") + be(1) +
                                                    frz(startag) + t(frz(endag).t()) +
                                                    CreateLight1(rnd, 60));
                            }
                        }
                    }

                    // starglow
                    foreach (ASSPoint point in mask.Points)
                    {
                        if (!Common.RandomBool(rnd, 0.4))
                        {
                            continue;
                        }
                        double xr = (double)(point.X - mask.X0) / mask.Width;
                        double yr = (double)(point.Y - mask.Y0) / mask.Height;
                        Func <double, double> f1 = _x => Math.Pow(Math.Abs(_x) * 2.0, 1.5);

                        ass_out.AppendEvent(70, "pt", kStart, kEnd + lastStr,
                                            an(7) + pos(point.X, point.Y) + fad(0.05, kEnd + 0.2 - kStart - 0.05 - 0.08) +
                                            a(1, Common.scaleAlpha("FF", "AA", f1(xr))) + be(1) +
                                            fscx(100 + f1(xr) * 60) +
                                            p(1) + "m 0 0 l 40 0 0 1 -40 0 0 0");
                        ass_out.AppendEvent(70, "pt", kStart, kEnd + lastStr,
                                            an(7) + pos(point.X, point.Y) + fad(0.05, kEnd + 0.2 - kStart - 0.05 - 0.08) +
                                            a(1, Common.scaleAlpha("FF", "AA", f1(yr))) + be(1) +
                                            fscx(100 + f1(yr) * 60) + frz(90) +
                                            p(1) + "m 0 0 l 40 0 0 1 -40 0 0 0");

                        if (remainStr > 0)
                        {
                            // remain "starglow"
                            ass_out.AppendEvent(70, "pt", (kEnd + lastStr - kStart) * 0.5 + kStart, ev.End + 0.3,
                                                an(7) + pos(point.X, point.Y) + fad((kEnd + lastStr - kStart) * 0.5, 0.3) +
                                                a(1, Common.scaleAlpha("FF", "AA", remainStr * f1(xr))) + be(1) +
                                                fscx(100 + f1(xr) * 60) +
                                                p(1) + "m 0 0 l 40 0 0 1 -40 0 0 0");
                            ass_out.AppendEvent(70, "pt", (kEnd + lastStr - kStart) * 0.5 + kStart, ev.End + 0.3,
                                                an(7) + pos(point.X, point.Y) + fad((kEnd + lastStr - kStart) * 0.5, 0.3) +
                                                a(1, Common.scaleAlpha("FF", "AA", remainStr * f1(yr))) + be(1) +
                                                fscx(100 + f1(yr) * 60) + frz(90) +
                                                p(1) + "m 0 0 l 40 0 0 1 -40 0 0 0");

                            // disappear with particles
                            if (Common.RandomBool(rnd, 1))
                            {
                                double ptt0 = ev.End + iK * 0.02;
                                double ptt1 = ptt0 + Common.RandomDouble_Gauss(rnd, 1.2, 2.4, 2);

                                string sFrz   = frz(Common.RandomInt(rnd, 0, 359));
                                string sMove  = move(point.X, point.Y, point.X + Common.RandomInt(rnd, 100, 200), point.Y);
                                string sMoveT = t(0, ptt1 - ptt0, 0.5, fscx((Math.Abs(Common.RandomDouble_Gauss(rnd, -1, 1, 3)) * 180 + 20) * 100).t());
                                string tS1    = t(0, Common.RandomDouble(rnd, 1, 2) * (ptt1 - ptt0), a(1, "FFFF").t());
                                point.Y += Common.RandomInt(rnd, -5, 5);
                                ass_out.AppendEvent(80, "pt", ptt0, ptt1,
                                                    org(point.X, point.Y) + pos(point.X, point.Y) + sMoveT + sFrz +
                                                    p(1) + "m 0 0 l 1 0 1 1 0 1" + r() + sFrz + fad(0, 0.4) +
                                                    t(0, 0.3, fscx(700).t()) + t(0.3, 1, 2, fscx(150).t()) +
                                                    blur(1) + a(1, "00") + tS1 +
                                                    p(1) + "m 0 0 l 1 0 1 1 0 1");
                                ass_out.AppendEvent(20, "pt", ptt0, ptt1,
                                                    org(point.X, point.Y) + pos(point.X, point.Y) + sMoveT + sFrz +
                                                    p(1) + "m 0 0 l 1 0 1 1 0 1" + r() + sFrz + fad(0, 0.4) +
                                                    t(0, 0.3, fscx(1000).t()) + t(0.3, 1, 2, fscx(250).t()) +
                                                    fscy(150) + c(1, ptColor) +
                                                    blur(2) + a(1, "00") + tS1 +
                                                    p(1) + "m 0 0 l 1 0 1 1 0 1");
                            }
                        }
                    }

                    ass_out.AppendEvent(60, evStyle, kStart, kEnd + lastStr,
                                        pos(x + 1, y + 1) + fad(0.05, kEnd + lastStr - kStart - 0.05 - 0.08) +
                                        a(1, "00") +
                                        a(3, "22") + bord(2.5) + blur(2.5) +
                                        ke.KText);
                    ass_out.AppendEvent(60, evStyle, kStart, kEnd + lastStr,
                                        pos(x + 1, y + 1) + fad(0.05, kEnd + lastStr - kStart - 0.05 - 0.08) +
                                        a(1, "00") +
                                        a(3, "22") + bord(5) + blur(5) +
                                        ke.KText);

                    if (remainStr > 0)
                    {
                        ass_out.AppendEvent(60, evStyle, (kEnd + lastStr - kStart) * 0.5 + kStart + iK * 0.02, ev.End + 0.3 + iK * 0.02,
                                            pos(x + 1, y + 1) + fad((kEnd + lastStr - kStart) * 0.5, 0.3) +
                                            a(1, Common.scaleAlpha("FF", "00", remainStr)) +
                                            a(3, Common.scaleAlpha("FF", "22", remainStr)) + bord(2.5) + blur(2.5) +
                                            ke.KText);
                        ass_out.AppendEvent(60, evStyle, kStart + iK * 0.02, kEnd + lastStr + iK * 0.02,
                                            pos(x + 1, y + 1) + fad(0.05, kEnd + lastStr - kStart - 0.05 - 0.08) +
                                            a(1, Common.scaleAlpha("FF", "00", remainStr)) +
                                            a(3, Common.scaleAlpha("FF", "22", remainStr)) + bord(5) + blur(5) +
                                            ke.KText);

                        ass_out.AppendEvent(60, evStyle, ev.End - 0.1 + iK * 0.02, ev.End + 0.3 + iK * 0.02,
                                            pos(x + 1, y + 1) + fad(0.05, 0.2) +
                                            a(1, "00") +
                                            a(3, "22") + bord(2.5) + blur(2.5) +
                                            ke.KText);
                        ass_out.AppendEvent(60, evStyle, ev.End - 0.1 + iK * 0.02, ev.End + 0.3 + iK * 0.02,
                                            pos(x + 1, y + 1) + fad(0.05, 0.2) +
                                            a(1, "00") +
                                            a(3, "22") + bord(5) + blur(5) +
                                            ke.KText);
                    }
                }

                if (iEv > 10)
                {
                    curve.AddCurve(curve_t0, curve.MaxT, new Line {
                        X0 = curve_x0, Y0 = curve_y0, X1 = curve_x0, Y1 = curve_y0
                    });
                    foreach (ASSPointF point in curve.GetPath_DT(0.002))
                    {
                        double ptt0 = point.T;
                        double ptt1 = ptt0 + Common.RandomDouble_Gauss(rnd, 1.2, 1.8, 2);

                        string sFrz   = frz(Common.RandomInt(rnd, 0, 359));
                        string sMove  = move(point.X, point.Y, point.X + Common.RandomInt(rnd, 100, 200), point.Y);
                        string sMoveT = t(0, ptt1 - ptt0, 0.5, fscx((Math.Abs(Common.RandomDouble_Gauss(rnd, -1, 1, 3)) * 180 + 20) * 100).t());
                        string tS1    = t(0, Common.RandomDouble(rnd, 1, 2) * (ptt1 - ptt0), a(1, "FFFF").t());

                        ass_out.AppendEvent(80, "pt", ptt0, ptt1,
                                            org(point.X, point.Y) + pos(point.X, point.Y) + sMoveT + sFrz +
                                            p(1) + "m 0 0 l 1 0 1 1 0 1" + r() + sFrz + fad(0, 0.4) +
                                            t(0, 0.3, fscx(700).t()) + t(0.3, 1, 2, fscx(150).t()) +
                                            blur(1) + a(1, "00") + tS1 +
                                            p(1) + "m 0 0 l 1 0 1 1 0 1");
                        ass_out.AppendEvent(20, "pt", ptt0, ptt1,
                                            org(point.X, point.Y) + pos(point.X, point.Y) + sMoveT + sFrz +
                                            p(1) + "m 0 0 l 1 0 1 1 0 1" + r() + sFrz + fad(0, 0.4) +
                                            t(0, 0.3, fscx(1000).t()) + t(0.3, 1, 2, fscx(250).t()) +
                                            fscy(150) + c(1, ptColor) +
                                            blur(2) + a(1, "00") + tS1 +
                                            p(1) + "m 0 0 l 1 0 1 1 0 1");
                    }
                }
            }

            ass_out.SaveFile(OutFileName);
            Console.WriteLine("Lines : {0}", ass_out.Events.Count);
        }
コード例 #6
0
        public override void Run()
        {
            ASS ass_in  = ASS.FromFile(this.InFileName);
            ASS ass_out = new ASS()
            {
                Header = ass_in.Header, Events = new List <ASSEvent>()
            };

            string cPink = "8283FE";

            for (int iEv = 0; iEv < ass_in.Events.Count; iEv++)
            {
                bool isJp = iEv <= 12;
                //if (isJp) continue;
                //if (iEv != 13) continue;
                //if (!(iEv >= 0 && 7 >= iEv)) continue;
                ASSEvent        ev     = ass_in.Events[iEv];
                List <KElement> kelems = ev.SplitK(!isJp);
                if (!isJp)
                {
                    foreach (KElement ke in kelems)
                    {
                        ke.KValue = 10;
                    }
                }
                int    x0       = MarginLeft;
                int    y0       = (isJp) ? (PlayResY - MarginBottom - FontHeight) : MarginTop;
                int    kSum     = 0;
                string outlines = "";
                double ev0_sp   = 500;
                for (int iK = 0; iK < kelems.Count; iK++)
                {
                    Console.WriteLine("{0} / {1} : {2} / {3}", iEv + 1, ass_in.Events.Count, iK + 1, kelems.Count);
                    this.MaskStyle = isJp ?
                                     "Style: Default,DFGMaruGothic-Md,28,&H00FFFFFF,&HFFFFFFFF,&HFFFFFFFF,&HFFFFFFFF,0,0,0,0,100,100,0,0,0,0,0,5,0,0,0,128" :
                                     "Style: Default,方正准圆_GBK,28,&H00FFFFFF,&HFFFFFFFF,&HFFFFFFFF,&HFFFFFFFF,0,0,0,0,100,100,0,0,0,0,0,5,0,0,0,134";
                    string   evStyle         = isJp ? "jp" : "cn";
                    string   outlineFontname = isJp ? "DFGMaruGothic-Md" : "方正准圆_GBK";
                    int      outlineEncoding = isJp ? 128 : 134;
                    KElement ke     = kelems[iK];
                    Size     sz     = GetSize(ke.KText);
                    double   kStart = ev.Start + kSum * 0.01;
                    double   kEnd   = kStart + ke.KValue * 0.01;
                    kSum += ke.KValue;
                    int        x     = x0 + this.FontSpace + sz.Width / 2;
                    int        y     = y0 + FontHeight / 2;
                    int        x_an7 = x0;
                    int        y_an7 = y0;
                    StringMask mask  = GetMask(ke.KText, x, y);
                    x0 += this.FontSpace + sz.Width;
                    if (ke.KText.Trim().Length == 0)
                    {
                        continue;
                    }
                    string outlineString = GetOutline(x - sz.Width / 2, y - FontHeight / 2, ke.KText[0], outlineFontname, outlineEncoding, FontHeight, 0, 191);
                    if (!isJp)
                    {
                        outlineString = GetOutline(x - sz.Width / 2, y - FontHeight / 2, ke.KText[0], outlineFontname, outlineEncoding, FontHeight, 0, 177);
                    }
                    outlines += outlineString;

                    if (iEv == 0)
                    {
                        double t0 = kStart - 1;
                        double t1 = kStart - 0.1;
                        double t2 = kStart + 0.4;
                        double t3 = ev.End - 0.5 + iK * 0.07;
                        double t4 = t3 + 0.5;

                        string cMain  = "000071";
                        string cMain2 = "1DA4DD";// "10B7FC";

                        ass_out.AppendEvent(30, evStyle, t0, t3,
                                            pos(x + 2, y + 2) + a(1, "00") + c(1, "000000") + blur(1.2) + fad(0.8, 0) +
                                            ke.KText);
                        ass_out.AppendEvent(30, evStyle, t3, t4,
                                            pos(x + 2, y + 2) + a(1, "00") + c(1, "000000") + blur(1.2) + fad(0, t4 - t3) +
                                            ke.KText);
                        ass_out.AppendEvent(40, "pt", t1, 7 + x / ev0_sp + 0.3,
                                            clip(4, outlineString) + pos(x, y) + a(1, "33") + c(1, "222222") + fad(t2 - t1, 0.3) +
                                            p(1) + "m -20 -20 l 20 -20 20 20 -20 20");
                        ass_out.AppendEvent(40, "pt", 7 + x / ev0_sp - 0.3, t3,
                                            clip(4, outlineString) + pos(x, y) + a(1, "33") + c(1, cMain) + fad(0.3, 0) +
                                            p(1) + "m -20 -20 l 20 -20 20 20 -20 20");
                        ass_out.AppendEvent(40, "pt", t3, t4,
                                            clip(4, outlineString) + pos(x, y) + a(1, "33") + c(1, cMain) + fad(0, t4 - t3) +
                                            p(1) + "m -20 -20 l 20 -20 20 20 -20 20");
                        for (int i = 0; i < 4; i++)
                        {
                            int lumsz = 5 - i;
                            ass_out.AppendEvent(40, "pt", 7 + x / ev0_sp - 0.3, t4,
                                                pos(0, 0) + a(1, "FF") + a(3, "DD") + blur(lumsz) + bord(lumsz) + c(3, "1D4FDD") + fad(0.3, 0.5) +
                                                p(4) + outlineString);
                        }
                        double lumX = Common.RandomInt(rnd, x - 12, x + 12);
                        double lumY = Common.RandomInt(rnd, y - 12, y + 12);
                        for (int i = 0; i < 3; i++)
                        {
                            int lumsz  = 8 + i * 2;
                            int lumsz2 = lumsz - 1;
                            ass_out.AppendEvent(50, "pt", t1, t2,
                                                clip(4, outlineString) + pos(lumX, lumY) +
                                                a(1, "44") + a(3, "00") + c(1, cMain) + c(3, cMain) + t(bord(lumsz).t() + blur(lumsz).t()) +
                                                p(1) + "m 0 0 l 1 0 1 1 0 1");
                            ass_out.AppendEvent(50, "pt", t2, 7 + x / ev0_sp + 0.3, // Speed : 200
                                                clip(4, outlineString) + pos(lumX, lumY) + fad(0, 0.3) +
                                                a(1, "44") + a(3, "00") + c(1, cMain) + c(3, cMain) + bord(lumsz) + blur(lumsz) +
                                                p(1) + "m 0 0 l 1 0 1 1 0 1");
                            ass_out.AppendEvent(50, "pt", 7 + x / ev0_sp - 0.3, t3,// Speed : 200
                                                clip(4, outlineString) + pos(lumX, lumY) + fad(0.3, 0) +
                                                a(1, "44") + a(3, "00") + c(1, cMain2) + c(3, cMain2) + bord(lumsz2) + blur(lumsz2) +
                                                p(1) + "m 0 0 l 1 0 1 1 0 1");
                            ass_out.AppendEvent(50, "pt", t3, t4,
                                                clip(4, outlineString) + pos(lumX, lumY) +
                                                a(1, "44") + a(3, "00") + c(1, cMain2) + c(3, cMain2) + bord(lumsz2) + blur(lumsz2) +
                                                t(bord(0).t() + blur(0).t()) +
                                                p(1) + "m 0 0 l 1 0 1 1 0 1");
                        }
                        for (int i = 0; i < 4; i++)
                        {
                            double ptt0 = Common.RandomDouble(rnd, 7, 9);
                            double ptt1 = ptt0 + 0.5;
                            double ptx0 = Common.RandomDouble(rnd, x - 15, x + 15);
                            double pty0 = Common.RandomDouble(rnd, y - 15, y + 15) + 40;
                            double ptx1 = Common.RandomDouble(rnd, ptx0 + 10, ptx0 + 15);
                            double pty1 = Common.RandomDouble(rnd, pty0 - 80, pty0 - 100);
                            for (int j = 0; j < 3; j++)
                            {
                                double lumsz = 4 - j * 1;
                                ass_out.AppendEvent(90, "pt", ptt0, ptt1,
                                                    move(ptx0, pty0, ptx1, pty1) + a(1, "44") + a(3, "00") +
                                                    bord(lumsz) + blur(lumsz) + fad(0, ptt1 - ptt0) +
                                                    p(1) + "m 0 0 l 1 0 1 1 0 1");
                            }
                            ass_out.AppendEvent(89, "pt", ptt0, ptt1,
                                                move(ptx0, pty0, ptx1, pty1) + a(1, "44") + a(3, "77") +
                                                bord(8) + blur(8) + fad(0, ptt1 - ptt0) +
                                                p(1) + "m 0 0 l 1 0 1 1 0 1");
                        }
                    }
                    else if (iEv == 1)
                    {
                        double t0 = ev.Start - 0.5 + iK * 0.07;
                        double t1 = kStart - 0.1;
                        double t2 = kStart + 0.4;
                        double t3 = ev.End - 0.5 + iK * 0.07;
                        double t4 = t3 + 0.5;

                        string cMain = "FFFFFF";
                        if (iEv != 1)
                        {
                            cMain = cPink;
                        }
                        string cShad = "222222";
                        if (iEv != 1)
                        {
                            cShad = "FFFFFF";
                        }

                        ass_out.AppendEvent(30, evStyle, t0, t3,
                                            pos(x + 2, y + 2) + a(1, "00") + c(1, "000000") + blur(1.2) + fad(0.8, 0) +
                                            ke.KText);
                        ass_out.AppendEvent(30, evStyle, t3, t4,
                                            pos(x + 2, y + 2) + a(1, "00") + c(1, "000000") + blur(1.2) + fad(0, t4 - t3) +
                                            ke.KText);
                        ass_out.AppendEvent(40, "pt", t1, t3,
                                            clip(4, outlineString) + pos(x, y) + a(1, "33") + c(1, cShad) + fad(t2 - t1, 0) +
                                            p(1) + "m -20 -20 l 20 -20 20 20 -20 20");
                        ass_out.AppendEvent(40, "pt", t3, t4,
                                            clip(4, outlineString) + pos(x, y) + a(1, "33") + c(1, cShad) + fad(0, t4 - t3) +
                                            p(1) + "m -20 -20 l 20 -20 20 20 -20 20");
                        for (int i = 0; i < 4; i++)
                        {
                            int lumsz = 5 - i;
                            ass_out.AppendEvent(30, "pt", t1, t4,
                                                pos(0, 0) + a(1, "FF") + a(3, "DD") + blur(lumsz) + bord(lumsz) + c(3, "FFFFFF") + fad(0.3, 0.5) +
                                                p(4) + outlineString);
                        }
                        double lumX = Common.RandomInt(rnd, x - 12, x + 12);
                        double lumY = Common.RandomInt(rnd, y - 12, y + 12);
                        for (int i = 0; i < 3; i++)
                        {
                            int lumsz = 8 + i * 2;
                            ass_out.AppendEvent(50, "pt", t1, t2,
                                                clip(4, outlineString) + pos(lumX, lumY) +
                                                a(1, "44") + a(3, "00") + c(1, cMain) + c(3, cMain) + t(bord(lumsz).t() + blur(lumsz).t()) +
                                                p(1) + "m 0 0 l 1 0 1 1 0 1");
                            ass_out.AppendEvent(50, "pt", t2, t3,
                                                clip(4, outlineString) + pos(lumX, lumY) +
                                                a(1, "44") + a(3, "00") + c(1, cMain) + c(3, cMain) + bord(lumsz) + blur(lumsz) +
                                                p(1) + "m 0 0 l 1 0 1 1 0 1");
                            ass_out.AppendEvent(50, "pt", t3, t4,
                                                clip(4, outlineString) + pos(lumX, lumY) +
                                                a(1, "44") + a(3, "00") + c(1, cMain) + c(3, cMain) + bord(lumsz) + blur(lumsz) +
                                                t(bord(0).t() + blur(0).t()) +
                                                p(1) + "m 0 0 l 1 0 1 1 0 1");
                        }
                        for (int i = 0; i < 30 * (t3 - t1); i++)
                        {
                            double   ptt0       = Common.RandomDouble(rnd, t1, t3);
                            double   ptt1       = ptt0 + 0.5;
                            int      pxid       = Common.RandomInt(rnd, 0, mask.Points.Count - 1);
                            ASSPoint ogpt       = mask.Points[pxid];
                            double   ptx0       = ogpt.X;
                            double   pty0       = ogpt.Y;
                            double   ptx1       = Common.RandomDouble(rnd, ptx0 - 50, ptx0 + 50);
                            double   pty1       = Common.RandomDouble(rnd, pty0 - 50, pty0 + 50);
                            string   obj        = CreatePolygon(rnd, 10, 15, 5);
                            string   moveString = Common.RandomBool(rnd, 0.75) ? move(ptx0, pty0, ptx1, pty1) : move(ptx1, pty1, ptx0, pty0);
                            ass_out.AppendEvent(20, "pt", ptt0, ptt1,
                                                moveString + a(1, "00") + a(3, "55") + c(1, "A266FD") + c(3, "A266FD") +
                                                bord(2) + blur(2) + fad(0, ptt1 - ptt0) +
                                                obj);
                            ass_out.AppendEvent(20, "pt", ptt0, ptt1,
                                                moveString + a(1, "00") + a(3, "00") + c(1, "A266FD") + c(3, "A266FD") +
                                                bord(1.2) + blur(1.2) + fad(0, ptt1 - ptt0) +
                                                obj);
                            ass_out.AppendEvent(20, "pt", ptt0, ptt1,
                                                moveString + a(1, "00") + a(3, "00") +
                                                bord(0.8) + blur(0.8) + fad(0, ptt1 - ptt0) +
                                                obj);
                        }
                    }
                    else if (isJp)
                    {
                        double t0 = ev.Start - 0.5 + iK * 0.07;
                        double t1 = kStart - 0.1;
                        double t2 = kStart + 0.4;
                        double t3 = ev.End - 0.5 + iK * 0.07;
                        double t4 = t3 + 0.5;

                        string cMain = "3C3DFF";
                        if (iEv == 2)
                        {
                            cMain = "FF8D3C";
                        }
                        if (iEv == 3)
                        {
                            cMain = "FC7D7F";
                        }
                        if (iEv == 4)
                        {
                            cMain = "FFC6D2";
                        }
                        if (iEv == 5)
                        {
                            cMain = "5758FF";
                        }
                        if (iEv == 6)
                        {
                            cMain = "5758FF";
                        }
                        if (iEv == 7)
                        {
                            cMain = "FF55C6";
                        }
                        if (iEv >= 8)
                        {
                            cMain = "FF8D3C";
                        }
                        string cShad = "EEEEEE";

                        ass_out.AppendEvent(30, evStyle, t0, t3,
                                            pos(x + 2, y + 2) + a(1, "00") + c(1, "000000") + blur(1.2) + fad(0.8, 0) +
                                            ke.KText);
                        ass_out.AppendEvent(30, evStyle, t3, t4,
                                            pos(x + 2, y + 2) + a(1, "00") + c(1, "000000") + blur(1.2) + fad(0, t4 - t3) +
                                            ke.KText);
                        ass_out.AppendEvent(40, "pt", t1, t3,
                                            clip(4, outlineString) + pos(x, y) + a(1, "33") + c(1, cShad) + fad(t2 - t1, 0) +
                                            p(1) + "m -20 -20 l 20 -20 20 20 -20 20");
                        ass_out.AppendEvent(40, "pt", t3, t4,
                                            clip(4, outlineString) + pos(x, y) + a(1, "33") + c(1, cShad) + fad(0, t4 - t3) +
                                            p(1) + "m -20 -20 l 20 -20 20 20 -20 20");
                        for (int i = 0; i < 4; i++)
                        {
                            int lumsz = 5 - i;
                            ass_out.AppendEvent(30, "pt", t1, t4,
                                                pos(0, 0) + a(1, "FF") + a(3, "DD") + blur(lumsz) + bord(lumsz) + c(3, cMain) + fad(0.3, 0.5) +
                                                p(4) + outlineString);
                        }
                        double lumX = Common.RandomInt(rnd, x - 12, x + 12);
                        double lumY = Common.RandomInt(rnd, y - 12, y + 12);
                        for (int i = 0; i < 3; i++)
                        {
                            int lumsz = 8 + i * 2;
                            ass_out.AppendEvent(50, "pt", t1, t2,
                                                clip(4, outlineString) + pos(lumX, lumY) +
                                                a(1, "44") + a(3, "00") + c(1, cMain) + c(3, cMain) + t(bord(lumsz).t() + blur(lumsz).t()) +
                                                p(1) + "m 0 0 l 1 0 1 1 0 1");
                            ass_out.AppendEvent(50, "pt", t2, t3,
                                                clip(4, outlineString) + pos(lumX, lumY) +
                                                a(1, "44") + a(3, "00") + c(1, cMain) + c(3, cMain) + bord(lumsz) + blur(lumsz) +
                                                p(1) + "m 0 0 l 1 0 1 1 0 1");
                            ass_out.AppendEvent(50, "pt", t3, t4,
                                                clip(4, outlineString) + pos(lumX, lumY) +
                                                a(1, "44") + a(3, "00") + c(1, cMain) + c(3, cMain) + bord(lumsz) + blur(lumsz) +
                                                t(bord(0).t() + blur(0).t()) +
                                                p(1) + "m 0 0 l 1 0 1 1 0 1");
                        }

                        if (iEv == 2)
                        {
                            for (double ti = t1; ti <= kEnd + 0.3; ti += 0.01)
                            {
                                double ag    = ti * Math.PI * 1.5;
                                int    iag   = (int)((ag / 2.0 / Math.PI) * 360) % 360;
                                string alpha = "00";
                                if (kEnd - ti < 0.3)
                                {
                                    alpha = Common.scaleAlpha("FF", "00", (kEnd - ti) / 0.3);
                                }
                                if (ti - t1 < 0.3)
                                {
                                    alpha = Common.scaleAlpha("FF", "00", (ti - t1) / 0.3);
                                }
                                ass_out.AppendEvent(10, "pt", ti, ti + 0.5,
                                                    pos(x, y) + a(1, alpha) + be(1) + frz(-iag) + fad(0, 0.3) +
                                                    p(1) + "m 1 0 l 0 30 -1 0 0 -30");
                            }
                        }
                        if (iEv == 3)
                        {
                            for (int i = 0; i < 15 * (t3 - t1); i++)
                            {
                                int      pxid = Common.RandomInt(rnd, 0, mask.Points.Count - 1);
                                ASSPoint ogpt = mask.Points[pxid];
                                int      ptx0 = ogpt.X;
                                int      pty0 = y;
                                double   ptt0 = Common.RandomDouble(rnd, t1, t3);
                                double   ptt1 = ptt0 + 0.1;
                                ass_out.AppendEvent(110, "pt", ptt0, ptt1,
                                                    clip(4, outlineString) + pos(ptx0, pty0) + a(1, "77") + blur(1.8) + fad(0, 0) + c(1, "000000") + frz(-30) +
                                                    p(1) + "m 2 0 l 0 20 -2 0 0 -20");
                            }
                        }
                        if (iEv == 4)
                        {
                            for (int i = 0; i < 25 * (t3 - t1); i++)
                            {
                                double   ptt0       = Common.RandomDouble(rnd, t1, t1 + 0.3);
                                double   ptt1       = ptt0 + Common.RandomDouble(rnd, 0, t3 - t1 - 0.3) + 1;
                                int      pxid       = Common.RandomInt(rnd, 0, mask.Points.Count - 1);
                                ASSPoint ogpt       = mask.Points[pxid];
                                double   ptx0       = ogpt.X;
                                double   pty0       = ogpt.Y;
                                double   ptx1       = Common.RandomDouble(rnd, ptx0 - 50, ptx0 - 150);
                                double   pty1       = Common.RandomDouble(rnd, pty0 + 10, pty0 + 50);
                                string   obj        = CreatePolygon(rnd, 7, 10, 5);
                                string   moveString = move(ptx0, pty0, ptx1, pty1, ptt1 - ptt0 - 1, ptt1 - ptt0);

                                /*ass_out.AppendEvent(110, "pt", ptt0, ptt1,
                                 *  moveString + a(1, "00") + a(3, "55") + c(1, "FFF3F3") + c(3, "FFF3F3") +
                                 *  bord(2) + blur(2) + fad(0, ptt1 - ptt0) +
                                 *  obj);*/
                                ass_out.AppendEvent(110, "pt", ptt0, ptt1,
                                                    moveString + a(1, "00") + a(3, "00") + c(1, "FFF3F3") + c(3, "FFF3F3") +
                                                    bord(1.2) + blur(1.2) + fad(0, ptt1 - ptt0) +
                                                    obj);
                                ass_out.AppendEvent(110, "pt", ptt0, ptt1,
                                                    moveString + a(1, "00") + a(3, "00") +
                                                    bord(0.8) + blur(0.8) + fad(0, ptt1 - ptt0) +
                                                    obj);
                            }
                        }
                        if (iEv == 5 || iEv == 6 || iEv == 7)
                        {
                            ass_out.AppendEvent(109, "jp", kStart, kStart + 0.15,
                                                pos(x, y) + a(1, "00") + a(3, "44") + bord(4) + blur(4) + fad(0, 0.12) +
                                                ke.KText);
                            ass_out.AppendEvent(109, "jp", kStart, kStart + 0.15,
                                                pos(x, y) + a(1, "00") + a(3, "44") + bord(6) + blur(6) + fad(0, 0.12) +
                                                ke.KText);
                            for (int i = 0; i < 2; i++)
                            {
                                CompositeCurve curve = new CompositeCurve {
                                    MinT = kStart - 0.5 * 0.25, MaxT = kStart + 0.5 * 0.25
                                };
                                Line line = new Line {
                                    X0 = x + 50 - 5 - 5, X1 = x - 50 - 5 - 5, Y0 = y - 30 - 5 - 5, Y1 = y + 30 - 5 - 5
                                };
                                if (i == 1)
                                {
                                    line = new Line {
                                        Y1 = y - 30 + i * 15 - 5, Y0 = y + 30 + i * 15 - 5, X1 = x + 50 + i * 15 - 5, X0 = x - 50 + i * 15 - 5
                                    }
                                }
                                ;
                                curve.AddCurve(curve.MinT, curve.MaxT, line);
                                List <ASSPointF> pts = curve.GetPath_Dis(1, 1.1);
                                foreach (ASSPointF pt in pts)
                                {
                                    if (!Common.InRange(0, PlayResX, pt.X) || !Common.InRange(0, PlayResY, pt.Y))
                                    {
                                        continue;
                                    }
                                    ass_out.AppendEvent(0, "pt", pt.T, pt.T + 0.25,
                                                        pos(pt.X, pt.Y) + a(1, "00") + a(3, "77") + c(1, cMain) + c(3, cMain) + fad(0, 0.1) +
                                                        bord(1.5) + blur(1.5) +
                                                        p(1) + "m 0 0 l 1 0 1 1 0 1");
                                    ass_out.AppendEvent(0, "pt", pt.T, pt.T + 0.25,
                                                        pos(pt.X, pt.Y) + a(1, "00") + a(3, "BB") + c(1, cMain) + c(3, cMain) + fad(0, 0.1) +
                                                        bord(4) + blur(4) +
                                                        p(1) + "m 0 0 l 1 0 1 1 0 1");
                                    ass_out.AppendEvent(2, "pt", pt.T, pt.T + 0.25,
                                                        pos(pt.X, pt.Y) + a(1, "00") + a(3, "44") + c(1, "FFFFFF") + c(3, "FFFFFF") + fad(0, 0.1) +
                                                        bord(1) + blur(1) +
                                                        p(1) + "m 0 0 l 1 0 1 1 0 1");
                                }
                                pts = curve.GetPath_DT(0.01);
                                foreach (ASSPointF pt in pts)
                                {
                                    if (!Common.InRange(0, PlayResX, pt.X) || !Common.InRange(0, PlayResY, pt.Y))
                                    {
                                        continue;
                                    }
                                    ass_out.AppendEvent(115, "pt", pt.T, pt.T + 0.01,
                                                        pos(pt.X, pt.Y) + a(1, "00") + a(3, "00") + c(1, "FFFFFF") + c(3, "FFFFFF") +
                                                        bord(8) + blur(8) +
                                                        p(1) + "m 0 0 l 1 0 1 1 0 1");
                                    ass_out.AppendEvent(114, "pt", pt.T, pt.T + 0.01,
                                                        pos(pt.X, pt.Y) + a(1, "00") + a(3, "00") + c(1, "FFFFFF") + c(3, "FFFFFF") +
                                                        bord(6) + blur(6) +
                                                        p(1) + "m 0 0 l 1 0 1 1 0 1");
                                }
                            }
                        }
                        if (iEv >= 8 && iEv <= 12)
                        {
                            ass_out.AppendEvent(109, "jp", kStart, kStart + 0.35,
                                                pos(x, y) + a(1, "00") + a(3, "44") + bord(4) + blur(4) + fad(0, 0.25) +
                                                ke.KText);
                            ass_out.AppendEvent(109, "jp", kStart, kStart + 0.35,
                                                pos(x, y) + a(1, "00") + a(3, "44") + bord(6) + blur(6) + fad(0, 0.25) +
                                                ke.KText);
                            string pCol = "A266FD";
                            if (iEv >= 11)
                            {
                                pCol = Common.scaleColor("FFFFFF", pCol, 0.5);
                            }
                            for (int i = 0; i < (30 + (iEv - 7) * 10) * (t3 - t1); i++)
                            {
                                double   ptt0       = Common.RandomDouble(rnd, t1, t3);
                                double   ptt1       = ptt0 + 0.5;
                                int      pxid       = Common.RandomInt(rnd, 0, mask.Points.Count - 1);
                                ASSPoint ogpt       = mask.Points[pxid];
                                double   ptx0       = ogpt.X;
                                double   pty0       = ogpt.Y;
                                double   ptx1       = Common.RandomDouble(rnd, ptx0 - 50, ptx0 + 50);
                                double   pty1       = Common.RandomDouble(rnd, pty0 - 50, pty0 + 50);
                                string   obj        = CreatePolygon(rnd, 10, 15, 5);
                                string   moveString = Common.RandomBool(rnd, 0.75) ? move(ptx0, pty0, ptx1, pty1) : move(ptx1, pty1, ptx0, pty0);
                                ass_out.AppendEvent(20, "pt", ptt0, ptt1,
                                                    moveString + a(1, "00") + a(3, "55") + c(1, pCol) + c(3, pCol) +
                                                    bord(2) + blur(2) + fad(0, ptt1 - ptt0) +
                                                    obj);
                                ass_out.AppendEvent(20, "pt", ptt0, ptt1,
                                                    moveString + a(1, "00") + a(3, "00") + c(1, pCol) + c(3, pCol) +
                                                    bord(1.2) + blur(1.2) + fad(0, ptt1 - ptt0) +
                                                    obj);
                                ass_out.AppendEvent(20, "pt", ptt0, ptt1,
                                                    moveString + a(1, "00") + a(3, "00") +
                                                    bord(0.8) + blur(0.8) + fad(0, ptt1 - ptt0) +
                                                    obj);
                            }
                        }
                    }
                    if (!isJp)
                    {
                        if (iEv == 13)
                        {
                            double t0 = kStart - 1;
                            double t1 = kStart - 0.1;
                            double t2 = kStart + 0.4;
                            double t3 = ev.End - 0.5 + iK * 0.07;
                            double t4 = t3 + 0.5;

                            string cMain  = "000071";
                            string cMain2 = "1DA4DD";// "10B7FC";

                            ass_out.AppendEvent(30, evStyle, t0, t3,
                                                pos(x + 2, y + 2) + a(1, "00") + c(1, "000000") + blur(1.2) + fad(0.8, 0) +
                                                ke.KText);
                            ass_out.AppendEvent(30, evStyle, t3, t4,
                                                pos(x + 2, y + 2) + a(1, "00") + c(1, "000000") + blur(1.2) + fad(0, t4 - t3) +
                                                ke.KText);
                            ass_out.AppendEvent(40, "pt", t1, 7 + x / ev0_sp + 0.3,
                                                clip(4, outlineString) + pos(x, y) + a(1, "33") + c(1, "222222") + fad(t2 - t1, 0.3) +
                                                p(1) + "m -20 -20 l 20 -20 20 20 -20 20");
                            ass_out.AppendEvent(40, "pt", 7 + x / ev0_sp - 0.3, t3,
                                                clip(4, outlineString) + pos(x, y) + a(1, "33") + c(1, cMain) + fad(0.3, 0) +
                                                p(1) + "m -20 -20 l 20 -20 20 20 -20 20");
                            ass_out.AppendEvent(40, "pt", t3, t4,
                                                clip(4, outlineString) + pos(x, y) + a(1, "33") + c(1, cMain) + fad(0, t4 - t3) +
                                                p(1) + "m -20 -20 l 20 -20 20 20 -20 20");
                            for (int i = 0; i < 4; i++)
                            {
                                int lumsz = 5 - i;
                                ass_out.AppendEvent(40, "pt", 7 + x / ev0_sp - 0.3, t4,
                                                    pos(0, 0) + a(1, "FF") + a(3, "DD") + blur(lumsz) + bord(lumsz) + c(3, "1D4FDD") + fad(0.3, 0.5) +
                                                    p(4) + outlineString);
                            }
                            double lumX = Common.RandomInt(rnd, x - 12, x + 12);
                            double lumY = Common.RandomInt(rnd, y - 12, y + 12);
                            for (int i = 0; i < 3; i++)
                            {
                                int lumsz  = 8 + i * 2;
                                int lumsz2 = lumsz - 1;
                                ass_out.AppendEvent(50, "pt", t1, t2,
                                                    clip(4, outlineString) + pos(lumX, lumY) +
                                                    a(1, "44") + a(3, "00") + c(1, cMain) + c(3, cMain) + t(bord(lumsz).t() + blur(lumsz).t()) +
                                                    p(1) + "m 0 0 l 1 0 1 1 0 1");
                                ass_out.AppendEvent(50, "pt", t2, 7 + x / ev0_sp + 0.3, // Speed : 200
                                                    clip(4, outlineString) + pos(lumX, lumY) + fad(0, 0.3) +
                                                    a(1, "44") + a(3, "00") + c(1, cMain) + c(3, cMain) + bord(lumsz) + blur(lumsz) +
                                                    p(1) + "m 0 0 l 1 0 1 1 0 1");
                                ass_out.AppendEvent(50, "pt", 7 + x / ev0_sp - 0.3, t3,// Speed : 200
                                                    clip(4, outlineString) + pos(lumX, lumY) + fad(0.3, 0) +
                                                    a(1, "44") + a(3, "00") + c(1, cMain2) + c(3, cMain2) + bord(lumsz2) + blur(lumsz2) +
                                                    p(1) + "m 0 0 l 1 0 1 1 0 1");
                                ass_out.AppendEvent(50, "pt", t3, t4,
                                                    clip(4, outlineString) + pos(lumX, lumY) +
                                                    a(1, "44") + a(3, "00") + c(1, cMain2) + c(3, cMain2) + bord(lumsz2) + blur(lumsz2) +
                                                    t(bord(0).t() + blur(0).t()) +
                                                    p(1) + "m 0 0 l 1 0 1 1 0 1");
                            }
                        }
                        else
                        {
                            double t0 = ev.Start - 0.5 + iK * 0.07;
                            double t1 = kStart - 0.1;
                            double t2 = kStart + 0.4;
                            double t3 = ev.End - 0.5 + iK * 0.07;
                            double t4 = t3 + 0.5;

                            string cMain = "3C3DFF";
                            int    jEv   = iEv - 13;
                            if (jEv == 1)
                            {
                                cMain = "FFFFFF";
                            }
                            if (jEv == 2)
                            {
                                cMain = "FF8D3C";
                            }
                            if (jEv == 3)
                            {
                                cMain = "FC7D7F";
                            }
                            if (jEv == 4)
                            {
                                cMain = "FFC6D2";
                            }
                            if (jEv == 5)
                            {
                                cMain = "5758FF";
                            }
                            if (jEv == 6)
                            {
                                cMain = "5758FF";
                            }
                            if (jEv == 7)
                            {
                                cMain = "FF55C6";
                            }
                            if (jEv >= 8)
                            {
                                cMain = "FF8D3C";
                            }
                            string cShad = "EEEEEE";
                            if (jEv == 1)
                            {
                                cShad = "222222";
                            }

                            ass_out.AppendEvent(30, evStyle, t0, t3,
                                                pos(x + 2, y + 2) + a(1, "00") + c(1, "000000") + blur(1.2) + fad(0.8, 0) +
                                                ke.KText);
                            ass_out.AppendEvent(30, evStyle, t3, t4,
                                                pos(x + 2, y + 2) + a(1, "00") + c(1, "000000") + blur(1.2) + fad(0, t4 - t3) +
                                                ke.KText);
                            ass_out.AppendEvent(40, "pt", t1, t3,
                                                clip(4, outlineString) + pos(x, y) + a(1, "33") + c(1, cShad) + fad(t2 - t1, 0) +
                                                p(1) + "m -20 -20 l 20 -20 20 20 -20 20");
                            ass_out.AppendEvent(40, "pt", t3, t4,
                                                clip(4, outlineString) + pos(x, y) + a(1, "33") + c(1, cShad) + fad(0, t4 - t3) +
                                                p(1) + "m -20 -20 l 20 -20 20 20 -20 20");
                            for (int i = 0; i < 4; i++)
                            {
                                int lumsz = 5 - i;
                                ass_out.AppendEvent(30, "pt", t1, t4,
                                                    pos(0, 0) + a(1, "FF") + a(3, "DD") + blur(lumsz) + bord(lumsz) + c(3, cMain) + fad(0.3, 0.5) +
                                                    p(4) + outlineString);
                            }
                            double lumX = Common.RandomInt(rnd, x - 12, x + 12);
                            double lumY = Common.RandomInt(rnd, y - 12, y + 12);
                            for (int i = 0; i < 3; i++)
                            {
                                int lumsz = 8 + i * 2;
                                ass_out.AppendEvent(50, "pt", t1, t2,
                                                    clip(4, outlineString) + pos(lumX, lumY) +
                                                    a(1, "44") + a(3, "00") + c(1, cMain) + c(3, cMain) + t(bord(lumsz).t() + blur(lumsz).t()) +
                                                    p(1) + "m 0 0 l 1 0 1 1 0 1");
                                ass_out.AppendEvent(50, "pt", t2, t3,
                                                    clip(4, outlineString) + pos(lumX, lumY) +
                                                    a(1, "44") + a(3, "00") + c(1, cMain) + c(3, cMain) + bord(lumsz) + blur(lumsz) +
                                                    p(1) + "m 0 0 l 1 0 1 1 0 1");
                                ass_out.AppendEvent(50, "pt", t3, t4,
                                                    clip(4, outlineString) + pos(lumX, lumY) +
                                                    a(1, "44") + a(3, "00") + c(1, cMain) + c(3, cMain) + bord(lumsz) + blur(lumsz) +
                                                    t(bord(0).t() + blur(0).t()) +
                                                    p(1) + "m 0 0 l 1 0 1 1 0 1");
                            }
                        }
                    }
                }

                if (iEv == 0 || iEv == 13)
                {
                    double ptx0   = MarginLeft;
                    double ptx1   = x0 + 30;
                    double pty    = y0 + FontHeight / 2;
                    string cMain  = "1DA4DD";
                    double tStart = 7;
                    for (int i = 0; i < 3; i++)
                    {
                        int lumsz = 18 + i * 2;
                        ass_out.AppendEvent(70, "pt", tStart, tStart + (ptx1 - ptx0) / ev0_sp,
                                            clip(4, outlines) + move(ptx0, pty, ptx1, pty) + fad(0.3, 0.3) +
                                            bord(lumsz) + blur(lumsz) + a(1, "44") + a(3, "00") + c(1, cMain) + c(3, cMain) +
                                            p(1) + "m 0 -20 l 1 -20 1 20 0 20");
                    }
                }
            }

            Console.WriteLine(ass_out.Events.Count);
            ass_out.SaveFile(this.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();

            for (int iEv = 0; iEv < ass_in.Events.Count; iEv++)
            {
                if (iEv <= 2)
                {
                    continue;
                }

                ASSEvent ev = ass_in.Events[iEv];

                /// trick
                if (iEv == 2)
                {
                    ev.Text = ev.Text.Replace(' ', '@');
                }
                List <KElement> kelems = ev.SplitK(true);
                if (iEv == 2)
                {
                    ev.Text = ev.Text.Replace('@', ' ');
                    foreach (KElement ke in kelems)
                    {
                        ke.KText = ke.KText.Replace('@', ' ');
                    }
                }

                this.FontCharset = 1;
                this.FontName    = "EPSON 丸ゴシック体M";
                this.MaskStyle   = "Style: Default,EPSON 丸ゴシック体M,38,&H00FFFFFF,&HFFFFFFFF,&HFFFFFFFF,&HFFFFFFFF,-1,0,0,0,100,100,0,0,1,0,0,5,0,0,0,1";
                string evStyle = "ed_jp";

                int tw      = GetTotalWidth(ev);
                int x0      = (PlayResX - MarginLeft - MarginRight - tw) / 2 + MarginLeft;
                int startx0 = x0;
                int y0      = PlayResY - MarginBottom - FontHeight;
                int kSum    = 0;

                List <CompositeCurve> curves      = new List <CompositeCurve>();
                List <CompositeCurve> curve_blurs = new List <CompositeCurve>();
                for (int i = 0; i < 4; i++)
                {
                    Brown brown = new Brown {
                        X0 = 0, Y0 = 0, R = 5, Speed = 100, MinT = ev.Start, MaxT = ev.End
                    };
                    CompositeCurve curve = new CompositeCurve {
                        MinT = ev.Start, MaxT = ev.End
                    };
                    curve.AddCurve(ev.Start, ev.End, brown);

                    Brown brown_blur = new Brown {
                        X0 = 0, Y0 = 0, R = 1, Speed = 5, MinT = ev.Start - 1, MaxT = ev.End + 1
                    };
                    CompositeCurve curve_blur = new CompositeCurve {
                        MinT = ev.Start - 1, MaxT = ev.End + 1
                    };
                    curve_blur.AddCurve(ev.Start - 1, ev.End + 1, brown_blur);

                    curves.Add(curve);
                    curve_blurs.Add(curve_blur);
                }

                List <int> centerOffsetX = new List <int>();
                if (iEv == 1 || iEv == 2)
                {
                    List <int> tmpx = new List <int>();
                    int        tx0  = x0;
                    for (int i = 0; i < kelems.Count; i++)
                    {
                        KElement ke    = kelems[i];
                        Size     sz    = GetSize(ke.KText);
                        int      x_an7 = x0;
                        int      y_an7 = y0;
                        tmpx.Add(tx0);
                        tx0 += sz.Width + FontSpace;
                        if (ke.KText.Trim().Length == 0)
                        {
                            continue;
                        }
                    }
                    tmpx.Add(tx0);
                    for (int i = 0; i < kelems.Count; i++)
                    {
                        KElement ke = kelems[i];
                        int      j  = i;
                        while (j + 1 < kelems.Count)
                        {
                            if (kelems[j + 1].KEnd_NoSplit == ke.KEnd_NoSplit && kelems[j + 1].KStart_NoSplit == ke.KStart_NoSplit)
                            {
                                j++;
                            }
                            else
                            {
                                break;
                            }
                        }
                        int centerx = (tmpx[i] + tmpx[j + 1]) / 2;
                        for (; i <= j; i++)
                        {
                            centerOffsetX.Add(tmpx[i] - centerx);
                        }
                        i--;
                    }
                }

                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];
                    Size     sz      = GetSize(ke.KText);
                    double   kStart  = ev.Start + kSum * 0.01;
                    double   kEnd    = kStart + ke.KValue * 0.01;
                    double   kStart0 = kStart;
                    double   kEnd0   = kEnd;
                    kSum  += ke.KValue;
                    kStart = ke.KStart_NoSplit;
                    kEnd   = ke.KEnd_NoSplit;
                    int x     = x0 + this.FontSpace + sz.Width / 2;
                    int y     = y0 + FontHeight / 2;
                    int x_an7 = x0;
                    int y_an7 = y0;
                    x0 += this.FontSpace + sz.Width;
                    if (ke.KText.Trim().Length == 0)
                    {
                        continue;
                    }

                    if (iEv == 0)
                    {
                        for (int j = 0; j < 3; j++)
                        {
                            if (j == 1)
                            {
                                x = MarginLeft + sz.Width / 2;
                            }
                            if (j == 2)
                            {
                                x = PlayResX - MarginRight - sz.Width / 2;
                            }
                            if (j != 0)
                            {
                                continue;
                            }

                            for (int i = 0; i < 4; i++)
                            {
                                CompositeCurve curve      = curves[i];
                                CompositeCurve curve_blur = curve_blurs[i];

                                foreach (ASSPointF pt in curve.GetPath_DT(0.04))
                                {
                                    ASSPointF pt_blur = curve_blur.GetPointF(pt.T);
                                    string    a1      = "22";
                                    if (pt.T - ev.Start < 0.3)
                                    {
                                        a1 = Common.scaleAlpha("FF", "22", (pt.T - ev.Start) / 0.3);
                                    }
                                    if (ev.End - pt.T < 0.3)
                                    {
                                        a1 = Common.scaleAlpha("FF", "22", (ev.End - pt.T) / 0.3);
                                    }

                                    ass_out.AppendEvent(50, evStyle, pt.T, pt.T + 0.04,
                                                        pos(pt.X + x, pt.Y + y) +
                                                        a(1, a1) +
                                                        c(1, (i % 2 == 0) ? "FFFFFF" : "000000") +
                                                        blur(5.0 * ((pt_blur.X + 1.1) * 0.5)) +
                                                        ke.KText);
                                }
                            }
                        }
                    }

                    if (iEv == 1 || iEv == 2)
                    {
                        for (int i = 0; i < 2; i++)
                        {
                            CompositeCurve curve      = curves[i];
                            CompositeCurve curve_blur = curve_blurs[i];

                            foreach (ASSPointF pt in curve.GetPath_DT(0.04))
                            {
                                ASSPointF pt_blur = curve_blur.GetPointF(pt.T);
                                string    a1      = "22";
                                if (pt.T - ev.Start < 0.3)
                                {
                                    a1 = Common.scaleAlpha("FF", "22", (pt.T - ev.Start) / 0.3);
                                }
                                if (ev.End - pt.T < 0.3)
                                {
                                    a1 = Common.scaleAlpha("FF", "22", (ev.End - pt.T) / 0.3);
                                }

                                double blur_value = 2.0 * ((pt_blur.X + 2) * 0.5);
                                int    ifsc       = 100;
                                double kEnd2      = kEnd;
                                bool   ink        = false;
                                if (pt.T >= kStart && pt.T <= kEnd2)
                                {
                                    ifsc = 135;
                                    ink  = true;
                                }
                                string col = (i % 2 == 0) ? "FFFFFF" : "000000";
                                if (i % 2 == 0 && ink)
                                {
                                    col = "FFFFFF";
                                    a1  = "00";
                                }
                                else
                                {
                                    a1 = "77";
                                }

                                ass_out.AppendEvent((i == 0) ? (ink ? 150 : 50) : 100, evStyle, pt.T, pt.T + 0.04,
                                                    pos(pt.X + x + (double)(ifsc - 100) / 100.0 * centerOffsetX[iK], pt.Y + y) +
                                                    a(1, a1) +
                                                    c(1, col) +
                                                    blur(blur_value) + fsc(ifsc) +
                                                    ke.KText);

                                if (i == 1)
                                {
                                    continue;
                                }
                                double tx  = pt.X + x;
                                double dx  = -(pt.T - kStart0) / ev.Last * 10.0;
                                double ta1 = 1;
                                if (!ink)
                                {
                                    ta1 = 0.5;
                                }
                                if (pt.T - ev.Start < 0.3)
                                {
                                    ta1 *= (pt.T - ev.Start) / 0.3;
                                }
                                if (ev.End - pt.T < 0.3)
                                {
                                    ta1 *= (ev.End - pt.T) / 0.3;
                                }
                                double tb   = blur_value;
                                int    tfsc = ifsc + 5;
                                for (int j = 0; j < 10; j++)
                                {
                                    ass_out.AppendEvent(50 + j + 1, evStyle, pt.T, pt.T + 0.04,
                                                        pos(tx + (double)(tfsc - 100) / 100.0 * centerOffsetX[iK], pt.Y + y) +
                                                        a(1, Common.scaleAlpha("FF", "00", ta1)) +
                                                        c(1, col) +
                                                        blur(tb) + fsc(tfsc) +
                                                        ke.KText);

                                    tx += dx;
                                    if (dx < 0)
                                    {
                                        dx -= 1.0;
                                    }
                                    else
                                    {
                                        dx += 1.0;
                                    }
                                    ta1  *= 0.9;
                                    tb   += 1;
                                    tfsc += (int)Math.Abs(dx);
                                }
                            }
                        }
                    }

                    if (iEv > 2)
                    {
                        ass_out.AppendEvent(49, evStyle, ev.Start, ev.End,
                                            pos(x - 1, y - 1) +
                                            a(1, "00") + c(1, "000000") + blur(1.1) +
                                            ke.KText);
                        ass_out.AppendEvent(50, evStyle, ev.Start, ev.End,
                                            pos(x, y) +
                                            a(1, "00") + c(1, "000000") + blur(0.9) +
                                            ke.KText);
                        ass_out.AppendEvent(51, evStyle, ev.Start, ev.End,
                                            pos(x + 2, y + 2) +
                                            a(1, "00") + c(1, "000000") +
                                            ke.KText);
                    }
                }
            }

            ass_out.SaveFile(OutFileName);
            Console.WriteLine("Lines : {0}", ass_out.Events.Count);
        }