public List <ASSPoint> Create(float step)
        {
            List <ASSPoint> result = new List <ASSPoint>();
            float           t      = 0;

            while (true)
            {
                ASSPoint pt = new ASSPoint
                {
                    X = (int)(Math.Pow(1 - t, 3) * P0.X + 3.0 * Math.Pow(1 - t, 2) * t * P1.X + 3.0 * (1 - t) * Math.Pow(t, 2) * P2.X + Math.Pow(t, 3) * P3.X),
                    Y = (int)(Math.Pow(1 - t, 3) * P0.Y + 3.0 * Math.Pow(1 - t, 2) * t * P1.Y + 3.0 * (1 - t) * Math.Pow(t, 2) * P2.Y + Math.Pow(t, 3) * P3.Y)
                };
                if (result.Count == 0 || result[result.Count - 1].X != pt.X || result[result.Count - 1].Y != pt.Y)
                {
                    result.Add(pt);
                }

                if (t >= 1)
                {
                    break;
                }
                t += step;
                if (t > 1)
                {
                    t = 1;
                }
            }
            return(result);
        }
Example #2
0
        public static Bezier CreateBezier3(Random rnd, double ox, double oy, double a, double b)
        {
            string s = @"{\p1}";

            double[] aa = new double[4];
            for (int i = 0; i < 4; i++)
            {
                aa[i] = Common.RandomDouble(rnd, 0, 2 * Math.PI);
            }
            ASSPoint[] pp = new ASSPoint[4];
            int        j  = Common.RandomInt(rnd, 0, 4);

            for (int i = 0; i < 4; i++)
            {
                if (i == 0)
                {
                    s += "m";
                }
                else
                {
                    s += " s";
                }
                j     = (j + 1) % aa.Length;
                pp[i] = new ASSPoint {
                    X = (int)(Math.Round(ox + Math.Cos(aa[j]) * a)), Y = (int)(Math.Round(oy + Math.Sin(aa[j]) * b))
                };
            }
            return(new Bezier(pp[0], pp[1], pp[2], pp[3]));
        }
        public ASSPoint Get(float t)
        {
            ASSPoint pt = new ASSPoint
            {
                X = (int)(Math.Pow(1 - t, 3) * P0.X + 3.0 * Math.Pow(1 - t, 2) * t * P1.X + 3.0 * (1 - t) * Math.Pow(t, 2) * P2.X + Math.Pow(t, 3) * P3.X),
                Y = (int)(Math.Pow(1 - t, 3) * P0.Y + 3.0 * Math.Pow(1 - t, 2) * t * P1.Y + 3.0 * (1 - t) * Math.Pow(t, 2) * P2.Y + Math.Pow(t, 3) * P3.Y)
            };

            return(pt);
        }
        public Bezier(ASSPoint p0, ASSPoint p1, ASSPoint p2, ASSPoint p3)
        {
            this.P0 = p0;
            this.P1 = p1;
            this.P2 = p2;
            this.P3 = p3;

            MinT = 0;
            MaxT = 1;
        }
        public override void Run()
        {
            ASS ass_in  = ASS.FromFile(this.InFileName);
            ASS ass_out = new ASS();

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

            string ms1    = "Style: Default,DFGMaruGothic-Md,30,&H00FF0000,&HFF600D00,&H000000FF,&HFF0A5A84,-1,0,0,0,100,100,0,0,0,2,0,5,20,20,20,128";
            string ms3    = "Style: Default,DFGMaruGothic-Md,30,&H000000FF,&HFF600D00,&H00FF0000,&HFF0A5A84,-1,0,0,0,100,100,0,0,0,2,0,5,20,20,20,128";
            string ptstr  = @"{\p1}m 0 0 l 1 0 1 1 0 1";
            string pt0Str = @"{\blur2\bord3\p4}m 5 5 s 5 -5 -5 -5 -5 5";

            Random rnd = new Random();

            InitBFS();

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

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

                int kSum = 0;

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

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

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

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

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


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

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

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

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

                    int bakx0 = x0;

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

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

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

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

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

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

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

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

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

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

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

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

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

            ass_out.SaveFile(OutFileName);
            Console.WriteLine("Lines : {0}", ass_out.Events.Count);
        }
