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 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 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); }
public override void Run() { ASS ass_in = ASS.FromFile(this.InFileName); ASS ass_out = new ASS(); ass_out.Header = ass_in.Header; ass_out.Events = new List <ASSEvent>(); this.Font = new System.Drawing.Font("FA 瑞筆行書M", 26, GraphicsUnit.Pixel); this.MaskStyle = "Style: Default,FA 瑞筆行書M,26,&H00FFCEE7,&HFF0000FF,&H00FF2D49,&HFF0A5A84,-1,0,0,0,100,100,1,0,1,2,0,5,20,20,10,128"; for (int i = 0; i < 21; i++) { ASSEvent ev = ass_in.Events[i]; List <KElement> kelems = ev.SplitK(true); if (i >= 11) { this.Font = new System.Drawing.Font("華康行書體(P)", 26, GraphicsUnit.Pixel); this.MaskStyle = "Style: Default,華康行書體(P),26,&H00FFCEE7,&HFF0000FF,&H00FF2D49,&HFF0A5A84,-1,0,0,0,100,100,1,0,1,2,0,5,20,20,10,136"; } int sumw = GetTotalWidth(ev); int x0 = (PlayResX - MarginLeft - MarginRight - sumw) / 2 + MarginLeft; int kSum = 0; for (int ik = 0; ik < kelems.Count; ik++) { Console.WriteLine("{0} / {1} : {2} / {3}", i + 1, ass_in.Events.Count, ik + 1, kelems.Count); KElement elem = kelems[ik]; Size sz = this.GetSize(elem.KText); int x = x0; x0 += sz.Width + this.FontSpace; int y = PlayResY - MarginBottom; if (i == 5) { y -= FontHeight + 10; } if (i >= 11) { y = MarginTop + FontHeight; } double kStart = (double)kSum * 0.01; double kEnd = (double)(kSum + elem.KValue) * 0.01; kEnd = kStart + 0.6; double kMid = (kStart + kEnd) * 0.5; double kQ1 = kStart + (kEnd - kStart) * 0.1; double r = (double)ik / (double)(kelems.Count - 1); double r0 = 1.0 - r; int fd_xof = (int)((double)(ik - (kelems.Count - 1) / 2) / (double)(kelems.Count - 1) * (double)PlayResX * 0.2); // an7 -> an5 x += sz.Width / 2; y -= FontHeight / 2; // 0.5秒内出现 ass_out.Events.Add(ev.StartReplace(ev.Start - r0 * 0.5).EndReplace(ev.Start - r0 * 0.5 + 0.3).TextReplace( ASSEffect.move(x + fd_xof, y, x, y) + ASSEffect.an(5) + ASSEffect.be(1) + ASSEffect.a(1, "FF") + ASSEffect.a(3, "FF") + ASSEffect.fsc(400, 400) + ASSEffect.t(0, 0.3, ASSEffect.fsc(100, 100).t() + ASSEffect.a(1, "00").t() + ASSEffect.a(3, "00").t() + ASSEffect.fry(-360).t()) + elem.KText)); double newStart = ev.Start; if (ev.Start - r0 * 0.5 + 0.3 > ev.Start) { newStart = ev.Start - r0 * 0.5 + 0.3; } else { ass_out.Events.Add(ev.StartReplace(ev.Start - r0 * 0.5 + 0.3).EndReplace(ev.Start).TextReplace( ASSEffect.pos(x, y) + ASSEffect.an(5) + ASSEffect.be(1) + elem.KText)); } //ass_out.Events.Add(ev.TextReplace( // ASSEffect.pos(x, y) + ASSEffect.an(5) + elem.KText)); if (i < 11) { ass_out.Events.Add(ev.StartReplace(newStart).EndReplace(ev.Start + kStart).TextReplace( ASSEffect.pos(x, y) + ASSEffect.an(5) + ASSEffect.be(1) + elem.KText)); ass_out.Events.Add(ev.StartReplace(ev.Start + kStart).EndReplace(ev.Start + kEnd).TextReplace( ASSEffect.pos(x, y) + ASSEffect.an(5) + ASSEffect.be(1) + ASSEffect.t(0, kQ1 - kStart, ASSEffect.c(1, "FFFFFF").t() + ASSEffect.c(1, "FFFFFF").t() + ASSEffect.fsc(200, 200).t()) + ASSEffect.t(kQ1 - kStart, kEnd - kStart, ASSEffect.c(3, "A4CEE7").t() + ASSEffect.c(1, "072D49").t() + ASSEffect.fsc(100, 100).t()) + elem.KText)); ass_out.Events.Add(ev.StartReplace(ev.Start + kEnd).EndReplace(ev.End).TextReplace( ASSEffect.pos(x, y) + ASSEffect.an(5) + ASSEffect.be(1) + ASSEffect.c(1, "072D49") + ASSEffect.c(3, "A4CEE7") + elem.KText)); } else { ass_out.Events.Add(ev.StartReplace(newStart).TextReplace( ASSEffect.pos(x, y) + ASSEffect.an(5) + ASSEffect.be(1) + elem.KText)); } // 0.5秒内消失 if (i < 11) { ass_out.Events.Add(ev.StartReplace(ev.End + r * 0.5).EndReplace(ev.End + r * 0.5 + 0.3).TextReplace( ASSEffect.move(x, y, x + fd_xof, y) + ASSEffect.be(1) + ASSEffect.an(5) + ASSEffect.c(1, "072D49") + ASSEffect.c(3, "A4CEE7") + ASSEffect.t(0, 0.3, ASSEffect.fsc(400, 400).t() + ASSEffect.a(1, "FF").t() + ASSEffect.a(3, "FF").t() + ASSEffect.fry(-360).t()) + elem.KText)); ass_out.Events.Add(ev.StartReplace(ev.End).EndReplace(ev.End + r * 0.5).TextReplace( ASSEffect.pos(x, y) + ASSEffect.an(5) + ASSEffect.be(1) + ASSEffect.c(1, "072D49") + ASSEffect.c(3, "A4CEE7") + elem.KText)); } else { ass_out.Events.Add(ev.StartReplace(ev.End + r * 0.5).EndReplace(ev.End + r * 0.5 + 0.3).TextReplace( ASSEffect.move(x, y, x + fd_xof, y) + ASSEffect.be(1) + ASSEffect.an(5) + ASSEffect.t(0, 0.3, ASSEffect.fsc(400, 400).t() + ASSEffect.a(1, "FF").t() + ASSEffect.a(3, "FF").t() + ASSEffect.fry(-360).t()) + elem.KText)); ass_out.Events.Add(ev.StartReplace(ev.End).EndReplace(ev.End + r * 0.5).TextReplace( ASSEffect.pos(x, y) + ASSEffect.an(5) + ASSEffect.be(1) + elem.KText)); } kSum += elem.KValue; } } ass_out.SaveFile(OutFileName); }
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); }
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>(); 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); /// an7 pos int x0 = MarginLeft; int y0 = PlayResY - MarginBottom - FontHeight; int kSum = 0; for (int i = 0; i < kelems.Count; i++) { KElement ke = kelems[i]; double r = (double)i / (double)(kelems.Count - 1); double r0 = 1.0 - r; Size sz = GetSize(ke.KText); if (Char.IsWhiteSpace(ke.KText[0])) { sz.Width = 15; } double kStart = kSum * 0.01; double kEnd = kStart + ke.KValue * 0.01; /// an5 pos int x = x0 + FontSpace + sz.Width / 2; int y = y0 + FontHeight / 2; x0 += this.FontSpace + sz.Width; y0 = y0; kSum += ke.KValue; double t0 = ev.Start - r0 * 0.5; double t1 = t0 + 0.2; // 出现 double t2 = ev.Start + kStart - 0.1; // 保持框 double t3 = t2 + 0.5; // K效果 double t4 = ev.End - r0 * 0.5; // 保持 double t5 = t4 + 0.2; // 消失 double rect_x0 = x - sz.Width / 2 - 2; double rect_y0 = y - FontHeight / 2 - 2; double rect_x1 = x + sz.Width / 2 + 2; double rect_y1 = y + FontHeight / 2 + 2; if (ke.KText.Length > 1) { rect_x0 -= ke.KText.Length * 1; rect_x1 += ke.KText.Length * 1; } if (ke.KText == "with" || ke.KText == "find" || ke.KText == "world") { rect_x0 -= 2; rect_x1 += 1; } if (ke.KText == "DITE") { rect_x0 -= 3; rect_x1 += 3; } if (ke.KText == "alive") { rect_x0 -= 2; rect_x1 += 2; } double rect_xmid = (rect_x0 + rect_x1) * 0.5; double rect_ymid = (rect_y0 + rect_y1) * 0.5; if (ke.KText.Trim().Length > 0) { ass_out.Events.Add( ev.StartReplace(t0).EndReplace(t1).TextReplace( ASSEffect.move(x + 10, y - 10, x, y) + ASSEffect.fad(t1 - t0, 0) + ke.KText)); ass_out.Events.Add( CreateRectangle(t0, t1, "draw1", rect_x0, rect_y0, rect_x1, rect_y1, x, y, ASSEffect.move(x + 10, y - 10, x, y) + ASSEffect.fad(t1 - t0, 0)) ); int xC = 16; int yC = 16; if (ke.KText.Length > 1) { xC = (int)(Math.Round((double)yC / (rect_y1 - rect_y0) * (rect_x1 - rect_x0))); } switch (iEv) { case 0: case 1: ass_out.Events.Add( ev.StartReplace(t1).EndReplace(t4).TextReplace( ASSEffect.pos(x, y) + ke.KText)); ass_out.Events.Add( CreateRectangle(t1, t2, "draw1", rect_x0, rect_y0, rect_x1, rect_y1) ); ass_out.Events.Add( CreateRectangle(t2, t3, "draw1", rect_x0, rect_y0, rect_xmid, rect_y1, rect_x0, rect_ymid, ASSEffect.pos((int)Math.Round(rect_x0), (int)Math.Round(rect_ymid)) + ASSEffect.t(0, t3 - t2, ASSEffect.fry(-90).t()) + ASSEffect.fad(0, t3 - t2) )); ass_out.Events.Add( CreateRectangle(t2, t3, "draw1", rect_xmid, rect_y0, rect_x1, rect_y1, rect_x1, rect_ymid, ASSEffect.pos((int)Math.Round(rect_x1), (int)Math.Round(rect_ymid)) + ASSEffect.t(0, t3 - t2, ASSEffect.fry(90).t()) + ASSEffect.fad(0, t3 - t2) )); break; case 2: ass_out.Events.Add( ev.StartReplace(t1).EndReplace(t4).TextReplace( ASSEffect.pos(x, y) + ke.KText)); ass_out.Events.Add( CreateRectangle(t1, t2, "draw1", rect_x0, rect_y0, rect_x1, rect_y1) ); ass_out.Events.Add( CreateRectangle(t2, t3, "draw1", rect_x0, rect_y0, rect_x1, rect_ymid, rect_xmid, rect_y0, ASSEffect.pos((int)Math.Round(rect_xmid), (int)Math.Round(rect_y0)) + ASSEffect.t(0, t3 - t2, ASSEffect.frx(-90).t()) + ASSEffect.fad(0, t3 - t2) )); ass_out.Events.Add( CreateRectangle(t2, t3, "draw1", rect_x0, rect_ymid, rect_x1, rect_y1, rect_xmid, rect_y1, ASSEffect.pos((int)Math.Round(rect_xmid), (int)Math.Round(rect_y1)) + ASSEffect.t(0, t3 - t2, ASSEffect.frx(90).t()) + ASSEffect.fad(0, t3 - t2) )); break; case 7: case 8: ass_out.Events.Add( ev.StartReplace(t1).EndReplace(t4).TextReplace( ASSEffect.pos(x, y) + ke.KText)); ass_out.Events.Add( CreateRectangle(t1, t2, "draw1", rect_x0, rect_y0, rect_x1, rect_y1) ); for (int jR = 0; jR < yC; jR++) { double yy0 = rect_y0 + (rect_y1 - rect_y0) * (double)jR / (double)yC; double yy1 = yy0 + (rect_y1 - rect_y0) / (double)yC; double rStart = t2 + jR * 0.05; if (iEv == 8) { rStart = t2 + (yC - jR - 1) * 0.05; } double rEnd = rStart + 0.2; double yymid = (yy0 + yy1) * 0.5; ass_out.Events.Add( CreateRectangle(t2, rStart, "draw1", rect_x0, yy0, rect_x1, yy1) ); ass_out.Events.Add( CreateRectangle(rStart, rEnd, "draw1", rect_x0, yy0, rect_x1, yy1, rect_xmid, yymid, ASSEffect.pos(rect_xmid, yymid) + ASSEffect.fad(0, rEnd - rStart) )); } break; case 3: case 4: case 5: case 6: default: ass_out.Events.Add( ev.StartReplace(t1).EndReplace(t2).TextReplace( ASSEffect.pos(x, y) + ke.KText)); ass_out.Events.Add( CreateRectangle(t1, t2, "draw1", rect_x0, rect_y0, rect_x1, rect_y1) ); double t3_2 = ev.Start + kEnd; if (t3_2 > t4) { t3_2 = t4; } for (int iR = 0; iR < (int)(Math.Round((t3_2 - t2) / 0.01)); iR++) { double rStart = t2 + iR * 0.01; double rEnd = rStart + 0.01; ass_out.Events.Add( ev.StartReplace(rStart).EndReplace(rEnd).TextReplace( ASSEffect.pos(Common.RandomInt(rnd, x - 3, x + 3), Common.RandomInt(rnd, y - 3, y + 3)) + ke.KText)); } ass_out.Events.Add( ev.StartReplace(t3_2).EndReplace(t4).TextReplace( ASSEffect.pos(x, y) + ke.KText)); for (int iR = 0; iR < xC; iR++) { for (int jR = 0; jR < yC; jR++) { double xx0 = rect_x0 + (rect_x1 - rect_x0) * (double)iR / (double)xC; double yy0 = rect_y0 + (rect_y1 - rect_y0) * (double)jR / (double)yC; double xx1 = xx0 + (rect_x1 - rect_x0) / (double)xC; double yy1 = yy0 + (rect_y1 - rect_y0) / (double)yC; double dx = rnd.Next() % 20 + 8; double dy = rnd.Next() % 20 + 8; double xx2 = xx0; double yy2 = yy0; if (Common.RandomInt_Gauss2(rnd, xC, iR) <= xC / 2) { xx2 -= dx; } else { xx2 += dx; } if (Common.RandomInt_Gauss2(rnd, yC, jR) <= yC / 2) { yy2 -= dy; } else { yy2 += dy; } double rEnd = Common.RandomDouble(rnd, t2 + 0.3, t2 + 1.5); ass_out.Events.Add( CreateRectangle(t2, rEnd, "draw1", xx0, yy0, xx1, yy1, xx0, yy0, ASSEffect.move(xx0, yy0, xx2, yy2) + ASSEffect.fad(0, rEnd - t2) )); } } break; } ass_out.Events.Add( ev.StartReplace(t4).EndReplace(t5).TextReplace( ASSEffect.move(x, y, x - 10, y + 10) + ASSEffect.fad(0, t5 - t4) + ke.KText)); } } } 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); }