public void Run() { ASS ass = ASS.FromFile(InFileName); ass.Shift(Shift); ass.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>(); //Particle2 Par = new Particle2("FFFFFF", "000000", 0, 2, 0.01, 2, -5, 5, -20, 20, 0.5, 2); //ass_out.Events.AddRange(Par.Create(new MovingLinear(0, 2, 0, 240, 848, 240) { MinDY = -10, MaxDY = 10 })); Particle2 Par = new Particle2("FFFFFF", "FFCC33", 0, 2, 0.01, 16, 384, 504, -10, 10, 2, 5) { Star = false, Pt0Size = 2 }; ass_out.Events.AddRange(Par.Create(new MovingArc(0, 2, -100, 240, 848, 240, 60, -1.2, 1.2) { GaussRnd = 3 })); /*for (int i = 0; i < 20; i++) * { * int x0 = i * 32 + 15; * int y0 = 480 - 30; * double t0 = i * 0.3 + 1; * Particle2 Par = new Particle2("FFCC33", "FF0000", t0, t0 + 0.3, 0.003, 1, -10, 10, -10, 10, 0.5, 1) { Star = false, Pt0Size = 3 }; * ass_out.Events.AddRange(Par.Create(new MovingRound(t0, t0 + 0.3, x0, y0, 40, 0) { MinDX = -2, MaxDX = 2, MinDY = 2, MaxDY = 2 })); * }*/ /*Particle2 Par = new Particle2("FFCC33", "FF0000", 1, 1.5, 0.001, 1, -10, 10, -10, 10, 0.5, 1) { Star = false, Pt0Size = 3 }; * ass_out.Events.AddRange(Par.Create(new MovingSinH(1, 1.5, 0, 848, 430, 20, 0.15) { MinDX = -2, MaxDX = 2, MinDY = 2, MaxDY = 2 }));*/ ass_out.SaveFile(OutFileName); }
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; Random rnd = new Random(); for (int i = 0; i < 10; i++) { double bl = (double)i / (double)(10 - 1); string col = Common.scaleColor("FFFFFF", "0000FF", 1 - bl); string alp = Common.scaleAlpha("00", "FF", bl); ass_out.AppendEvent(0, "jp", 0, 5, pos(ox + bl * 2, oy + bl * 2) + a(1, alp) + bord(0) + blur(bl * 2) + c(1, col) + "き"); } ass_out.SaveFile(OutFileName); }
public override void Run() { string ptstr = @"{\p1}m 0 0 l -31 2 -53 10 -67 7 -53 9 -32 1 -41 -2 -49 -2 -54 -1 -49 -3 -41 -3 -46 -7 -49 -23 -45 -8 -41 -4 -32 0 -29 1 -26 1 -23 1 -10 0 -21 -8 -28 -12 -35 -11 -28 -13 -21 -9 -10 -1 -4 -14 5 -19 13 -25 13 -33 18 -37 24 -35 25 -29 23 -34 18 -36 14 -33 14 -25 10 -22 20 -17 20 -9 13 -5 19 -9 19 -17 9 -21 6 -19 -3 -13 -9 -1 0 -1 25 4 43 2 54 15 43 3 36 3 38 12 47 25 37 13 35 4 25 5 12 3 -8 22 -31 25 -41 32 -32 24 -9 21 11 3"; 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 = 424; int oy = 240; Random rnd = new Random(); double tStart = 1; double tEnd = 10; double particlePerSec = 200; string mainCol = "FF205C"; CompositeCurve curve = Line.Create1(424 - 20, 240 - 20, 424 + 20, 240 + 20, 100, tStart, tEnd); for (int iP = 0; iP < particlePerSec * (tEnd - tStart); iP++) { double t0 = Common.RandomDouble(rnd, tStart, tEnd); double life = 0.3; double t1 = t0 + life; double tmpt = (double)iP / (particlePerSec * (tEnd - tStart)) * (tEnd - tStart) + tStart; ASSPointF orgpt = curve.GetPointF(tmpt); double x0 = orgpt.X; double y0 = orgpt.Y; double ag = Common.RandomDouble(rnd, 0, 2 * Math.PI); double r = 40; double x1 = x0 + r * Math.Cos(ag); double y1 = y0 + r * Math.Sin(ag); int tmpz = Common.RandomInt(rnd, 100, 200) * Common.RandomSig(rnd); tmpz = Common.RandomInt(rnd, 0, 359); for (int i = 0; i < 1; i++) { ass_out.AppendEvent(10 + i, "pt", t0, t1, move(x0, y0, x1, y1, 0, life * 0.7) + a(1, "77") + a(3, "DD") + fad(0, life * 0.8) + c(1, mainCol) + c(3, mainCol) + bord(3 - i) + be(3 - i) + fsc(30, 30) + t(life * 0.5, life, fsc(0, 0).t()) + frz(tmpz) + ptstr); } ass_out.AppendEvent(20, "pt", t0, t1, move(x0, y0, x1, y1, 0, life * 0.7) + a(1, "77") + a(3, "DD") + fad(0, life * 0.8) + c(1, "FFFFFF") + c(3, "FFFFFF") + bord(2) + blur(2) + fsc(30, 30) + t(life * 0.5, life, fsc(0, 0).t()) + frz(tmpz) + ptstr); } ass_out.SaveFile(OutFileName); }
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 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"; Bezier bz1 = CreateBezier3(rnd, 300, 300, 200, 100); Bezier bz2 = CreateBezier3(rnd, 300, 300, 200, 100); Bezier[] bz = new Bezier[20]; Line[] li = new Line[bz.Length - 1]; Circle[] cc = new Circle[bz.Length - 1]; for (int i = 0; i < bz.Length; i++) { bz[i] = CreateBezier3(rnd, this.PlayResX / 2, this.PlayResY / 2, this.PlayResX / 2, this.PlayResY / 2); } for (int i = 0; i < li.Length; i++) { li[i] = new Line { X0 = bz[i].P3.X, Y0 = bz[i].P3.Y, X1 = bz[i + 1].P0.X, Y1 = bz[i + 1].P0.Y } } ; for (int i = 0; i < cc.Length; i++) { cc[i] = Circle.Create(bz[i].P3.X, bz[i].P3.Y, bz[i + 1].P0.X, bz[i + 1].P0.Y, Common.RandomBool(rnd, 0.5)); } CompositeCurve cv = new CompositeCurve() { MinT = 0, MaxT = bz.Length + li.Length }; for (int i = 0; i < li.Length; i++) { cv.AddCurve(i * 2, i * 2 + 1, bz[i]); cv.AddCurve(i * 2 + 1, (i + 1) * 2, cc[i]);//li[i]); } cv.AddCurve(li.Length * 2, li.Length * 2 + 1, bz[bz.Length - 1]); foreach (ASSPointF pt in cv.GetPath_Dis(10, 11)) { ass_out.AppendEvent(0, "pt", pt.T, pt.T + 1, ASSEffect.pos(pt.X, pt.Y) + ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") + ASSEffect.a(3, "FF") + ptstr); } 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 ptstr = @"{\p6}m -100 0 l -1 -1 l 0 -100 l 1 -1 l 100 0 l 1 1 l 0 100 l -1 1 c m 10 0 s 0 10 -10 0 0 -10 c"; 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>(); int ox = PlayResX / 2; int oy = PlayResY / 2; Random rnd = new Random(); /* * BaseCurve curve = new Model.Brown { MinT = 0, MaxT = 10, R = 20, X0 = PlayResX / 2, Y0 = PlayResY / 2, Speed = 200 }; * double freq = 250; * foreach (ASSPointF pt in curve.GetPath_DT(1.0 / freq)) * { * ass_out.AppendEvent(0, "pt", pt.T, pt.T + 3, * pos(pt.X, pt.Y) + fad(0.3, 2.3) + * a(1, "DD") + blur(1) + * fsc(1) + t(fsc(70).t()) + frz((int)(pt.T * 360 * 0.3)) + * p(1) + "m -100 -40 l 100 -40 100 40 -100 40 c m -95 -35 l -95 35 95 35 95 -35 c"); * } * */ string ptstr = "m 0 -100 b 133 -100 133 100 0 100 b -3 100 -3 92 0 92 b 123 92 123 -92 0 -92 b -3 -92 -3 -100 0 -100"; for (double ti = 0; ti < 10; ti += 1.0 / 30.0) { int frz0 = Common.RandomInt(rnd, 0, 359); int frz1 = frz0 + 180; string frxys = frx(f1()) + fry(f1()); for (int i = 0; i < 5; i++) { double dt = i * 0.04; string s1 = a(1, "55") + blur(0.7); if (i != 2) { s1 = a(1, "BB") + blur(2); } ass_out.AppendEvent(50, "pt", ti + dt, ti + 2 + dt, pos(ox, oy) + org(ox, oy) + fad(0.7, 1.5) + s1 + frxys + frz(frz0) + t(frz(frz1).t()) + t(fsc(500).t()) + p(4) + ptstr); } } ass_out.SaveFile(OutFileName); }
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; Random rnd = new Random(); Func <double, double, string> f1 = (a, b) => string.Format(" {0} {1}", (int)(Math.Round(a)), (int)(Math.Round(b))); Toy1 toy1 = new Toy1 { OX = 0, OY = 0, V = 50, MinR = 10, MaxR = 100, MinDAG = 0.2, MaxDAG = 0.5, IsSort = false }; toy1.Reset(); double dt = 0.04; for (double t = 0; t < 60; t += dt) { List <ASSPointF> pts = toy1.Next(); string s = @"{\p1}m"; s += f1(pts[0].X, pts[0].Y); s += " l"; for (int i = 1; i < pts.Count; i++) { s += f1(pts[i].X, pts[i].Y); } s += f1(pts[0].X, pts[0].Y); s += f1(pts[1].X, pts[1].Y); s += f1(pts[2].X, pts[2].Y); ass_out.AppendEvent(0, "pt", t, t + dt, ASSEffect.pos(ox, oy) + ASSEffect.an(7) + ASSEffect.a(1, "FF") + ASSEffect.c(1, "FFFFFF") + ASSEffect.a(3, "00") + ASSEffect.c(3, "FFFFFF") + ASSEffect.bord(1) + ASSEffect.be(0) + s); } 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"; string pt1str = @"{\p4}m 0 0 l 50 49 100 0 51 50 100 100 50 51 0 100 49 50 0 0 m 45 45 s 55 45 55 55 45 55 c{\p0}"; double dy = -0.5; double y = 200; int yl = 190; int yh = 210; int ag = 0; for (int x = 100; x <= 700; x++) { if (y == yh) { dy = -0.5; } if (y == yl) { dy = 0.5; } y += dy; ag += 1; double t0 = (double)(x - 100) / 100; ass_out.AppendEvent(0, "pt", t0, t0 + 2, ASSEffect.pos(x, y) + ASSEffect.an(5) + ASSEffect.a(1, "E0") + ASSEffect.c(1, "FFFFFF") + ASSEffect.a(3, "F0") + ASSEffect.c(3, "FFFFFF") + ASSEffect.bord(2) + ASSEffect.be(1) + ASSEffect.frx(ag) + ASSEffect.fry(ag) + ASSEffect.frz(ag) + ASSEffect.fad(0, 2) + ASSEffect.t(0, 2, ASSEffect.fsc(500, 500).t()) + pt1str); } ass_out.SaveFile(OutFileName); }
public override void Run() { 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); }
public override void Run() { ASS ass_in = ASS.FromFile(this.InFileName); ASS ass_out = new ASS(); ass_out.Header = ass_in.Header; ass_out.Events = new List <ASSEvent>(); Random rnd = new Random(); for (int iEv = 0; iEv < ass_in.Events.Count; iEv++) { ASSEvent ev = ass_in.Events[iEv]; List <KElement> kelems = ev.SplitK(false); this.MaskStyle = "Style: Default,DFGMaruGothic-Md,35,&H00FF0000,&HFF000000,&HFFFFFFFF,&HFFFF0000,-1,0,0,0,100,100,2,0,1,2,0,5,25,25,25,128"; int x0 = MarginLeft; int startx0 = x0; int y0 = PlayResY - MarginBottom - FontHeight; int kSum = 0; for (int iK = 0; iK < kelems.Count; iK++) { Console.WriteLine("{0} / {1} : {2} / {3}", iEv + 1, ass_in.Events.Count, iK + 1, kelems.Count); KElement ke = kelems[iK]; Size sz = GetSize(ke.KText); double kStart = ev.Start + kSum * 0.01; double kEnd = kStart + ke.KValue * 0.01; kSum += ke.KValue; int x = x0 + this.FontSpace + sz.Width / 2; int y = y0 + FontHeight / 2; int x_an7 = x0; int y_an7 = y0; StringMask mask = GetMask(ke.KText, x, y); x0 += this.FontSpace + sz.Width; if (ke.KText.Trim().Length == 0) { continue; } } } ass_out.SaveFile(OutFileName); Console.WriteLine("Lines : {0}", ass_out.Events.Count); }
public override void Run() { ASS ass_in = ASS.FromFile(this.InFileName); ASS ass_out = new ASS(); ass_out.Header = ass_in.Header; ass_out.Events = new List <ASSEvent>(); int c = IntAdd(2, 3); Random rnd = new Random(); //string s = TestHelloWorld(); string fn = "FA 瑞筆行書M"; string ss = ""; char[] cc = new char[10000]; int cclen = 1; bool b1 = GetOutline(cc, ref cclen, '々', Encoding.Unicode.GetChars(Encoding.Unicode.GetBytes(fn)), 128, 30 * 8, 1000, 564, 424 * 8, 240 * 8); for (int i = 0; i < cclen; i++) { ss += cc[i]; } //ass_out.AppendEvent(0, "pt", 0, 1, ASSEffect.pos(424, 240) + @"{\an7\p4}" + ss); ass_out.AppendEvent(0, "pt", 0, 10, ASSEffect.pos(0, 0) + @"{\an7\clip(4," + ss + @")\1a&H77&\p1} m -1000 -1000 l 1000 -1000 1000 1000 -1000 1000"); for (int i = 0; i < 10; i++) { ASSColor co = Common.RandomColor(rnd, 1, ASSColor.FromBBGGRR(1, "000000"), ASSColor.FromBBGGRR(1, "FFFFFF")); ass_out.AppendEvent(1, "pt", (double)i * 0.5, (double)i * 0.5 + 1, ASSEffect.move(400, 0, 500, 0) + ASSEffect.c(1, co.ToColString()) + ASSEffect.c(3, co.ToColString()) + @"{\an7\clip(4," + ss + @")\1a&H00&\3a&H00&\bord25\blur25\p1} m 0 0 l 1 0 1 480 0 480"); } /* ass_out.AppendEvent(0, "pt", 0, 10, * ASSEffect.pos(0, 0) + @"{\an7\p1}m -1000 240 l 1000 240 1000 241 -1000 241" * ); * ass_out.AppendEvent(0, "pt", 0, 10, * ASSEffect.pos(0, 0) + @"{\an7\p1}m 424 -1000 l 425 -1000 425 1000 424 1000" * ); * ass_out.AppendEvent(0, "Default", 1, 10, * ASSEffect.pos(0, 0) + ASSEffect.an(7) + '々');*/ ass_out.SaveFile(OutFileName); }
public override void Run() { string ptstr = @"{\p1}m 0 0 l 1 0 1 1 0 1"; string lstr0 = @"{\p1}m -1 0 l 0 -50 0 0"; string lstr1 = @"{\p1}m -1 0 l 0 0 0 50"; ASS ass_in = ASS.FromFile(this.InFileName); ASS ass_out = new ASS(); ass_out.Header = ass_in.Header; ass_out.Events = new List <ASSEvent>(); int ox = 300; int oy = 300; Random rnd = new Random(); string lcol = "00C6FF"; for (int count = 0; count < 50; count++) { double t0 = 2 + Common.RandomDouble(rnd, 0, 1); double t1 = t0 + 1; double x0 = Common.RandomDouble(rnd, ox - 10, ox + 10); double x1 = Common.RandomDouble(rnd, ox - 20, ox + 20); //if (Common.RandomBool(rnd, 0.5)) x1 = ox - 20; else x1 = ox + 20; int startag = Common.RandomInt(rnd, 0, 90); ass_out.AppendEvent(5, "pt", t0, t1, ASSEffect.fad(0.2, 0) + ASSEffect.move(x0, oy, x1, oy) + ASSEffect.a(1, "00") + ASSEffect.c(1, lcol) + ASSEffect.a(3, "FF") + ASSEffect.frx(startag) + ASSEffect.t(0, t1 - t0, ASSEffect.frx(90).t()) + lstr0); ass_out.AppendEvent(5, "pt", t0, t1, ASSEffect.fad(0.2, 0) + ASSEffect.move(x0, oy, x1, oy) + ASSEffect.a(1, "00") + ASSEffect.c(1, lcol) + ASSEffect.a(3, "FF") + ASSEffect.frx(startag) + ASSEffect.t(0, t1 - t0, ASSEffect.frx(90).t()) + lstr1); } ass_out.SaveFile(OutFileName); }
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>(); ass_out.AppendEvent(50, "pt", 0, 10, pos(0, 0) + t(0, 10, 2, fscy(48000).t()) + ptstr + "\\N" + r() + t(fscx(84800).t()) + ptstr + r() + a(1, "44") + a(3, "44") + bord(2) + blur(2) + ptstr); ass_out.SaveFile(OutFileName); }
void PreConvert(string infile) { ASS ass1 = ASS.FromFile(infile); FileInfo tcfi = new FileInfo(infile); string inbakname = infile + ".bak"; if (File.Exists(inbakname)) { File.Delete(inbakname); } tcfi.CopyTo(inbakname); ASS ass2 = ASS.FromFile(infile); ass2.Events.Clear(); for (int i = 0; i < ass1.Events.Count; i++) { if (ass1.Events[i].Text.IndexOf("PopSub注释") >= 0) { continue; } if (ass1.Events[i].Text.IndexOf("PopSub注釋") >= 0) { continue; } if (ass1.Events[i].Text.IndexOf(@"{\fs24\an8}") == 0) { ass1.Events[i].Text = ass1.Events[i].Text.Replace(@"{\fs24\an8}", ""); ass1.Events[i].Style = "an8"; } if (ass1.Events[i].Style.Contains("Default")) { ass1.Events[i].Text = ass1.Events[i].Text.Replace(",", " ").Replace("。", " "); } ass2.Events.Add(ass1.Events[i]); } ass2.SaveFile(infile); }
public string Filename2 = @"G:\Workshop\kiddy girl and\11\11.cht.ass"; // dest, cht public override void Run() { FileInfo fi2 = new FileInfo(Filename2); //fi2.CopyTo(Filename2 + ".bak"); ASS ass1 = ASS.FromFile(Filename1); ASS ass2 = ASS.FromFile(Filename2); for (int i = 0; i < ass1.Events.Count && i < ass2.Events.Count; i++) { ass2.Events[i].Start = ass1.Events[i].Start; ass2.Events[i].End = ass1.Events[i].End; continue; if (ass1.Events[i].Text.Trim() != ToSimplified(ass2.Events[i].Text.Trim())) { Console.WriteLine("----------------Warning----------------"); Console.WriteLine(ass1.Events[i].ToString()); Console.WriteLine(ass2.Events[i].ToString()); } } ass2.SaveFile(Filename2); }
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>(); for (int iEv = 0; iEv < ass_in.Events.Count; iEv++) { ASSEvent ev = ass_in.Events[iEv]; List <KElement> kelems = ev.SplitK(iEv > 130); StringBuilder sb = new StringBuilder(); int kSum = 30; ev.Start -= 0.3; for (int iK = 0; iK < kelems.Count; iK++) { KElement ke = kelems[iK]; double kStart = kSum * 0.01; sb.Append( ASSEffect.be(1) + ASSEffect.a(3, "FF") + ASSEffect.a(1, "FF") + ASSEffect.t(0, 0.3, ASSEffect.a(3, "00").t() + ASSEffect.a(1, "00").t()) + //ASSEffect.t(kStart, kStart + 0.3, ASSEffect.a(1, "77").t()) + ASSEffect.t(kStart + 0, kStart + 0.5, ASSEffect.a(1, "FF").t() + ASSEffect.a(3, "FF").t()) + ke.KText + ASSEffect.r() ); kSum += ke.KValue; if (ev.Last < kStart + 1.0) { ev.End += (kStart + 1.0 - ev.Last); } } ass_out.Events.Add(ev.LayerReplace(iEv).TextReplace(sb.ToString())); } 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>(); for (int i = 0; i <= 10 * 100; i += 10) { double t0 = (double)i * 0.01; double t1 = t0 + 0.1; string s = t0.ToString("00.00"); if (i < 5 * 100) { s = ((int)t0).ToString("00") + ".00"; } ass_out.AppendEvent(0, "Default", t0, t1, an(5) + pos(PlayResX / 2, PlayResY / 2) + "00:00:" + s); } ass_out.SaveFile(OutFileName); }
/// <summary> /// Recognization loop based on tag and implementation on idefaultmodule. /// </summary> private static void ModuleRecognization() { foreach (Assembly ASS in AppDomain.CurrentDomain.GetAssemblies()) { foreach (Type Type in ASS.GetTypes()) { if (Type.GetCustomAttributes(typeof(BeagleModule), true).Length > 0) { if (Assembly.GetEntryAssembly() != ASS) { Log.Success("Module {0} recognized.", Type.Module.Name.Replace(".dll", "")); } else { Log.Success("Application initialized based on {0} module.", Type.Module.Name.Replace(".exe", "").Replace(".dll", "")); } try { Modules.Add(ASS, new RecognizedBeagleModule(Type, (DefaultModule)Activator.CreateInstance(Type))); } catch (ArgumentException) { string Ex = "Possible duplicate [BeagleModule] attribute on class, this may be caused because DefaultModule.cs has declared a [BeagleModule] attribute."; Log.Exception(Ex); throw new ArgumentException(Ex); } catch (InvalidCastException) { string Ex = "Cast to DefaultModule error. Check if the Module class of {0} has a DefaultClass as base class. Use inheritance of Default class instead implements raw IDefaultModule interface."; Log.Exception(Ex); throw new InvalidCastException(Ex); } } } } }
public override int Eval(Stack st) { return(ASS.lambdap(st, Operator.get("/").Lambda)); }
public override int Eval(Stack st) { return(ASS.lambdai(st, false, true)); }
public override void Run() { ASS ass_in = ASS.FromFile(this.InFileName); ASS ass_out = new ASS() { Header = ass_in.Header, Events = new List <ASSEvent>() }; for (int iEv = 0; iEv < ass_in.Events.Count; iEv++) { ASSEvent ev = ass_in.Events[iEv]; List <KElement> kelems = ev.SplitK(false); int sw = GetTotalWidth(ev); int x0 = (PlayResX - sw) / 2; int xxx = x0; int y0 = PlayResY - MarginBottom - FontHeight; int kSum = 0; for (int iK = 0; iK < kelems.Count; iK++) { Console.WriteLine("{0} / {1} : {2} / {3}", iEv + 1, ass_in.Events.Count, iK + 1, kelems.Count); KElement ke = kelems[iK]; Size sz = GetSize(ke.KText); double kStart = ev.Start + kSum * 0.01; double kEnd = kStart + ke.KValue * 0.01; kSum += ke.KValue; int x = x0 + this.FontSpace + sz.Width / 2; int y = y0 + FontHeight / 2; int x_an7 = x0; int y_an7 = y0; StringMask mask = GetMask(ke.KText, x, y); x0 += this.FontSpace + sz.Width; if (ke.KText.Trim().Length == 0) { continue; } double t0 = ev.Start - 0.5 + iK * 0.05; double t1 = t0 + 0.3; double t2 = kStart - 0.07; double t3 = kEnd; double t4 = ev.End - 0.5 + iK * 0.05; double t5 = t4 + 0.3; Func <double, string> fMainColor = ti => (ti < t2) ? Common.scaleColor("FFFFFF", "000000", (ti - t1) / 0.2) : "FFFFFF"; Func <double, string> fMainAlpha = ti => (ti < t2) ? "55" : "00"; ass_out.AppendEvent(60, "jp", t0, t1, move(x - 100, y, x, y) + a(1, "55") + fsc(150, 150) + fad(t1 - t0, 0) + frx(Common.RandomInt(rnd, 200, 500)) + fry(Common.RandomInt(rnd, 200, 500)) + frz(Common.RandomInt(rnd, 200, 500)) + t(frx(0).t() + fry(0).t() + frz(0).t() + fsc(100, 100).t()) + ke.KText); ass_out.AppendEvent(55, "jp", t2, t2 + 0.25, pos(x, y) + a(1, "00") + bord(8) + blur(8) + fad(0, 0.18) + a(3, "00") + ke.KText); { double ti = t1; while (ti < t4) { double ti1 = ti + 0.04; ass_out.AppendEvent(50, "jp", ti, ti1 + 0.04, pos(Common.RandomInt(rnd, x - 3, x + 3), Common.RandomInt(rnd, y - 3, y + 3)) + a(1, fMainAlpha(ti)) + fad(0, Common.RandomDouble(rnd, 0.04, 0.09)) + c(1, fMainColor(ti)) + ke.KText); ti = ti1; } ass_out.AppendEvent(60, "jp", ti, t5, move(x, y, x + 100, y) + a(1, "00") + fad(0, t5 - ti) + c(1, "FFFFFF") + t(frx(Common.RandomInt(rnd, 200, 500)).t() + fry(Common.RandomInt(rnd, 200, 500)).t() + frz(Common.RandomInt(rnd, 200, 500)).t() + fsc(150, 150).t()) + ke.KText); } string cShad = "000000"; for (int i = 0; i < 2; i++) { ass_out.AppendEvent(40, "jp", t1, t4, pos(x, y) + a(1, "00") + blur(2) + c(1, cShad) + ke.KText); } { CompositeCurve curve = new CompositeCurve { MinT = t2 - 0.1, MaxT = t2 + 0.1 }; double ptag = Common.RandomDouble(rnd, 0, Math.PI); double ptr = 100; double ptx0 = x + Math.Cos(ptag) * ptr; double pty0 = y - Math.Sin(ptag) * ptr; double ptx1 = x - Math.Cos(ptag) * ptr; double pty1 = y + Math.Sin(ptag) * ptr; Line line = new Line { X0 = ptx0, Y0 = pty0, X1 = ptx1, Y1 = pty1 }; curve.AddCurve(curve.MinT, curve.MaxT, line); List <ASSPointF> pts = curve.GetPath_Dis(1, 1.2); foreach (ASSPointF pt in pts) { if (!Common.InRange(0, PlayResX, pt.X) || !Common.InRange(0, PlayResY, pt.Y)) { continue; } ass_out.AppendEvent(30, "pt", pt.T, pt.T + 0.25, pos(pt.X, pt.Y) + a(1, "00") + a(3, "77") + c(1, "FFD9A1") + c(3, "FFD9A1") + fad(0, 0.1) + bord(4) + blur(4) + t(bord(2).t() + blur(2).t()) + p(1) + "m 0 0 l 1 0 1 1 0 1"); ass_out.AppendEvent(32, "pt", pt.T, pt.T + 0.25, pos(pt.X, pt.Y) + a(1, "00") + a(3, "44") + c(1, "FFFFFF") + c(3, "FFFFFF") + fad(0, 0.1) + bord(2.5) + blur(2.5) + t(bord(1.3).t() + blur(1.3).t()) + p(1) + "m 0 0 l 1 0 1 1 0 1"); } pts = curve.GetPath_DT(0.01); foreach (ASSPointF pt in pts) { if (!Common.InRange(0, PlayResX, pt.X) || !Common.InRange(0, PlayResY, pt.Y)) { continue; } ass_out.AppendEvent(35, "pt", pt.T, pt.T + 0.01, pos(pt.X, pt.Y) + a(1, "00") + a(3, "00") + c(1, "FFFFFF") + c(3, "FFFFFF") + bord(13) + blur(13) + p(1) + "m 0 0 l 1 0 1 1 0 1"); } } } } Console.WriteLine(ass_out.Events.Count); ass_out.SaveFile(this.OutFileName); }
public override void Run() { ASS ass_in = ASS.FromFile(this.InFileName); ASS ass_out = new ASS(); ass_out.Header = ass_in.Header; ass_out.Events = new List <ASSEvent>(); this.Font = new System.Drawing.Font("FA 瑞筆行書M", 13); Particle pt = new Particle { AreaHeight = 80, AreaWidth = 200, IsRandomColor = true, Color = new ASSColor { A = 0, R = 255, G = 255, B = 255, Index = 1 }, Color1 = new ASSColor { A = 0, R = 255, G = 255, B = 255, Index = 1 }, Color2 = new ASSColor { A = 0, R = 0xEF, G = 0xF7, B = 0xFB, Index = 1 }, Count = 100, FontSize = this.FontHeight, MinLast = 1, MaxLast = 2, IsMove = true, MoveStyle = 2, IsPatternScale = false, PatternScaleX = 250, PatternScaleY = 250, ParticlePattern = ParticlePatternType.o, Style = "pt", XOffset = 0, YOffset = 0, IsRotate = true, BE = 1 }; for (int i = 0; i < 20; i++) { if (i >= 10) { this.Font = new System.Drawing.Font("華康行書體(P)", 13); } ASSEvent ev = ass_in.Events[i]; List <KElement> kelems = ev.SplitK(false); int sumw = GetTotalWidth(ev); int x0 = (PlayResX - MarginLeft - MarginRight - sumw) / 2 + MarginLeft; int kSum = 0; for (int ik = 0; ik < kelems.Count; ik++) { KElement elem = kelems[ik]; Size sz = this.GetSize(elem.KText); int x = x0; x0 += sz.Width + this.FontSpace; int y = PlayResY - MarginBottom; if (i >= 10) { y = MarginTop + FontHeight; } double kStart = (double)kSum * 0.01; double kEnd = (double)(kSum + elem.KValue) * 0.01; kEnd = kStart + 0.6; double kMid = (kStart + kEnd) * 0.5; double kQ1 = kStart + (kEnd - kStart) * 0.1; double r = (double)ik / (double)(kelems.Count - 1); double r0 = 1.0 - r; int fd_xof = (int)((double)(ik - (kelems.Count - 1) / 2) / (double)(kelems.Count - 1) * (double)PlayResX * 0.2); // particle need an7 position pt.X = x; pt.Y = y - FontHeight; pt.Start = ev.Start + kStart; pt.End = ev.Start + kEnd; // an7 -> an5 x += FontWidth / 2; y -= FontHeight / 2; // 提前1秒出现 ass_out.Events.Add(ev.StartReplace(ev.Start - r0 * 1.0).TextReplace( ASSEffect.fad(0.3, 0) + ASSEffect.be(1) + ASSEffect.pos(x, y) + ASSEffect.an(5) + ASSEffect.t(kStart + r0 * 1.0, kEnd + r0 * 1.0, ASSEffect.be(10).t() + ASSEffect.a(1, "FF").t()) + ASSEffect.t(kStart + r0 * 1.0 + 0.2, kEnd + r0 * 1.0, ASSEffect.a(3, "FF").t()) + elem.KText)); ass_out.Events.AddRange(pt.Create()); kSum += elem.KValue; } } ass_out.SaveFile(OutFileName); }
public override void Run() { ASS ass_in = ASS.FromFile(this.InFileName); ASS ass_out = new ASS() { Header = ass_in.Header, Events = new List <ASSEvent>() }; for (int iEv = 0; iEv < ass_in.Events.Count; iEv++) { bool isJp = true; //if (iEv > 1) continue; this.MaskStyle = isJp ? "Style: Default,DFMincho-UB,38,&H00FFFFFF,&HFFFFFFFF,&HFFFFFFFF,&HFFFFFFFF,0,0,0,0,100,100,0,0,0,0,0,5,0,0,0,128" : "Style: Default,汉仪粗宋繁,38,&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(false); int x0 = (PlayResX - GetTotalWidth(ev) - MarginLeft - MarginRight) / 2 + MarginLeft; int x0_start = x0; int y0 = MarginTop; int kSum = 0; for (int iK = 0; iK < kelems.Count; iK++) { Console.WriteLine("{0} / {1} : {2} / {3}", iEv + 1, ass_in.Events.Count, iK + 1, kelems.Count); KElement ke = kelems[iK]; Size sz = GetSize(ke.KText); double kStart = ev.Start + kSum * 0.01; double kEnd = kStart + ke.KValue * 0.01; kSum += ke.KValue; int x = x0 + this.FontSpace + sz.Width / 2; int y = y0 + FontHeight / 2; int x_an7 = x0 + 2; int y_an7 = y0; StringMask mask = GetMask(ke.KText, x, y); x0 += this.FontSpace + sz.Width; if (ke.KText.Trim().Length == 0) { continue; } string evStyle = "jp"; double t0 = ev.Start - 0.5 + iK * 0.1; double t1 = t0 + 0.5; double t2 = kStart; double t3 = kEnd; double t4 = ev.End - 0.5 + iK * 0.1; double t5 = t4 + 0.5; string[,] bordColors = { { "FFB9A8", "BC5237", "6B1905" }, // {"FFE1DA","FFBCAB","EF6C4B"}, { "FFB9A8", "BC5237", "6B1905" }, { "AFAFFF", "595AF1", "595AF1" }, { "AFAFFF", "595AF1", "595AF1" }, { "8DEDFF", "5CCFFF", "2BABF5" }, { "8DEDFF", "5CCFFF", "2BABF5" }, { "8DEDFF", "5CCFFF", "2BABF5" }, { "AFAFFF", "595AF1", "595AF1" }, { "AFAFFF", "595AF1", "595AF1" }, { "FFB9A8", "BC5237", "6B1905" }, { "AFAFFF", "595AF1", "595AF1" } }; string MainColor = bordColors[iEv, 2]; for (int i = -20; i <= 20; i++) // 50 - 70 { //string col = Common.scaleColor(MainColor, "FFFFFF", 1.0 - Math.Pow((double)Math.Abs(i) / 20.0, 2)); string col = i == 0 ? "FFFFFF" : MainColor; col = Common.scaleColor(MainColor, "FFFFFF", 1.0 - Math.Pow((double)Math.Abs(i) / 20.0, 3)); string alp = i == 0 ? "DD" : "DD"; ass_out.AppendEvent(70 - Math.Abs(i), evStyle, t0, t1, move(x + i * 2, y, x, y) + fad(0.15, 0) + a(1, "DD") + c(1, col) + blur(Math.Abs(i) * 0.2) + ke.KText); /*ass_out.AppendEvent(70 - Math.Abs(i), evStyle, t1, t4, * pos(x + i * 0.06, y) + * a(1, "DD") + c(1, col) + blur(Math.Abs(i) * 0.2) + * ke.KText);*/ { // t1 - t4 double ptt0 = t2; double ptt1 = t2; double ptt2 = t2; double ptt3 = t3 + 0.1; if (ptt3 > t4) { ptt3 = t4; } if (ptt1 > t4) { ptt1 = ptt2 = ptt3; } else if (ptt1 > ptt2) { ptt2 = ptt3; } ass_out.AppendEvent(70 - Math.Abs(i), evStyle, t1, ptt0, pos(x + i * 0.06, y) + a(1, alp) + c(1, col) + blur(Math.Abs(i) * 0.2) + ke.KText); ass_out.AppendEvent(70 - Math.Abs(i), evStyle, ptt0, ptt1, pos(x + i * 0.06, y) + a(1, alp) + c(1, col) + blur(Math.Abs(i) * 0.2) + t(fsc(130, 130).t()) + ke.KText); ass_out.AppendEvent(70 - Math.Abs(i), evStyle, ptt1, ptt2, pos(x + i * 0.06, y) + a(1, alp) + c(1, col) + blur(Math.Abs(i) * 0.2) + fsc(130, 130) + ke.KText); ass_out.AppendEvent(70 - Math.Abs(i), evStyle, ptt2, ptt3, pos(x + i * 0.06, y) + a(1, alp) + c(1, col) + blur(Math.Abs(i) * 0.2) + fsc(130, 130) + t(fsc(100, 100).t()) + ke.KText); ass_out.AppendEvent(70 - Math.Abs(i), evStyle, ptt3, t4, pos(x + i * 0.06, y) + a(1, alp) + c(1, col) + blur(Math.Abs(i) * 0.2) + ke.KText); if (i == 0) { { double[] timeSegs = { t0 + 0.2, ptt0, ptt1, ptt2, ptt3, t5 - 0.2 }; string[] addStrs = { fad(0.8, 0), t(fsc(130, 130).t()), fsc(130, 130), fsc(130, 130) + t(fsc(100, 100).t()), fad(0, 0.8) }; for (int j = 0; j + 1 < timeSegs.Length; j++) { ass_out.AppendEvent(39, evStyle, timeSegs[j], timeSegs[j + 1], pos(x, y) + a(3, "33") + c(3, bordColors[iEv, 0]) + bord(3) + blur(3) + addStrs[j] + ke.KText); ass_out.AppendEvent(38, evStyle, timeSegs[j], timeSegs[j + 1], pos(x, y) + a(3, "33") + c(3, bordColors[iEv, 1]) + bord(5) + blur(5) + addStrs[j] + ke.KText); //if (new int[] { 0, 2, 3, 6, 7 }.Contains(iEv)) continue; ass_out.AppendEvent(37, evStyle, timeSegs[j], timeSegs[j + 1], pos(x, y) + a(3, "33") + c(3, bordColors[iEv, 2]) + bord(8) + blur(8) + addStrs[j] + ke.KText); } } /* * ass_out.AppendEvent(29, evStyle, t0, ptt0, * pos(x + i * 0.06 + 3, y + 3) + fad(0.3, 0) + * a(1, "66") + c(1, "000000") + blur(2) + * ke.KText); * ass_out.AppendEvent(29, evStyle, ptt0, ptt1, * pos(x + i * 0.06 + 3, y + 3) + * a(1, "66") + c(1, "000000") + blur(2) + t(fsc(130, 130).t()) + * ke.KText); * ass_out.AppendEvent(29, evStyle, ptt1, ptt2, * pos(x + i * 0.06 + 3, y + 3) + * a(1, "66") + c(1, "000000") + blur(2) + fsc(130, 130) + * ke.KText); * ass_out.AppendEvent(29, evStyle, ptt2, ptt3, * pos(x + i * 0.06 + 3, y + 3) + * a(1, "66") + c(1, "000000") + blur(2) + fsc(130, 130) + t(fsc(100, 100).t()) + * ke.KText); * ass_out.AppendEvent(29, evStyle, ptt3, t5, * pos(x + i * 0.06 + 3, y + 3) + fad(0, 0.3) + * a(1, "66") + c(1, "000000") + blur(2) + * ke.KText); * */ } } ass_out.AppendEvent(70 - Math.Abs(i), evStyle, t4, t5, move(x + i * 0.06, y, x + i * 2, y) + fad(0, 0.15) + a(1, "DD") + c(1, col) + blur(Math.Abs(i) * 0.2) + ke.KText); } } } 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(); ass_out.Header = ass_in.Header; ass_out.Events = new List <ASSEvent>(); ass_out.Events.Add(ass_in.Events[0]); this.Font = new System.Drawing.Font("DFGRuLeiA-W5", 13); Particle pt = new Particle { AreaHeight = 50, AreaWidth = 100, IsRandomColor = false, Color = new ASSColor { A = 0, R = 255, G = 255, B = 255, Index = 1 }, Count = 10, FontSize = this.FontHeight, MinLast = 1, MaxLast = 2, IsMove = true, IsPatternScale = true, PatternScaleX = 250, PatternScaleY = 250, ParticlePattern = ParticlePatternType.Circle, Style = "particle", XOffset = 0, YOffset = 0, IsRotate = false, }; for (int i = 1; i <= 15; i++) { ASSEvent ev = ass_in.Events[i]; List <KElement> kelems = ev.SplitK(false); int sumw = GetTotalWidth(ev); int x0 = (PlayResX - MarginLeft - MarginRight - sumw) / 2 + MarginLeft; int kSum = 0; for (int ik = 0; ik < kelems.Count; ik++) { KElement elem = kelems[ik]; Size sz = this.GetSize(elem.KText); int x = x0; x0 += sz.Width + this.FontSpace; int y = MarginTop; string color = Common.scaleColor("7A93EB", "6939C8", (double)ik / (double)(kelems.Count - 1)); double kStart = (double)kSum * 0.01; double kEnd = (double)(kSum + elem.KValue) * 0.01; double kMid = (kStart + kEnd) * 0.5; double kQ1 = kStart + (kEnd - kStart) * 0.25; // an7 -> an5 int x5 = x + sz.Width / 2; int y5 = y + sz.Height / 2; ass_out.Events.Add(ev.TextReplace(ASSEffect.pos(x5, y5) + ASSEffect.c(1, color) + ASSEffect.t(0, 0.001, ASSEffect.c(1, "555555").t()) + ASSEffect.t(kStart, kQ1, ASSEffect.c(1, "FFFFFF").t() + ASSEffect.fsc(170, 170).t()) + ASSEffect.t(kQ1, kEnd, ASSEffect.c(1, color).t() + ASSEffect.fsc(100, 100).t()) + elem.KText)); pt.X = x; pt.Y = y; pt.Start = ev.Start + kStart; pt.End = ev.Start + kEnd; ass_out.Events.AddRange(pt.Create()); kSum += elem.KValue; } } for (int i = 16; i <= 30; i++) { ass_out.Events.Add(ass_in.Events[i]); } ass_out.SaveFile(this.OutFileName); }
public override void Run() { ASS ass_in = ASS.FromFile(this.InFileName); ASS ass_out = new ASS(); ass_out.Header = ass_in.Header; ass_out.Events = new List <ASSEvent>(); string ptString = @"{\p8}m 0 0 l 128 0 128 128 0 128"; string[] colString = { "4BFCCC", "CE8046", "52065D", "8F0036", "33AE52", "6ADB57" }; colString = colString.Select(s => ASSColor.HtmlToASS(s)).ToArray(); for (int iEv = 0; iEv < ass_in.Events.Count; iEv++) { Console.WriteLine("{0} / {1}", iEv + 1, ass_in.Events.Count); ASSEvent ev = ass_in.Events[iEv]; List <KElement> kelems = ev.SplitK(true); /// an7 pos int x0 = (PlayResX - GetTotalWidth(ev)) / 2; int y0 = PlayResY - MarginBottom - FontHeight; Random rnd = new Random(); int kSum = 0; string col0 = colString[iEv % colString.Length]; string col1 = (iEv >= 7 && iEv <= 10) ? "CCCCCC" : "CCCCCC"; string col20 = "FFFFFF"; string col21 = "CCCCCC"; string col22 = "888888"; string col23 = "444444"; string col24 = "111111"; if (iEv >= 7 && iEv <= 10) { col20 = "111111"; col21 = "444444"; col23 = "CCCCCC"; col24 = "FFFFFF"; } for (int iK = 0; iK < kelems.Count; iK++) { KElement ke = kelems[iK]; double r = (double)iK / (double)(kelems.Count - 1); Size sz = GetSize(ke.KText); /// an5 pos int x = x0 + this.FontSpace + sz.Width / 2; int y = y0 + FontHeight; int mask_x0 = x0 + 2; int mask_y0 = y0 + 0; StringMask mask = GetMask(ke.KText, mask_x0, mask_y0); if (ke.KText == "ト") { mask = GetMask(ke.KText, mask_x0 + 3, mask_y0); } if (ke.KText == "ル") { mask = GetMask(ke.KText, mask_x0 + 1, mask_y0); } if (ke.KText == "ば") { mask = GetMask(ke.KText, mask_x0 + 1, mask_y0); } if (ke.KText == "し") { mask = GetMask(ke.KText, mask_x0 + 1, mask_y0); } if (ke.KText == "ダ") { mask = GetMask(ke.KText, mask_x0 + 1, mask_y0); } if (ke.KText == "ユ") { mask = GetMask(ke.KText, mask_x0 + 1, mask_y0); } if (ke.KText == "ン") { mask = GetMask(ke.KText, mask_x0, mask_y0); } if (ke.KText == "ざ") { mask = GetMask(ke.KText, mask_x0, mask_y0); } if (ke.KText == "に") { mask = GetMask(ke.KText, mask_x0 - 1, mask_y0); } if (ke.KText == "浮") { mask = GetMask(ke.KText, mask_x0 - 1, mask_y0); } if (ke.KText == "な") { mask = GetMask(ke.KText, mask_x0 - 1, mask_y0); } if (ke.KText == "く") { mask = GetMask(ke.KText, mask_x0 - 1, mask_y0); } if (ke.KText == "の") { mask = GetMask(ke.KText, mask_x0 - 1, mask_y0); } if (ke.KText == "肩") { mask = GetMask(ke.KText, mask_x0 - 1, mask_y0); } if (ke.KText == "を") { mask = GetMask(ke.KText, mask_x0 - 1, mask_y0); } if (ke.KText == "て") { mask = GetMask(ke.KText, mask_x0 - 1, mask_y0); } if (ke.KText == "テ") { mask = GetMask(ke.KText, mask_x0 - 1, mask_y0); } if (ke.KText == "熱") { mask = GetMask(ke.KText, mask_x0 - 1, mask_y0); } if (ke.KText == "る") { mask = GetMask(ke.KText, mask_x0 - 1, mask_y0); } if (ke.KText == "こ") { mask = GetMask(ke.KText, mask_x0 - 1, mask_y0); } if (ke.KText == "読") { mask = GetMask(ke.KText, mask_x0 - 1, mask_y0); } if (ke.KText == "ま") { mask = GetMask(ke.KText, mask_x0 - 1, mask_y0); } if (ke.KText == "さ") { mask = GetMask(ke.KText, mask_x0 - 1, mask_y0); } if (ke.KText == "波") { mask = GetMask(ke.KText, mask_x0 - 1, mask_y0); } if (ke.KText == "時") { mask = GetMask(ke.KText, mask_x0 - 1, mask_y0); } if (ke.KText == "間") { mask = GetMask(ke.KText, mask_x0 - 1, mask_y0); } if (ke.KText == "柄") { mask = GetMask(ke.KText, mask_x0 - 1, mask_y0); } if (ke.KText == "焼") { mask = GetMask(ke.KText, mask_x0 - 1, mask_y0); } x0 += this.FontSpace + sz.Width; y0 = y0; double kStart = ev.Start + kSum * 0.01; kSum += ke.KValue; double kEnd = ev.Start + kSum * 0.01; double t0 = ev.Start + r * 1.0 - 1.0; double t1 = t0 + 0.2; double t2 = t0 + 0.4; double t3 = t0 + 0.6; double t4 = t0 + 0.8; double t5 = kStart - 0.1; double t6 = kStart + 0.05; double t7 = kStart + 0.15; double t8 = kStart + 0.3; double t9 = ev.End + r * 1.0 - 1.0; double tA = t9 + 0.4; ass_out.Events.Add( ev.StyleReplace("bd").StartReplace(t5).EndReplace(t7).TextReplace( ASSEffect.pos(x, y) + ASSEffect.fad(t6 - t5, 0) + ASSEffect.bord(15) + ASSEffect.a(1, "FF") + ASSEffect.c(3, col0) + ASSEffect.blur(10) + ke.KText)); ass_out.Events.Add( ev.StyleReplace("bd").StartReplace(t7).EndReplace(t8 + 0.15).TextReplace( ASSEffect.pos(x, y) + ASSEffect.bord(15) + ASSEffect.fad(0, t8 + 0.15 - t7) + ASSEffect.a(1, "FF") + ASSEffect.c(3, col0) + ASSEffect.blur(10) + ke.KText)); ass_out.Events.Add( ev.StyleReplace("bd").StartReplace(t7).EndReplace(t8 + 0.15).TextReplace( ASSEffect.pos(x, y) + ASSEffect.fad(t8 + 0.15 - t7, 0) + ASSEffect.a(1, "FF") + ASSEffect.c(3, col0) + ASSEffect.blur(10) + ASSEffect.a(3, "77") + ke.KText)); ass_out.Events.Add( ev.StyleReplace("bd").StartReplace(t8 + 0.15).EndReplace(t9).TextReplace( ASSEffect.pos(x, y) + ASSEffect.a(1, "FF") + ASSEffect.c(3, col0) + ASSEffect.blur(10) + ASSEffect.a(3, "77") + ke.KText)); ass_out.Events.Add( ev.StyleReplace("bd").StartReplace(t9).EndReplace(tA).TextReplace( ASSEffect.pos(x, y) + ASSEffect.fad(0, tA - t9) + ASSEffect.a(1, "FF") + ASSEffect.c(3, col0) + ASSEffect.blur(10) + ASSEffect.a(3, "77") + ke.KText)); ass_out.Events.Add( ev.StartReplace(kEnd - 0.1).EndReplace(t9).TextReplace( ASSEffect.pos(x, y) + ASSEffect.fad(t9 - kEnd + 0.1, 0) + ASSEffect.a(3, "FF") + ASSEffect.c(1, col0) + ke.KText)); ass_out.Events.Add( ev.StartReplace(t9).EndReplace(tA).TextReplace( ASSEffect.pos(x, y) + ASSEffect.fad(0, tA - t9) + ASSEffect.a(3, "FF") + ASSEffect.c(1, col0) + ke.KText)); ass_out.Events.Add( ev.StartReplace(t0).EndReplace(t1).TextReplace( ASSEffect.move(x, y, x, y - 75) + ASSEffect.a(1, "FF") + ASSEffect.a(3, "FF") + ASSEffect.blur(1) + ASSEffect.c(3, col20) + ASSEffect.t(0, t1 - t0, ASSEffect.a(3, "C0").t() + ASSEffect.frx(180).t() + ASSEffect.c(3, col21).t()) + ke.KText)); ass_out.Events.Add( ev.StartReplace(t1).EndReplace(t2).TextReplace( ASSEffect.move(x, y - 75, x, y) + ASSEffect.a(1, "FF") + ASSEffect.a(3, "C0") + ASSEffect.frx(180) + ASSEffect.blur(1) + ASSEffect.c(3, col21) + ASSEffect.t(0, t2 - t1, ASSEffect.a(3, "80").t() + ASSEffect.frx(360).t() + ASSEffect.c(3, col22).t()) + ke.KText)); ass_out.Events.Add( ev.StartReplace(t2).EndReplace(t3).TextReplace( ASSEffect.move(x, y, x, y - 75) + ASSEffect.a(1, "FF") + ASSEffect.a(3, "80") + ASSEffect.blur(1) + ASSEffect.c(3, col22) + ASSEffect.t(0, t3 - t2, ASSEffect.a(3, "40").t() + ASSEffect.frx(180).t() + ASSEffect.c(3, col23).t()) + ke.KText)); ass_out.Events.Add( ev.StartReplace(t3).EndReplace(t4).TextReplace( ASSEffect.move(x, y - 75, x, y) + ASSEffect.a(1, "FF") + ASSEffect.a(3, "40") + ASSEffect.frx(180) + ASSEffect.blur(1) + ASSEffect.c(3, col23) + ASSEffect.t(0, t4 - t3, ASSEffect.a(3, "00").t() + ASSEffect.frx(360).t() + ASSEffect.c(3, col24).t() + ASSEffect.blur(1).t()) + ke.KText)); ass_out.Events.Add( ev.StartReplace(t4).EndReplace(t5).TextReplace( ASSEffect.pos(x, y) + ASSEffect.c(3, col24) + ASSEffect.a(1, "FF") + ASSEffect.blur(1) + ke.KText)); ass_out.Events.Add( ev.StartReplace(t5).EndReplace(t8 + 0.1).TextReplace( ASSEffect.pos(x, y) + ASSEffect.a(1, "FF") + ASSEffect.t(0, t8 + 0.1 - t5, ASSEffect.c(3, col20).t() + ASSEffect.fry(360 * 3).t()) + ASSEffect.blur(1) + ke.KText)); ass_out.Events.Add( ev.StartReplace(t8 + 0.1).EndReplace(t9).TextReplace( ASSEffect.pos(x, y) + ASSEffect.a(1, "FF") + ASSEffect.c(3, col20) + ASSEffect.blur(1) + ke.KText)); ass_out.Events.Add( ev.StartReplace(t9).EndReplace(tA).TextReplace( ASSEffect.pos(x, y) + ASSEffect.a(1, "FF") + ASSEffect.c(3, col20) + ASSEffect.blur(1) + ASSEffect.fad(0, tA - t9) + ASSEffect.t(0, tA - t9, ASSEffect.fry(700).t()) + ke.KText)); foreach (ASSPoint pt in mask.Points) { double ptx0 = Common.RandomInt_Gauss(rnd, pt.X, 10); double pty0 = Common.RandomInt_Gauss(rnd, pt.Y - 60, 10); double ptx1 = Common.RandomInt_Gauss(rnd, pt.X - 60, 20); double pty1 = Common.RandomInt_Gauss(rnd, pt.Y, 10); double pt_kt = ((double)(pt.X - mask.X0) / (double)mask.Width) * (kEnd - kStart) + kStart; double ptt0 = Common.RandomDouble(rnd, pt_kt - 0.4, pt_kt); double ptt1 = Common.RandomDouble(rnd, ptt0 + 0.25, ptt0 + 0.45); double ptt2 = ev.End - 1.0 * (1.0 - r) + 0.3 * (double)(pt.Y - y0) / (double)FontHeight + Common.RandomDouble(rnd, 0, 0.2); double ptt3 = Common.RandomDouble(rnd, ptt2 + 0.25, ptt2 + 0.45); string ptcol = Common.scaleColor(col0, col1, (double)(pt.Y - y0) / (double)FontHeight); ass_out.Events.Add( ev.StartReplace(ptt0).EndReplace(ptt1).StyleReplace("pt").TextReplace( ASSEffect.move(ptx0, pty0, pt.X, pt.Y) + ASSEffect.a(1, Common.ToHex2(255 - pt.Brightness)) + ASSEffect.c(1, ptcol) + ASSEffect.fad(0.4 * (ptt1 - ptt0), 0) + ptString )); ass_out.Events.Add( ev.StartReplace(ptt1).EndReplace(ptt2).StyleReplace("pt").TextReplace( ASSEffect.pos(pt.X, pt.Y) + ASSEffect.a(1, Common.ToHex2(255 - pt.Brightness)) + ASSEffect.c(1, ptcol) + ptString )); ass_out.Events.Add( ev.StartReplace(ptt2).EndReplace(ptt3).StyleReplace("pt").TextReplace( ASSEffect.move(pt.X, pt.Y, ptx1, pty1) + ASSEffect.a(1, Common.ToHex2(255 - pt.Brightness)) + ASSEffect.c(1, ptcol) + ASSEffect.fad(0, ptt3 - ptt2) + ptString )); } } } ass_out.SaveFile(OutFileName); }
public override int lambda(Stack st) { return(ASS.lambdai(st, true, true)); }
public override int lambda(Stack st) { return(ASS.lambdai(st, false, false)); }