Example #6
0
        public override void Run()
        {
            ASS ass_in  = ASS.FromFile(this.InFileName);
            ASS ass_out = new ASS();

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

            Random rnd = new Random();

            string col0   = "96726A";
            string col1   = "D17C6A";
            string ptcol2 = "644BFF";
            string ptcol1 = "5BFF4B";
            string ptstr  = @"{\p1}m 0 0 l 1 0 1 1 0 1";

            string[] ptcollist =
            {
                "5A3AFF",
                "3A5BFF",
                "FF3A5D",
                "3AFF4E",
                "FF3AD9",
                "FFD13A"
            };
            string lastptcol = "";

            string[] firestr =
            {
                @"{\p5}m 0 0 b 8 1 9 -28 -2 -41 b 3 -23 -17 0 0 0",
                @"{\p5}m 1 41 b 20 39 1 13 13 -11 b 5 1 -18 22 1 41",
                @"{\p4}m 6 39 b 4 29 1 13 27 -37 b -1 -3 -15 34 6 39",
                @"{\p5}m -3 43 b -9 22 -1 33 16 -47 b 1 3 -17 0 -3 43"
            };

            string spstr = @"{\p1}m 3 0 b 7 0 12 0 16 0 b 19 0 19 2 16 2 b 12 2 7 2 3 2 b 0 2 0 0 3 0{\p0}";

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

                int x0      = MarginLeft;
                int startx0 = x0;
                int y0      = PlayResY - MarginBottom - FontHeight;
                int kSum    = 0;

                List <ASSPointF> poslist = new List <ASSPointF>();

                string ptcol = ptcollist[Common.RandomInt(rnd, 0, ptcollist.Length - 1)];
                while (ptcol == lastptcol)
                {
                    ptcol = ptcollist[Common.RandomInt(rnd, 0, ptcollist.Length - 1)];
                }
                lastptcol = ptcol;

                for (int iK = 0; iK < kelems.Count; iK++)
                {
                    Console.WriteLine("{0} / {1} : {2} / {3}", iEv + 1, ass_in.Events.Count, iK + 1, kelems.Count);
                    KElement ke     = kelems[iK];
                    double   r      = (double)iK / (double)(kelems.Count - 1);
                    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;
                    y0  = y0;
                    if (ke.KText.Trim().Length == 0)
                    {
                        continue;
                    }
                    poslist.Add(new ASSPointF {
                        X = x, Y = y, Start = kStart, End = kEnd
                    });

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

                    ass_out.AppendEvent(60, "Default", t0, t1,
                                        pos(x, y) + frz(-30) + a(1, "00") +
                                        fad((t1 - t0) * 0.5, 0) + fsc(130, 200) + blur(3) + bord(0) +
                                        t(0, t1 - t0, frz(0).t() + fsc(100, 100).t() + c(1, col0).t() + blur(0).t()) +
                                        ke.KText);
                    ass_out.AppendEvent(50, "Default", t1, t2,
                                        pos(x, y) + a(1, "00") + c(1, col0) +
                                        ke.KText);
                    ass_out.AppendEvent(60, "Default", t2, t3,
                                        pos(x, y) + a(1, "00") + a(3, "00") + c(3, col1) +
                                        bord(4) + blur(4) + fsc(200, 200) +
                                        t(0, t3 - t2, fsc(110, 110).t() + bord(2).t() + blur(2).t()) +
                                        ke.KText);
                    ass_out.AppendEvent(30, "Default", t2, t4,
                                        pos(x, y) + a(1, "FF") + a(3, "44") +
                                        bord(2) + blur(2) +
                                        fad(0.3, 0.1) +
                                        ke.KText);
                    ass_out.AppendEvent(50, "Default", t3, t4,
                                        pos(x, y) + a(1, "00") + c(1, "FFFFFF") + a(3, "00") +
                                        c(3, col1) + bord(1) +
                                        ke.KText);
                    ass_out.AppendEvent(40, "Default", t4, t5,
                                        pos(x, y) + a(1, "00") + c(1, "FFFFFF") + a(3, "FF") +
                                        bord(0) + blur(0) + fad(0, t5 - t4) +
                                        t(0, t5 - t4, frz(30).t() + fsc(130, 200).t() + blur(4).t()) +
                                        ke.KText);

                    //continue;
                    for (int i = 0; i < (t2 - t1) * 100; i++)
                    {
                        ASSPoint pt     = mask.Points[Common.RandomInt(rnd, 0, mask.Points.Count - 1)];
                        double   ptx    = pt.X;
                        double   pty    = pt.Y;
                        double   ptt0   = Common.RandomDouble(rnd, t1, t2);
                        double   ptt1   = ptt0 + 0.3;
                        int      tmpz   = Common.RandomInt(rnd, 0, 359);
                        string   tmpstr = firestr[Common.RandomInt(rnd, 0, firestr.Length - 1)];
                        ass_out.AppendEvent(100, "pt", ptt0, ptt1,
                                            move(ptx, pty, ptx, pty - 20) + a(1, "D0") + c(1, "B79E8A") +
                                            a(3, "C0") + c(3, "B79E8A") + bord(3) + blur(3) +
                                            frz(tmpz) +
                                            t(0, ptt1 - ptt0, fsc(80, 80).t() + bord(1).t() + frx(0).t() + fry(361).t() + frz(-57).t()) +
                                            tmpstr);
                    }
                    for (int i = 0; i < (t4 - t3) * 100; i++)
                    {
                        ASSPoint pt     = mask.Points[Common.RandomInt(rnd, 0, mask.Points.Count - 1)];
                        double   ptx    = pt.X;
                        double   pty    = pt.Y;
                        double   ptt0   = Common.RandomDouble(rnd, t3, t4);
                        double   ptt1   = ptt0 + 0.3;
                        int      tmpz   = Common.RandomInt(rnd, 0, 359);
                        string   tmpstr = firestr[Common.RandomInt(rnd, 0, firestr.Length - 1)];
                        ass_out.AppendEvent(100, "pt", ptt0, ptt1,
                                            move(ptx, pty, ptx, pty - 20) + a(1, "D0") + c(1, "3D3EE7") + //354CB9
                                            a(3, "C0") + c(3, "3D3EE7") + bord(3) + blur(3) +
                                            frz(tmpz) +
                                            t(0, ptt1 - ptt0, fsc(80, 80).t() + bord(1).t() + frx(0).t() + fry(361).t() + frz(-57).t()) +
                                            tmpstr);
                    }
                }

                //continue;

                for (int i = 1; i < poslist.Count; i++)
                {
                    if (poslist[i].End - poslist[i].Start < 1e-8)
                    {
                        poslist[i - 1].End -= 0.1;
                        poslist[i].Start   -= 0.1;
                    }
                }

                for (int i = 0; i < 3; i++)
                {
                    /*
                     * if (i > 1) continue;
                     * CompositeCurve curve = new CompositeCurve() { MinT = ev.Start - 0.1, MaxT = ev.End + (PlayResX - x0) * 0.002 };
                     * bool lastup = i == 0;
                     * if (lastup)
                     *  curve.AddCurve(curve.MinT, ev.Start, new Line() { MinT = 0, MaxT = 1, X0 = 0, X1 = MarginLeft, Y0 = y0 - FontHeight * 0.5, Y1 = y0 - FontHeight * 0.5 });
                     * else
                     *  curve.AddCurve(curve.MinT, ev.Start, new Line() { MinT = 0, MaxT = 1, X0 = 0, X1 = MarginLeft, Y0 = y0 + FontHeight * 1.5, Y1 = y0 + FontHeight * 1.5 });
                     * string ptcol = lastup ? ptcol1 : ptcol2;
                     * double lastx1 = MarginLeft;
                     * double lasty1 = 0;
                     * double lastt = 0;
                     * foreach (ASSPointF pos in poslist)
                     * {
                     *  double thisx1 = pos.X + FontWidth / 2;
                     *  double yy0 = y0 - FontHeight * 0.5;
                     *  double yy1 = y0 + FontHeight * 1.5;
                     *  if (!lastup)
                     *  {
                     *      yy0 = y0 + FontHeight * 1.5;
                     *      yy1 = y0 - FontHeight * 0.5;
                     *  }
                     *  lastup = !lastup;
                     *  //curve.AddCurve(pos.Start, pos.End, new Line() { MinT = 0, MaxT = 1, X0 = lastx1, X1 = thisx1, Y0 = yy0, Y1 = yy1 });
                     *  curve.AddCurve(pos.Start, pos.End, Sine.Create(lastx1, yy0, thisx1, yy1));
                     *  lastx1 = thisx1;
                     *  lasty1 = yy1;
                     *  lastt = pos.End;
                     * }
                     * curve.AddCurve(lastt, curve.MaxT, new Line() { MinT = 0, MaxT = 1, X0 = lastx1, X1 = PlayResX, Y0 = lasty1, Y1 = lasty1 });
                     * */
                    CompoundCurve curve = new CompoundCurve()
                    {
                        MinT = ev.Start - 0.2, MaxT = ev.End + 1
                    };
                    curve.AddCurve(curve.MinT, curve.MaxT, new Circle()
                    {
                        X0 = 0, Y0 = 0, R = 30, MinT = 0 + i * 2.0 / 3.0 * Math.PI, MaxT = Math.PI * 2 * (curve.MaxT - curve.MinT) * 1.3 + i * 2.0 / 3.0 * Math.PI
                    });
                    CompositeCurve pathcurve = new CompositeCurve()
                    {
                        MinT = curve.MinT, MaxT = curve.MaxT
                    };
                    double lastx = 0;
                    double lastt = curve.MinT;
                    double yyy   = y0 + FontHeight * 0.5;
                    for (int j = 0; j < poslist.Count; j++)
                    {
                        double thist = poslist[j].Start;
                        double thisx = poslist[j].X;
                        pathcurve.AddCurve(lastt, thist, new Line()
                        {
                            X0 = lastx, X1 = thisx, Y0 = yyy, Y1 = yyy
                        });
                        if (j + 1 == poslist.Count)
                        {
                            thist = curve.MaxT;
                        }
                        else
                        {
                            thist = poslist[j + 1].Start - 0.2;
                            if (thist < poslist[j].Start)
                            {
                                thist = poslist[j].Start * 0.25 + poslist[j + 1].Start * 0.75;
                            }
                        }
                        pathcurve.AddCurve(poslist[j].Start, thist, new Line()
                        {
                            X0 = thisx, X1 = thisx, Y0 = yyy, Y1 = yyy
                        });
                        lastt = thist;
                        lastx = thisx;
                    }
                    curve.AddCurve(curve.MinT, curve.MaxT, pathcurve);

                    List <ASSPointF> pts = curve.GetPath_Dis(1, 1.2);
                    foreach (ASSPointF pt in pts)
                    {
                        double ptx2 = Common.RandomDouble(rnd, pt.X - 10, pt.X - 15);
                        double pty2 = pt.Y * 0.25 + (y0 + FontHeight * 0.5) * 0.75;
                        ass_out.AppendEvent(55, "pt", pt.T, pt.T + 0.3,
                                            pos(pt.X, pt.Y) +
                                            //                          move(pt.X, pt.Y, ptx2, pty2, 0.4, 1) +
                                            a(1, "AA") + c(1, "FFFFFF") +
                                            a(3, "AA") + c(3, ptcol) +
                                            bord(6) + blur(6) +
                                            t(0, 0.1, bord(3).t() + blur(3).t()) +
                                            fad(0, 0.2) +
                                            ptstr);
                        ass_out.AppendEvent(55, "pt", pt.T, pt.T + 0.3,
                                            pos(pt.X, pt.Y) +
//                            move(pt.X, pt.Y, ptx2, pty2, 0.4, 1) +
                                            a(1, "AA") + c(1, "FFFFFF") +
                                            a(3, "00") + c(3, "FFFFFF") +
                                            bord(4) + blur(4) +
                                            t(0, 0.1, bord(1).t() + blur(1).t() + a(3, "44").t()) +
                                            fad(0, 0.2) +
                                            ptstr);
                    }
                }
            }

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

            string ptString = @"{\p8}m 0 0 l 128 0 128 128 0 128";

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

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

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

                Random rnd = new Random();

                int kSum = 0;

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

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

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

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

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

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

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

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

                    for (int i = 0; i < mask.Points.Count; i++)
                    {
                        ASSPoint pt    = mask.Points[i];
                        double   indsc = 50.0;
                        if (iEv >= 4)
                        {
                            indsc = 75.0;
                        }
                        double tp0 = kStart - 0.1 + (double)ind[i] / indsc + Common.RandomDouble_Gauss(rnd, -0.2, 0.2);
                        double tp1 = tp0 + 0.3;
                        double tp2 = tp1 + 0.3;
                        string pc0 = "5955FF";
                        string pc1 = "55FDFF";
                        string pc2 = "9C4E4D";
                        ass_out.Events.Add(
                            ev.StartReplace(tp0).EndReplace(tp1).StyleReplace("pt").LayerReplace(5).TextReplace(
                                ASSEffect.pos(pt.X, pt.Y) + ASSEffect.fad(0.3, 0) +
                                ASSEffect.a(1, Common.ToHex2(255 - pt.Brightness)) + ASSEffect.c(1, pc0) +
                                ptString
                                ));
                        ass_out.Events.Add(
                            ev.StartReplace(tp1).EndReplace(tp2).StyleReplace("pt").LayerReplace(5).TextReplace(
                                ASSEffect.pos(pt.X, pt.Y) +
                                ASSEffect.a(1, Common.ToHex2(255 - pt.Brightness)) + ASSEffect.c(1, pc0) +
                                ASSEffect.t(0, tp2 - tp1, ASSEffect.c(1, pc1).t()) +
                                ptString
                                ));
                        ass_out.Events.Add(
                            ev.StartReplace(tp2).EndReplace(t2).StyleReplace("pt").LayerReplace(5).TextReplace(
                                ASSEffect.pos(pt.X, pt.Y) +
                                ASSEffect.a(1, Common.ToHex2(255 - pt.Brightness)) + ASSEffect.c(1, pc1) +
                                ASSEffect.t(0, 0.3, ASSEffect.c(1, pc2).t()) +
                                ptString
                                ));
                    }
                }
            }
            ass_out.SaveFile(OutFileName);
        }
