/// <summary>
        /// Masks a string with a specific string mask
        /// </summary>
        /// <param name="source">The string to be masked</param>
        /// <param name="mask">A commom known mask to be used</param>
        /// <returns>The masked string</returns>
        public static string ToMaskedString(this string source, StringMask mask)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            string maskPattern = string.Empty;

            switch (mask)
            {
            case StringMask.CEP:
                maskPattern = "#####-###";
                break;

            case StringMask.CNPJ:
                maskPattern = "##.###.###/####-##";
                break;

            case StringMask.CPF:
                maskPattern = "###.###.###-##";
                break;

            case StringMask.RG:
                maskPattern = "##.###.###-#";
                break;
            }

            return(ToMaskedString(source.OnlyAlphaNumeric(), maskPattern));
        }
Exemple #2
0
        public override void Run()
        {
            string ptstr = @"{\p1}m 0 0 l 1 0 1 1 0 1";

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

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

            int        x     = 300;
            int        y     = 200;
            StringMask mask  = GetMask("き", x, y);
            bool       first = true;

            ass_out.AppendEvent(0, "Default", 0, 10, ASSEffect.pos(265, y) + ASSEffect.an(5) + "拉");
            foreach (ASSPoint pt in mask.Points)
            {
                double ag  = (double)(pt.Y - mask.Y0) / (double)mask.Height * 0.25;
                int    iag = (int)(ag / Math.PI / 2 * 360);
                //ag = -0.2;
                int yy = (int)(150 * Math.Sin(ag));
                int xx = (int)(150 * Math.Cos(ag));
                ass_out.Events.Add(
                    new ASSEvent
                {
                    Effect  = "",
                    Layer   = 0,
                    MarginL = "0000",
                    MarginR = "0000",
                    MarginV = "0000",
                    Name    = "NTP",
                    Style   = "pt",
                    Start   = 1,
                    End     = 11,
                    Text    = ASSEffect.pos(pt.X, pt.Y) + ASSEffect.a(1, Common.ToHex2(255 - pt.Brightness)) + ASSEffect.c(1, "FFFFFF") + ASSEffect.a(3, "FF") + ptstr
                }
                    );
                //if (!first) continue;
                first = false;
                ass_out.Events.Add(
                    new ASSEvent
                {
                    Effect  = "",
                    Layer   = 1,
                    MarginL = "0000",
                    MarginR = "0000",
                    MarginV = "0000",
                    Name    = "NTP",
                    Style   = "pt",
                    Start   = 1,
                    End     = 11,
                    Text    = ASSEffect.pos(pt.X, pt.Y) + ASSEffect.frz(iag) + ASSEffect.t(0, 10, ASSEffect.fry(360 * 5).t()) + ASSEffect.an(7) + ASSEffect.a(1, "F0") + ASSEffect.c(1, "7879F5") + ASSEffect.a(3, "FF") + ASSEffect.bord(0) + ASSEffect.be(1) + @"{\p2}m 0 0 l -200 0 0 2"  //  @"{\p1}m 0 0 l " + xx + " " + yy + " 0 2"
                });
            }

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

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

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

            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(true);

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

                Random rnd = new Random();

                int kSum = 0;

                for (int iK = 0; iK < kelems.Count; iK++)
                {
                    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;

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

                    foreach (ASSPoint pt in mask.Points)
                    {
                        ass_out.Events.Add(
                            ev.StyleReplace("pt").TextReplace(
                                ASSEffect.pos(pt.X, pt.Y) +
                                ASSEffect.a(1, Common.ToHex2(255 - pt.Brightness)) + ASSEffect.c(1, "FFFFFF") + ASSEffect.a(3, "FF") +
                                ptString
                                ));
                    }
                }
            }
            ass_out.SaveFile(OutFileName);
        }
        public void TestMask()
        {
            //Arrange
            string text     = "0912345678";
            string mask     = "1111000111";
            string expected = "0912***678";

            //Act
            string result = StringMask.Mask(text, mask);

            //Assert
            Assert.AreEqual(expected, result);
        }
        public void TestMaskRepeat()
        {
            //Arrange
            string text     = "0912345678";
            string mask     = "100";
            string expected = "0**2**5**8";

            //Act
            string result = StringMask.Mask(text, mask);

            //Assert
            Assert.AreEqual(expected, result);
        }
        public void TestMaskCustom()
        {
            //Arrange
            string text = "*****@*****.**";
            string mask = "1100";

            char[] ignore   = { '.', '@' };
            string expected = "te??12??@g??il.?om";

            //Act
            string result = StringMask.Mask(text, mask, '?', ignore);

            //Assert
            Assert.AreEqual(expected, result);
        }
        public void TestMaskEmail()
        {
            //Arrange
            string text = "*****@*****.**";
            string mask = "1100";

            char[] ignore   = { '.', '@' };
            string expected = "te**12**@g**il.*om";

            //Act
            string result = StringMask.Mask(text, mask, ignore);

            //Assert
            Assert.AreEqual(expected, result);
        }
        public void TestMaskIgnoreRepeat()
        {
            //Arrange
            string text = "0912-345678";
            string mask = "1000";

            char[] ignore   = { '-' };
            string expected = "0***-***6**";

            //Act
            string result = StringMask.Mask(text, mask, ignore);

            //Assert
            Assert.AreEqual(expected, result);
        }
        public override void Run()
        {
            ASS ass_in  = ASS.FromFile(this.InFileName);
            ASS ass_out = new ASS();

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

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

            string s   = "見上げて 祈りさえも";
            int    x0  = 100;
            Random rnd = new Random();

            string[] cols = { "FFFFFF", "FF0000" };
            foreach (char ch in s)
            {
                StringMask mask = GetMask(ch + "", x0, 100);
                x0 += mask.Width + FontSpace;
                foreach (ASSPoint pt in mask.Points)
                {
                    foreach (string col in cols)
                    {
                        ass_out.Events.Add(
                            new ASSEvent
                        {
                            Effect  = "",
                            Layer   = 0,
                            MarginL = "0000",
                            MarginR = "0000",
                            MarginV = "0000",
                            Name    = "NTP",
                            Style   = "Default",
                            Start   = 1,
                            End     = 11,
                            Text    = ASSEffect.pos(pt.X, pt.Y) + ASSEffect.c(1, col) + ASSEffect.t(0, 10, ASSEffect.c(1, cols[0]).t()) + ASSEffect.t(0, Common.RandomDouble(rnd, 10, 20), ASSEffect.a(1, "FFFFFF").t()) + ptStr
                        }
                            );
                    }
                }
                //break;
            }

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

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

            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);
        }