Example #8
0
        public int[] CalculateBFSOrder(StringMask mask)
        {
            for (int i = 0; i < this.PlayResX; i++)
            {
                for (int j = 0; j < this.PlayResY; j++)
                {
                    map[i, j] = -1;
                }
            }
            for (int i = 0; i < mask.Points.Count; i++)
            {
                ASSPoint pt = mask.Points[i];
                map[pt.X, pt.Y] = i;
            }
            int[] dx0 = { 0, 1, 0, -1 };
            int[] dy0 = { 1, 0, -1, 0 };
            int[] dx1 = { 1, 1, -1, -1 };
            int[] dy1 = { -1, 1, -1, 1 };
            int[] ind = new int[mask.Points.Count]; // 顺序标号
            for (int i = 0; i < ind.Length; i++)
            {
                ind[i] = -1;
            }
            Queue <int> q;
            int         left = ind.Length; // 剩下

            while (left > 0)
            {
                q = new Queue <int>();
                for (int i = 0; i < ind.Length; i++)
                {
                    if (ind[i] == -1)
                    {
                        q.Enqueue(i);
                        ind[i] = 0;
                        break;
                    }
                }
                while (q.Count > 0)
                {
                    int s = q.Dequeue();
                    left--;
                    ASSPoint pt = mask.Points[s];
                    int      x1, y1, t;
                    for (int i = 0; i < 4; i++)
                    {
                        x1 = pt.X + dx0[i];
                        y1 = pt.Y + dy0[i];
                        if (x1 >= 0 && x1 < PlayResX && y1 >= 0 && y1 < PlayResY && map[x1, y1] >= 0)
                        {
                            t = map[x1, y1];
                            if (ind[t] < 0)
                            {
                                ind[t] = ind[s] + 1;
                                q.Enqueue(t);
                            }
                        }
                    }
                    for (int i = 0; i < 4; i++)
                    {
                        //if (Common.RandomBool(rnd, 0.5)) continue;
                        break;
                        x1 = pt.X + dx0[i];
                        y1 = pt.Y + dy0[i];
                        if (x1 >= 0 && x1 < PlayResX && y1 >= 0 && y1 < PlayResY && map[x1, y1] >= 0)
                        {
                            t = map[x1, y1];
                            if (ind[t] < 0)
                            {
                                ind[t] = ind[s] + 1;
                                q.Enqueue(t);
                            }
                        }
                    }
                }
            }
            return(ind);
        }
Example #9
0
        public override void Run()
        {
            ASS ass_in  = ASS.FromFile(InFileName);
            ASS ass_out = new ASS();

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

            int y0min = 0;
            int y0max = 100;

            string color1 = "DDC3B2";
            string color2 = "C69A7B";

            List <StringMask> lastMasks = new List <StringMask>();
            List <StringMask> thisMasks = new List <StringMask>();

            Random rnd = new Random();

            /// 所有的不动点最后一次写入
            List <ASSPoint> allPoints = new List <ASSPoint>();

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

                int x0 = MarginLeft;
                int y0 = PlayResY - FontHeight - MarginBottom;

                thisMasks.Clear();
                for (int iK = 0; iK < kelems.Count; iK++)
                {
                    KElement   elem = kelems[iK];
                    StringMask mask = GetMask(elem.KText, x0, y0);
                    thisMasks.Add(GetMask(kelems[iK].KText, x0, y0));
                    x0 += mask.Width + this.FontSpace;
                }

                List <ASSPoint> lastPts = new List <ASSPoint>();
                if (iEv > 0)
                {
                    if (Math.Abs(ev.Start - ass_in.Events[iEv - 1].End) < 2)
                    {
                        foreach (StringMask sm in lastMasks)
                        {
                            lastPts.AddRange(sm.Points);
                        }
                    }
                }
                if (lastPts.Count == 0)
                {
                    lastPts.Add(new ASSPoint {
                        X = -100 * ScaleRate, Y = y0 - 100 * ScaleRate, Brightness = 255
                    });
                }

                bool   next = (iEv + 1 < ass_in.Events.Count) && (Math.Abs(ev.End - ass_in.Events[iEv + 1].Start) < 2);
                bool[] used = new bool[lastPts.Count];
                for (int i = 0; i < used.Length; i++)
                {
                    used[i] = false;
                }

                for (int iK = 0; iK < kelems.Count; iK++)
                {
                    double r  = (double)iK / (double)(kelems.Count - 1);
                    double r0 = 1.0 - r;

                    StringMask      mask = thisMasks[iK];
                    List <ASSPoint> pts  = mask.Points;

                    foreach (ASSPoint pt in pts)
                    {
                        int zz = 0;
                        if (used.Length > 1)
                        {
                            zz = Common.RandomInt_Gauss2(rnd, used.Length, (int)(r * (used.Length - 1)));
                        }
                        used[zz] = true;
                        ASSPoint        srcpt   = lastPts[zz];
                        List <ASSPoint> bez_pts = new Bezier(srcpt,
                                                             new ASSPoint {
                            X = Common.RandomInt_Gauss(rnd, srcpt.X - 30 * ScaleRate, 80 * ScaleRate), Y = Common.RandomInt_Gauss(rnd, srcpt.Y - 50 * ScaleRate, 80 * ScaleRate)
                        },
                                                             new ASSPoint {
                            X = Common.RandomInt_Gauss(rnd, pt.X + 30 * ScaleRate, 80 * ScaleRate), Y = Common.RandomInt_Gauss(rnd, pt.Y - 50 * ScaleRate, 80 * ScaleRate)
                        }, pt).Create(0.1f);

                        /// for test
                        double f1 = ev.Start - r0 * 1.0;
                        double f0 = f1 - 1;
                        srcpt.End = f0;
                        pt.Color  = Common.scaleColor(color1, color2, mask.Y0, PlayResY - MarginBottom, pt.Y);
                        for (int i = 0; i + 1 < bez_pts.Count; i++)
                        {
                            ASSPoint p0 = bez_pts[i];
                            ASSPoint p1 = bez_pts[i + 1];
                            ass_out.Events.Add(CreateMovingPixel(f0, f0 + 0.1, p0.X, p0.Y, p1.X, p1.Y, Common.scaleColor(srcpt.Color, pt.Color, srcpt.End, f0 + 1, f0), "00"));
                            f0 += 0.1;
                        }
                        pt.Start      = f0;
                        pt.End        = ev.End;
                        pt.Brightness = 255;
                        allPoints.Add(pt);

                        if (!next)
                        {
                            ass_out.Events.Add(CreateMovingPixel(pt.End, pt.End + 1, pt.X, pt.Y, Common.RandomInt_Gauss(rnd, pt.X, 80 * ScaleRate), Common.RandomInt_Gauss(rnd, pt.Y, 80 * ScaleRate), pt.Color, "00", 2));
                        }
                    }
                }

                for (int i = 0; i < used.Length; i++)
                {
                    if (!used[i])
                    {
                        ASSPoint pt = lastPts[i];
                        if (pt.End > ev.Start - 1.5)
                        {
                            pt.End = ev.Start - 1.5;
                        }
                    }
                }

                Console.WriteLine(iEv);

                lastMasks.Clear();
                lastMasks.AddRange(thisMasks);
            }

            foreach (ASSPoint pt in allPoints)
            {
                ass_out.Events.Add(CreatePixel(pt.Start, pt.End, pt.X, pt.Y, pt.Color, Common.ToHex2(255 - pt.Brightness)));
            }

            ass_out.SaveFiles(@"G:\Workshop\natsume2\op_", 500000);
        }