Exemple #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>();

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

            char       ch   = '雨';
            int        x    = 300;
            int        y    = 300;
            double     r0   = 15;
            double     r1   = 30;
            string     col1 = "FFFC94";
            string     col2 = "FF94D1";
            string     col3 = "FFFFFF";
            StringMask mask = GetMask(ch + "", x, y);

            double t0 = 0;
            double t3 = 10;

            ass_out.AppendEvent(0, "Default", t0, t3,
                                ASSEffect.pos(x, y) + ASSEffect.a(1, "FF") + ASSEffect.c(1, col2) +
                                ASSEffect.a(3, "FF") +
                                ch);
            for (int i = 0; i < 1; i++)
            {
                ass_out.AppendEvent(0, "Default", t0, t3,
                                    ASSEffect.pos(x, y) + ASSEffect.a(1, "00") + ASSEffect.c(1, col2) +
                                    ASSEffect.org(x - 200, y) + ASSEffect.t(0, t3 - t0, ASSEffect.fry(-360).t()) +
                                    ASSEffect.a(3, "FF") + ASSEffect.be(1) + ASSEffect.bord(0) +
                                    ASSEffect.t(0, (t3 - t0) * 0.125, ASSEffect.fscx(30).t()) +
                                    ASSEffect.t((t3 - t0) * 0.125, (t3 - t0) * 0.125 * 2, ASSEffect.fscx(100).t()) +
                                    ASSEffect.t(0, (t3 - t0) * 0.25, ASSEffect.fscy(40).t()) +
                                    ASSEffect.bord(1) +
                                    ch);
            }

            /*
             * for (int agi = 0; agi < 360; agi += 20)
             * {
             *  double x0 = x + r0 * Math.Cos(0);
             *  double y0 = y + r0 * Math.Sin(0);
             *  double x1 = x + r1 * Math.Cos(0);
             *  double y1 = y + r1 * Math.Sin(0);
             *
             *  double t0 = 1;
             *  double t1 = t0 + 1.8;
             *
             *  ass_out.AppendEvent(2, "pt", t0, t1,
             *      ASSEffect.an(5) +
             *      ASSEffect.move(x0, y0, x1, y1) + ASSEffect.org(x, y) + ASSEffect.frz(agi) +
             *      ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") +
             *      ASSEffect.a(3, "44") + ASSEffect.c(3, "FFFFFF") +
             *      ASSEffect.t(0, t1 - t0, ASSEffect.frz(agi + 360).t()) +
             *      ASSEffect.ybord(10) + ASSEffect.xbord(0) + ASSEffect.be(1) +
             *      ptstr);
             *
             *  ass_out.AppendEvent(2, "pt", t0, t1,
             *      ASSEffect.an(5) +
             *      ASSEffect.move(x0, y0, x1, y1) + ASSEffect.org(x, y) + ASSEffect.frz(agi) +
             *      ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") +
             *      ASSEffect.a(3, "22") + ASSEffect.c(3, col1) +
             *      ASSEffect.t(0, t1 - t0, ASSEffect.frz(agi + 360).t()) +
             *      ASSEffect.ybord(11) + ASSEffect.xbord(0) + ASSEffect.blur(2) +
             *      ptstr);
             * }
             * */

            ass_out.SaveFile(OutFileName);
        }