Example #10
0
        public virtual StringMask GetMask(string s, int x, int y)
        {
            if (s.Trim() == "")
            {
                return new StringMask {
                           Height = FontHeight, Width = FontWidth, X0 = x, Y0 = y, Points = new List <ASSPoint>()
                }
            }
            ;
            Graphics g = GetGraphics();

            g.Clear(Color.Black);
            g.DrawString(s, Font, new SolidBrush(Color.White), 0, 0);
            List <ASSPoint> result = new List <ASSPoint>();

            for (int i = 0; i < 200; i++)
            {
                for (int j = 0; j < 50; j++)
                {
                    if (temp_img.GetPixel(i, j).G > 0)
                    {
                        ASSPoint newP = new ASSPoint {
                            X = (int)((double)i * Mask_WidthScale) + x, Y = (int)((double)j * Mask_HeightScale) + y, Brightness = temp_img.GetPixel(i, j).G
                        };
                        if (!result.Any(p => p.X == newP.X && p.Y == newP.Y && p.Brightness == newP.Brightness))
                        {
                            result.Add(newP);
                        }
                    }
                }
            }
            if (result.Count == 0)
            {
                return new StringMask {
                           Height = 0, Width = 0, X0 = x, Y0 = y, Points = result
                }
            }
            ;
            int xmin = 10000;
            int ymin = 10000;
            int xmax = -1;
            int ymax = -1;

            foreach (ASSPoint pt in result)
            {
                if (xmin > pt.X)
                {
                    xmin = pt.X;
                }
                if (xmax < pt.X)
                {
                    xmax = pt.X;
                }

                if (ymin > pt.Y)
                {
                    ymin = pt.Y;
                }
                if (ymax < pt.Y)
                {
                    ymax = pt.Y;
                }
            }
            foreach (ASSPoint pt in result)
            {
                pt.X -= xmin - x;
            }
            return(new StringMask {
                Height = ymax - ymin + 1, Width = xmax - xmin + 1, X0 = x, Y0 = y, Points = result
            });
        }
Example #11
0
        public override void Run()
        {
            ASS ass_in  = ASS.FromFile(this.InFileName);
            ASS ass_out = new ASS();

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

            string ms1    = "Style: Default,DFGMaruGothic-Md,26,&H00FF0000,&HFF600D00,&H000000FF,&HFF0A5A84,-1,0,0,0,100,100,0,0,0,2,0,5,20,20,20,128";
            string ms3    = "Style: Default,DFGMaruGothic-Md,26,&H000000FF,&HFF600D00,&H00FF0000,&HFF0A5A84,-1,0,0,0,100,100,0,0,0,2,0,5,20,20,20,128";
            string ptstr  = @"{\p1}m 0 0 l 1 0 1 1 0 1";
            string pt0Str = @"{\blur2\bord3\p4}m 5 5 s 5 -5 -5 -5 -5 5";

            Random rnd = new Random();

            InitBFS();

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

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

                int kSum = 0;

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

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

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

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

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

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

                    Console.WriteLine(y0);

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

                    int bakx0 = x0;

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

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

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

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

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

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

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

            ass_out.SaveFile(OutFileName);
            Console.WriteLine("Lines : {0}", ass_out.Events.Count);
        }
        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 mainCol = "FF51C5";
            string fCol    = "595AFF";

            for (int iEv = 0; iEv < ass_in.Events.Count; iEv++)
            {
                bool isJp = iEv <= 15;
                //if (iEv != 0) continue;
                this.MaskStyle = isJp ?
                                 "Style: Default,DFMincho-UB,28,&H00FFFFFF,&HFFFFFFFF,&HFFFFFFFF,&HFFFFFFFF,0,0,0,0,100,100,0,0,0,0,0,5,0,0,0,128" :
                                 "Style: Default,汉仪粗宋繁,28,&H00FFFFFF,&HFFFFFFFF,&HFFFFFFFF,&HFFFFFFFF,1,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(!isJp);
                if (!isJp)
                {
                    foreach (KElement ke in kelems)
                    {
                        ke.KValue = 10;
                    }
                }
                int    sw       = GetTotalWidth(ev);
                int    x0       = (!isJp) ? MarginLeft : PlayResX - MarginRight - sw;
                int    y0       = (!isJp) ? (PlayResY - MarginBottom - FontHeight) : MarginTop;
                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 ? "Default" : "cn";
                    string   outlineFontname = isJp ? "DFMincho-UB" : "汉仪粗宋繁";
                    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 - FontHeight / 2, y - FontHeight / 2, ke.KText[0], outlineFontname, outlineEncoding, FontHeight, 0, isJp ? 193 : 178);
                    outlines += outlineString;

                    double t0 = ev.Start - 0.5 + iK * 0.08;
                    double t1 = t0 + 0.4;
                    double t2 = kStart - 0.1;
                    double t3 = kEnd;
                    double t4 = ev.End - 0.5 + iK * 0.08;
                    double t5 = t4 + 0.4;

                    ass_out.AppendEvent(30, "pt", t0, t5,
                                        pos(2, 2) + fad(0.5, 0.5) + a(1, "00") + c(1, "222222") +
                                        blur(2) +
                                        p(4) + outlineString);
                    ass_out.AppendEvent(35, "pt", t0, t5,
                                        pos(0, 0) + fad(0.5, 0.5) + a(1, "00") + c(1, "FFFFFF") +
                                        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;
                        double t24   = t2 + 1;
                        if (t24 > t4)
                        {
                            t24 = (t2 + t4) * 0.5;
                        }
                        ass_out.AppendEvent(40, "pt", t2, t24,
                                            clip(4, outlineString) + pos(lumX, lumY) +
                                            a(1, "44") + a(3, "00") + c(1, mainCol) + c(3, mainCol) + t(bord(lumsz).t() + blur(lumsz).t()) +
                                            p(1) + "m 0 0 l 1 0 1 1 0 1");
                        ass_out.AppendEvent(40, "pt", t24, t4,
                                            clip(4, outlineString) + pos(lumX, lumY) +
                                            a(1, "44") + a(3, "00") + c(1, mainCol) + c(3, mainCol) + bord(lumsz) + blur(lumsz) +
                                            p(1) + "m 0 0 l 1 0 1 1 0 1");
                        ass_out.AppendEvent(40, "pt", t4, t5,
                                            clip(4, outlineString) + pos(lumX, lumY) +
                                            a(1, "44") + a(3, "00") + c(1, mainCol) + c(3, mainCol) + bord(lumsz) + blur(lumsz) +
                                            t(bord(0).t() + blur(0).t()) +
                                            p(1) + "m 0 0 l 1 0 1 1 0 1");
                    }

                    if (!isJp)
                    {
                        continue;
                    }

                    for (int iP = 0; iP < 10 * (t3 - t2); iP++)
                    {
                        int      pid   = Common.RandomInt(rnd, 0, mask.Points.Count - 1);
                        ASSPoint orgpt = mask.Points[pid];
                        double   ptt0  = Common.RandomDouble(rnd, t2, t3);
                        double   ptt1  = ptt0 + 2;
                        double   ptx0  = orgpt.X;
                        double   pty0  = orgpt.Y;
                        double   ag    = Common.RandomDouble(rnd, 0, 2 * Math.PI);
                        double   ptx1  = ptx0 + Common.RandomDouble(rnd, -160, -100);
                        double   pty1  = pty0 + Common.RandomDouble(rnd, 60, 35);

                        string ptstr = CreatePolygon(rnd, 40, 40, 3);
                        int    tmpx  = Common.RandomInt(rnd, 100, 400);
                        int    tmpy  = Common.RandomInt(rnd, 100, 400);
                        int    tmpz  = Common.RandomInt(rnd, 100, 400);

                        for (int i = 0; i < 3; i++)
                        {
                            ass_out.AppendEvent(70 + i, "pt", ptt0, ptt1,
                                                move(ptx0, pty0, ptx1, pty1) + a(1, "44") + a(3, "44") +
                                                c(1, mainCol) + c(3, mainCol) + t(frx(tmpx).t() + fry(tmpy).t() + frz(tmpz).t()) +
                                                blur(3 - i) +
                                                ptstr);
                        }
                        ass_out.AppendEvent(90, "pt", ptt0, ptt1,
                                            move(ptx0, pty0, ptx1, pty1) + a(1, "44") + a(3, "44") +
                                            c(1, "FFFFFF") + c(3, "FFFFFF") + t(frx(tmpx).t() + fry(tmpy).t() + frz(tmpz).t()) +
                                            blur(2) +
                                            ptstr);
                        ass_out.AppendEvent(60, "pt", ptt0, ptt1,
                                            move(ptx0 + 2, pty0 + 3, ptx1 + 2, pty1 + 3) + a(1, "44") + a(3, "44") +
                                            c(1, "000000") + c(3, "000000") + t(frx(tmpx).t() + fry(tmpy).t() + frz(tmpz).t()) +
                                            blur(1) +
                                            ptstr);
                    }
                }
            }

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

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

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

            Random rnd = new Random();

            int testEv = -1;

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

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

                int kSum = 0;

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

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

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

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

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

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


                    col1 = ASSColor.HtmlToASS(col1);

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

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

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

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

                int kSum = 0;

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

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

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

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

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

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


                    col1 = ASSColor.HtmlToASS(col1);

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

            ass_out.SaveFile(OutFileName);
            Console.WriteLine("Lines : {0}", ass_out.Events.Count);
        }
Example #15
0
        public void CalculateEdgeDistance()
        {
            StringMask mask = this;

            if (mask.Points.Count == 0)
            {
                return;
            }

            int mask_minx = 100000;
            int mask_miny = 100000;
            int mask_maxx = -100000;
            int mask_maxy = -100000;

            foreach (ASSPoint pt in mask.Points)
            {
                if (mask_minx > pt.X)
                {
                    mask_minx = pt.X;
                }
                if (mask_miny > pt.Y)
                {
                    mask_miny = pt.Y;
                }
                if (mask_maxx < pt.X)
                {
                    mask_maxx = pt.X;
                }
                if (mask_maxy < pt.Y)
                {
                    mask_maxy = pt.Y;
                }
            }

            foreach (ASSPoint pt in mask.Points)
            {
                pt.X           -= mask_minx - 1;
                pt.Y           -= mask_miny - 1;
                pt.EdgeDistance = -1;
            }
            map  = new int[mask_maxx - mask_minx + 2, mask_maxy - mask_miny + 2];
            edge = new int[mask_maxx - mask_minx + 2, mask_maxy - mask_miny + 2];
            for (int i = 0; i < map.GetLength(0); i++)
            {
                for (int j = 0; j < map.GetLength(1); j++)
                {
                    map[i, j]  = -1;
                    edge[i, j] = -1;
                }
            }
            for (int i = 0; i < mask.Points.Count; i++)
            {
                ASSPoint pt = mask.Points[i];
                map[pt.X, pt.Y]  = i;
                edge[pt.X, pt.Y] = -2;
            }

            for (int i = 0; i < map.GetLength(0); i++)
            {
                for (int j = 0; j < map.GetLength(1); j++)
                {
                    if (edge[i, j] == -1 && map[i, j] == -1)
                    {
                        CalculateEdgeDistance_DFS(i, j);
                    }
                }
            }

            for (int i = 0; i < map.GetLength(0); i++)
            {
                for (int j = 0; j < map.GetLength(1); j++)
                {
                    if (map[i, j] != -1 && edge[i, j] == 0)
                    {
                        mask.Points[map[i, j]].EdgeDistance = 0;
                    }
                }
            }

            foreach (ASSPoint pt in mask.Points)
            {
                pt.X += mask_minx - 1;
                pt.Y += mask_miny - 1;
            }

            for (int i = 0; i < mask.Points.Count; i++)
            {
                ASSPoint pt = mask.Points[i];
                if (pt.EdgeDistance == 0)
                {
                    continue;
                }
                pt.EdgeDistance = 1e8;
                for (int j = 0; j < mask.Points.Count; j++)
                {
                    ASSPoint pt2 = mask.Points[j];
                    if (pt2.EdgeDistance != 0)
                    {
                        continue;
                    }
                    double dis = Common.GetDistance(pt.X, pt.Y, pt2.X, pt2.Y);
                    if (pt.EdgeDistance > dis)
                    {
                        pt.EdgeDistance = dis;
                    }
                }
            }

            map = edge = null;
        }
        public override void Run()
        {
            string ptstr = @"{\p1}m 0 0 l 1 0 1 1 0 1";

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

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

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

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

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

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

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

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

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

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

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

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

            Random rnd = new Random();

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

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

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

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

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

            ass_out.SaveFile(OutFileName);
        }