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() { 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>(); 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(); 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 void Run() { ASS ass = ASS.FromFile(InFileName); ASS outass = new ASS(); outass.Header = ass.Header; outass.Events = new List <ASSEvent>(); Particle particle = new Particle { IsMove = false, IsRandomColor = false, IsPatternScale = true, Count = 1, FontSize = 26, MinLast = 0.5, MaxLast = 0.8, ParticlePattern = ParticlePatternType.Circle, PatternScaleX = 600, PatternScaleY = 600, Style = "Circle", XOffset = 0, YOffset = 0 }; ASSColor[] colors = { new ASSColor { A = 0, Index = 1, R = 0xCA, G = 0xB4, B = 0x6D }, new ASSColor { A = 0, Index = 1, R = 0xEE, G = 0x85, B = 0x57 }, new ASSColor { A = 0, Index = 1, R = 0xE4, G = 0x30, B = 0x99 }, new ASSColor { A = 0, Index = 1, R = 0x5D, G = 0xD3, B = 0xEE }, new ASSColor { A = 0, Index = 1, R = 0xE1, G = 0x32, B = 0x63 } }; for (int i = 0; i < ass.Events.Count; i++) { ASSEvent ev = ass.Events[i]; List <KElement> klist = ev.SplitK(); int ksum = 0; ASSColor lastcc = null; for (int j = 0; j < klist.Count; j++) { int x = (PlayResX - klist.Count * FontWidth) / 2 + j * FontWidth + FontWidth / 2; int y = PlayResY - MarginBottom - FontHeight / 2; if (i == 7) { y = MarginTop + FontHeight / 2; } double kStart = ksum * 0.01; double kEnd = (ksum + klist[j].KValue) * 0.01; ASSColor cc = colors[(i + j) % colors.Length]; /*while (lastcc == cc) * cc = colors[rnd.Next(colors.Length)]; * lastcc = cc;*/ if (!Char.IsWhiteSpace(klist[j].KText[0])) { outass.Events.Add(ev.TextReplace( ASSEffect.an(5) + ASSEffect.pos(x, y) + ASSEffect.a(1, "FF") + ASSEffect.t(kStart, kStart + 0.2, cc.ToString()) + (i % 4 <= 1 ? ASSEffect.t(ev.Last - 0.3 - 0.5 * (1 - ((double)j / (double)klist.Count)), ev.Last - 0.5 * (1 - ((double)j / (double)klist.Count)), @"\1a&HFF&\2a&HFF&\3a&HFF&\4a&HFF&" + ((i % 2 == 0) ? @"\frx700" : @"\fry700")) : (i % 4 == 3 ? ASSEffect.t(ev.Last - 0.5 * (1 - ((double)j / (double)klist.Count)), ev.Last - 0.5 * (1 - ((double)j / (double)klist.Count)) + 0.01, @"\1a&HFF&\2a&HFF&\3a&HFF&\4a&HFF&") : ASSEffect.t(ev.Last - 0.8 - 0.5 * (1 - ((double)j / (double)klist.Count)), ev.Last - 0.5 * (1 - ((double)j / (double)klist.Count)), @"\1a&HFF&\2a&HFF&\3a&HFF&\4a&HFF&" + @"\frz700"))) + klist[j].KText )); if (i % 4 == 3) { outass.Events.Add(ev.StartReplace(ev.Start + ev.Last - 0.5 * (1 - ((double)j / (double)klist.Count)) + 0.01).EndReplace(ev.Start + ev.Last - 0.5 * (1 - ((double)j / (double)klist.Count)) + 0.01 + 0.2).TextReplace( ASSEffect.an(5) + ASSEffect.move(x, y, x - 40, y) + ASSEffect.fad(0, 0.2) + ASSEffect.c(cc) + klist[j].KText)); } particle.X = x - FontWidth / 2; particle.Y = y - FontHeight / 2; particle.Start = ev.Start + kStart; particle.End = particle.Start; particle.Color = cc; outass.Events.AddRange(particle.Create()); } ksum += klist[j].KValue; } } outass.Shift(Shift); outass.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>(); this.Font = new System.Drawing.Font("HGGyoshotai", 28); this.Mask_HeightScale = 1; string src = "もう少しだけ"; /* * int x0 = 100; * Random rnd = new Random(); * foreach (char ch in src) * { * List<Point> pts = GetMask(ch, x0, 100); * foreach (Point pt in pts) * ass_out.Events.Add(new ASSEvent * { * Start = 0, * End = 1, * Layer = 0, * Style = "pt", * Effect = "", * MarginL = "0000", * MarginR = "0000", * MarginV = "0000", * Name = "NTP", * Text = ASSEffect.an(5) + ASSEffect.move(pt.X, pt.Y, pt.X - rnd.Next() % 50, pt.Y - rnd.Next() % 80 + 40) + 'o' * } * ); * * x0 += FontWidth; * } * */ int x0 = 200; int y0 = 200; int x1 = 200; int y1 = 200; int p1_x = 100; int p1_y = 170; int p2_x = 380; int p2_y = 250; List <ASSPoint> pts0 = GetMask("彼", x0, y0).Points; List <ASSPoint> pts1 = GetMask("雷", x1, y1).Points; int y0min = 200; int y0max = 240; int y1min = 200; int y1max = 240; foreach (ASSPoint pt in pts0) { ass_out.Events.Add(new ASSEvent { Start = 0, End = 1, Layer = 0, Style = "pt", Effect = "", MarginL = "0000", MarginR = "0000", MarginV = "0000", Name = "NTP", Text = ASSEffect.an(5) + ASSEffect.pos(pt.X, pt.Y) + ASSEffect.c(1, Common.scaleColor("7A93EB", "6939C8", y0min, y0max, pt.Y)) + '.' }); } Random rnd = new Random(); bool[] used0 = new bool[pts0.Count]; for (int i = 0; i < used0.Length; i++) { used0[i] = false; } foreach (ASSPoint pt1 in pts1) { int k0 = rnd.Next() % pts0.Count; used0[k0] = true; int p1_xx = Common.RandomInt_Gauss(rnd, p1_x, 80); int p1_yy = Common.RandomInt_Gauss(rnd, p1_y, 80); int p2_xx = Common.RandomInt_Gauss(rnd, p2_x, 80); int p2_yy = Common.RandomInt_Gauss(rnd, p2_y, 80); string startColor = Common.scaleColor("7A93EB", "6939C8", y0min, y0max, pts0[k0].Y); string endColor = Common.scaleColor("A3E789", "D9AB85", y1min, y1max, pt1.Y); List <ASSPoint> bez_pts = new Bezier(pts0[k0], new ASSPoint { X = p1_xx, Y = p1_yy }, new ASSPoint { X = p2_xx, Y = p2_yy }, pt1).Create(0.1f); for (int i = 0; i + 1 < bez_pts.Count; i++) { ass_out.Events.Add(new ASSEvent { Start = 1 + i * 0.2, End = 1 + (i + 1) * 0.2, Layer = 0, Style = "pt", Effect = "", MarginL = "0000", MarginR = "0000", MarginV = "0000", Name = "NTP", Text = ASSEffect.an(5) + ASSEffect.move(bez_pts[i].X, bez_pts[i].Y, bez_pts[i + 1].X, bez_pts[i + 1].Y) + ASSEffect.c(1, Common.scaleColor(startColor, endColor, (double)i / (double)bez_pts.Count)) + '.' }); } } double last_end = ass_out.Events[ass_out.Events.Count - 1].End; foreach (ASSPoint pt in pts1) { ass_out.Events.Add(new ASSEvent { Start = last_end, End = last_end + 1, Layer = 0, Style = "pt", Effect = "", MarginL = "0000", MarginR = "0000", MarginV = "0000", Name = "NTP", Text = ASSEffect.an(5) + ASSEffect.pos(pt.X, pt.Y) + ASSEffect.c(1, Common.scaleColor("A3E789", "D9AB85", y1min, y1max, pt.Y)) + '.' }); } ass_out.SaveFile(OutFileName); }
public List <ASSEvent> Create() { List <ASSEvent> result = new List <ASSEvent>(); for (int iCount = 0; iCount < Count; iCount++) { ASSEvent ev = new ASSEvent { Layer = 0, Effect = "", Name = "NTP", MarginL = "0000", MarginR = "0000", MarginV = "0000", Style = Style, Start = Common.RandomDouble(rnd, Start, End) }; double last = Common.RandomDouble(rnd, MinLast, MaxLast); ev.End = Start + last; ev.Text = ASSEffect.an(5) + ASSEffect.fad(0, last); if (IsMove && MoveStyle == 1) { int x1 = Common.RandomInt(rnd, X, X + FontSize); int y1 = Common.RandomInt(rnd, Y, Y + FontSize); int y2 = Common.RandomInt(rnd, Y + FontSize / 2 - AreaHeight / 2, Y + FontSize / 2 + AreaHeight / 2); int x2 = Common.RandomInt(rnd, X - AreaWidth, X); ev.Text += ASSEffect.move(x1 + XOffset, y1 + YOffset, x2 + XOffset, y2 + YOffset); } else if (IsMove && MoveStyle == 2) { int x1 = Common.RandomInt(rnd, X, X + FontSize); int y1 = Common.RandomInt(rnd, Y, Y + FontSize); int y2 = Common.RandomInt(rnd, Y + FontSize / 2 - AreaHeight / 2, Y + FontSize / 2 + AreaHeight / 2); int x2 = Common.RandomInt(rnd, X + FontSize / 2 - AreaWidth / 2, X + FontSize / 2 + AreaWidth / 2); ev.Text += ASSEffect.move(x1 + XOffset, y1 + YOffset, x2 + XOffset, y2 + YOffset); } else if (IsMove && MoveStyle == 3) { int x1 = X + FontSize / 2; int y1 = Y + FontSize / 2; int y2 = Common.RandomInt(rnd, y1 - AreaHeight / 2, y1 + AreaHeight / 2); int x2 = Common.RandomInt(rnd, x1 - AreaWidth / 2, x1 + AreaWidth / 2); ev.Text += ASSEffect.move(x1 + XOffset, y1 + YOffset, x2 + XOffset, y2 + YOffset); } else { ev.Text += ASSEffect.pos(X + FontSize / 2 + XOffset, Y + FontSize / 2 + YOffset); } if (!IsRandomColor) { ev.Text += ASSEffect.c(Color); } else { ev.Text += ASSEffect.c(Common.RandomColor(rnd, 1, Color1, Color2)); } if (BE > 0) { ev.Text += ASSEffect.be(BE); } if (IsPatternScale) { ev.Text += ASSEffect.t(0, last, @"\fscx" + PatternScaleX + @"\fscy" + PatternScaleY); } if (IsRotate) { ev.Text += ASSEffect.t(0, last, ASSEffect.frz((int)(last * 1000)).t()); } ev.Text += (char)ParticlePattern; result.Add(ev); } return(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 ms1 = "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"; string ptstr = @"{\p1}m 0 0 l 1 0 1 1 0 1"; Random rnd = new Random(); for (int iEv = 0; iEv < ass_in.Events.Count; iEv++) { //if (iEv != 1) continue; ASSEvent ev = ass_in.Events[iEv]; List <KElement> kelems = ev.SplitK(false); this.MaskStyle = ms1; int x0 = MarginLeft; int startx0 = x0; int y0 = PlayResY - MarginBottom - FontHeight; if (iEv == -1) { bool zz = false; foreach (Beat bt in GetBeats()) { ass_out.Events.Add( ev.StartReplace(bt.Time).EndReplace(bt.Time + 0.3).TextReplace( ASSEffect.pos(30, zz ? 30 : 80) + ASSEffect.an(7) + ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") + ASSEffect.a(3, "FF") + ASSEffect.fad(0.05, 0.2) + string.Format("ID:{0} STR:{1}", bt.Id, bt.Strength))); zz = !zz; } } if (iEv == 0) { int reg0 = 0; int[] blurstrar = new int[] { 2, 3, 4, 5, 6, 7, 8 }; blurstrar = blurstrar.Select(bs => bs + 4).ToArray(); foreach (Beat bt in GetBeats()) { if (bt.Id >= 151) { if (bt.Reg) { reg0 = 0; } else { reg0++; } int blurstr = blurstrar[reg0]; ass_out.Events.Add( ev.StartReplace(bt.Time).EndReplace(bt.Time + 0.3).LayerReplace(5).TextReplace( ASSEffect.an(7) + ASSEffect.pos(0, 0) + ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") + ASSEffect.a(3, "44") + ASSEffect.c(3, "ED6D64") + ASSEffect.fad(0.05, 0.2) + ASSEffect.blur(blurstr) + ASSEffect.bord(blurstr) + @"{\p1}m 0 678 l 1280 678 1280 679 0 679")); ass_out.Events.Add( ev.StartReplace(bt.Time).EndReplace(bt.Time + 0.3).LayerReplace(6).TextReplace( ASSEffect.an(7) + ASSEffect.pos(0, 0) + ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") + ASSEffect.a(3, "44") + ASSEffect.c(3, "FFFFFF") + ASSEffect.fad(0.05, 0.2) + ASSEffect.blur(2) + ASSEffect.bord(2) + @"{\p1}m 0 678 l 1280 678 1280 679 0 679")); } } foreach (Beat bt in GetBeats()) { if (bt.Id < 151 || bt.Strength == 0) { continue; } for (int i = 0; i < 0.3 * 1500; i++) { double parx0 = Common.RandomInt(rnd, 0, PlayResX); double pary0 = Common.RandomInt(rnd, 678 - 30, 678 + 20); double parx1 = parx0 + Common.RandomInt(rnd, -5, 5); double pary1 = pary0 - 30; double part0 = bt.Time; double part1 = bt.Time + 0.3; ass_out.Events.Add( ev.StartReplace(part0).EndReplace(part1).StyleReplace("pt").LayerReplace(3).TextReplace( ASSEffect.move(parx0, pary0, parx1, pary1) + ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") + ASSEffect.a(3, "55") + ASSEffect.c(3, "ED6D64") + ASSEffect.bord(2) + ASSEffect.blur(2) + ASSEffect.fad(0.05, 0.2) + ASSEffect.frz(Common.RandomInt(rnd, 0, 360)) + CreatePolygon(rnd, 10, 25, 6))); } } } int kSum = 0; //if (!(iEv == 1 || iEv == 3 || iEv == 5 || iEv == 7)) if (iEv + 1 < ass_in.Events.Count && ass_in.Events[iEv + 1].Start - ev.End > 0.5) { ev.End = ass_in.Events[iEv + 1].Start - 0.5; } 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 = ms1; Size sz = GetSize(ke.KText); if (ke.KText.Trim() == "") { sz.Width = 15; } double kStart = ev.Start + kSum * 0.01; double kEnd = kStart + ke.KValue * 0.01; kSum += ke.KValue; if (iK + 1 == kelems.Count && kEnd < ev.End) { kEnd = ev.End; } 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; } double r0 = ev.Start - 0.3; double t0 = kStart - 0.4; double t1 = t0 + 0.4; double t2 = ev.End; double r1 = r0 + 0.3; if (!(iEv == 0 || iEv == 2 || iEv == 4 || iEv == 6 || iEv == 8)) { for (int i = -1; i <= 1; i++) { ass_out.Events.Add( ev.StartReplace(r0).EndReplace(r1).TextReplace( ASSEffect.move(x + i * 10, y, x, y) + ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") + ASSEffect.a(3, "00") + ASSEffect.c(3, "FFFFFF") + ASSEffect.xbord(20) + ASSEffect.be(20) + ASSEffect.ybord(0) + ASSEffect.t(0, r1 - r0, ASSEffect.xbord(0).t() + ASSEffect.be(0).t()) + ASSEffect.fad((r1 - r0) * 1, 0) + ke.KText)); } } else { ass_out.Events.Add( ev.StartReplace(ev.Start - 0.3).EndReplace(t1).LayerReplace(10).TextReplace( ASSEffect.pos(x, y) + ASSEffect.a(1, "77") + ASSEffect.c(1, "777777") + ASSEffect.a(3, "FF") + ASSEffect.fad(0.5, 0) + ke.KText)); } if (iEv == 4 || iEv == 5) { ass_out.Events.Add( ev.StartReplace(kStart - 0.1).EndReplace(kEnd).StyleReplace("pt").LayerReplace(0).TextReplace( ASSEffect.an(7) + ASSEffect.pos(0, 0) + ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") + ASSEffect.a(3, "77") + ASSEffect.c(3, "ED6D64") + ASSEffect.bord(10) + ASSEffect.blur(10) + ASSEffect.fad(0.2, 0.2) + @"{\p1}" + string.Format("m {0} {1} l {0} {2} {3} {2} {3} {1}", x, PlayResY, PlayResY - MarginBottom - FontHeight - 285, x + 1))); ass_out.Events.Add( ev.StartReplace(kStart - 0.1).EndReplace(kEnd).StyleReplace("pt").LayerReplace(1).TextReplace( ASSEffect.an(7) + ASSEffect.pos(0, 0) + ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") + ASSEffect.a(3, "77") + ASSEffect.c(3, "FFFFFF") + ASSEffect.bord(2) + ASSEffect.blur(2) + ASSEffect.fad(0.2, 0.2) + @"{\p1}" + string.Format("m {0} {1} l {0} {2} {3} {2} {3} {1}", x, PlayResY, PlayResY - MarginBottom - FontHeight - 285, x + 1))); for (int i = 0; i < (int)((kEnd - kStart) * 200); i++) { double parx0 = Common.RandomInt(rnd, x - 5, x + 5); double pary0 = Common.RandomInt(rnd, PlayResY - MarginBottom - FontHeight - 285, PlayResY); double parx1 = parx0 + Common.RandomInt(rnd, -20, 20); double pary1 = pary0 + Common.RandomInt(rnd, -5, 5); double part0 = Common.RandomDouble(rnd, kStart - 0.1, kEnd - 0.1); double part1 = part0 + Common.GetDistance(parx0, pary0, parx1, pary1) / 50.0; ass_out.Events.Add( ev.StartReplace(part0).EndReplace(part1).StyleReplace("pt").LayerReplace(3).TextReplace( ASSEffect.move(parx0, pary0, parx1, pary1) + ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") + ASSEffect.a(3, "55") + ASSEffect.c(3, "ED6D64") + ASSEffect.bord(2) + ASSEffect.blur(2) + ASSEffect.fad(0.05, 0.2) + ASSEffect.frz(Common.RandomInt(rnd, 0, 360)) + CreatePolygon(rnd, 10, 25, 6))); } } if (iEv == 0 || iEv == 2 || iEv == 4 || iEv == 6 || iEv == 8) { double dt = 0.002; double dx, dy; { double t = t1; double ag = Math.PI * 2.0 * (t - t0) / (t1 - t0) - Math.PI * 0.5; double ca = 40; double cb = 18; double cx0 = ca * Math.Cos(ag); double cy0 = cb * Math.Sin(-ag); double cag = Math.PI * 0.25; double cx1 = cx0 * Math.Cos(cag) + cy0 * Math.Sin(cag); double cy1 = -cx0 *Math.Sin(cag) + cy0 * Math.Cos(cag); dx = -cx1; dy = -cy1; } for (double t = t0; t <= t1; t += dt) { double ag = Math.PI * 2.0 * (t - t0) / (t1 - t0) - Math.PI * 0.5; double ca = 40; double cb = 18; double cx0 = ca * Math.Cos(ag); double cy0 = cb * Math.Sin(-ag); double cag = Math.PI * 0.25; double cx1 = cx0 * Math.Cos(cag) + cy0 * Math.Sin(cag); double cy1 = -cx0 *Math.Sin(cag) + cy0 * Math.Cos(cag); cx1 += x + dx; cy1 += y + dy; int fs = (int)((double)this.FontHeight * (t - t0) / (t1 - t0) + 1); ass_out.Events.Add( ev.StartReplace(t).EndReplace(t + 0.4).LayerReplace(20).TextReplace( ASSEffect.pos(cx1, cy1) + ASSEffect.fs(fs) + ASSEffect.a(1, "E0") + ASSEffect.c(1, "FFFFFF") + ASSEffect.a(3, "E0") + ASSEffect.c(3, "FFFFFF") + ASSEffect.fad(0, 0.3) + ASSEffect.bord(1) + ASSEffect.blur(1) + ke.KText)); ass_out.Events.Add( ev.StartReplace(t).EndReplace(t + dt).TextReplace( ASSEffect.pos(cx1, cy1) + ASSEffect.fs(fs) + ASSEffect.pos(x, y) + ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") + ASSEffect.a(3, "FF") + ke.KText)); } ass_out.Events.Add( ev.StartReplace(t1).EndReplace(t1 + 0.35).LayerReplace(30).TextReplace( ASSEffect.pos(x, y) + ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") + ASSEffect.a(3, "00") + ASSEffect.c(3, "FFFFFF") + ASSEffect.bord(8) + ASSEffect.blur(8) + ASSEffect.fad(0.05, 0.2) + ke.KText)); ass_out.Events.Add( ev.StartReplace(t1).EndReplace(t2 + 0.2).LayerReplace(30).TextReplace( ASSEffect.pos(x, y) + ASSEffect.a(1, "BB") + ASSEffect.c(1, "FFFFFF") + ASSEffect.a(3, "BB") + ASSEffect.c(3, "FFFFFF") + ASSEffect.bord(2) + ASSEffect.blur(2) + 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, "00") + ASSEffect.c(1, "FFFFFF") + ASSEffect.a(3, "FF") + ke.KText)); } else { t0 += 0.2; t1 += 0.2; if (t0 < ev.Start) { t0 = ev.Start; t1 = t0 + 0.4; } ass_out.Events.Add( ev.StartReplace(r1 - 0.2).EndReplace(t0 + 0.2).LayerReplace(30).TextReplace( ASSEffect.pos(x, y) + ASSEffect.a(1, "E0") + ASSEffect.c(1, "FFFFFF") + ASSEffect.a(3, "E0") + ASSEffect.c(3, "FFFFFF") + ASSEffect.bord(2) + ASSEffect.blur(2) + ASSEffect.fad(0.2, 0.2) + ke.KText)); ass_out.Events.Add( ev.StartReplace(r1).EndReplace(t0).TextReplace( ASSEffect.pos(x, y) + ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") + ASSEffect.a(3, "FF") + ke.KText)); double dt = 0.002; double dx, dy; { double t = t1; double ag = Math.PI * 2.0 * (t - t0) / (t1 - t0) - Math.PI * 0.5; double ca = 40; double cb = 18; double cx0 = ca * Math.Cos(ag); double cy0 = cb * Math.Sin(-ag); double cag = Math.PI * 0.25; double cx1 = cx0 * Math.Cos(cag) + cy0 * Math.Sin(cag); double cy1 = -cx0 *Math.Sin(cag) + cy0 * Math.Cos(cag); dx = -cx1; dy = -cy1; } for (double t = t0; t <= t1; t += dt) { double ag = Math.PI * 2.0 * (t1 - t) / (t1 - t0) - Math.PI * 0.5; double ca = 40; double cb = 18; double cx0 = ca * Math.Cos(ag); double cy0 = cb * Math.Sin(-ag); double cag = Math.PI * 0.25; double cx1 = cx0 * Math.Cos(cag) + cy0 * Math.Sin(cag); double cy1 = -cx0 *Math.Sin(cag) + cy0 * Math.Cos(cag); cx1 += x + dx; cy1 += y + dy; int fs = (int)((double)this.FontHeight * (t1 - t) / (t1 - t0) + 1); ass_out.Events.Add( ev.StartReplace(t).EndReplace(t + 0.4).LayerReplace(20).TextReplace( ASSEffect.pos(cx1, cy1) + ASSEffect.fs(fs) + ASSEffect.a(1, "BB") + ASSEffect.c(1, "FFFFFF") + ASSEffect.a(3, "BB") + ASSEffect.c(3, "FFFFFF") + ASSEffect.fad(0, 0.3) + ASSEffect.bord(1) + ASSEffect.blur(1) + ke.KText)); ass_out.Events.Add( ev.StartReplace(t).EndReplace(t + dt).TextReplace( ASSEffect.pos(cx1, cy1) + ASSEffect.fs(fs) + ASSEffect.pos(x, y) + ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") + ASSEffect.a(3, "FF") + ke.KText)); } } double bt_lo = t1; bt_lo = ev.Start - 0.3 + 0.2; double bt_hi = t2; Func <double, bool> bbt = ti => ti >= t1; if (!(iEv == 0 || iEv == 2 || iEv == 4 || iEv == 6 || iEv == 8)) { bt_lo = ev.Start - 0.2; bt_hi = t1; bbt = ti => ti < kStart; } if (iEv == 0 || iEv == 2 || iEv == 4 || iEv == 6 || iEv == 8) { double t3 = t2 + 0.3; if (iEv + 1 < ass_in.Events.Count && ass_in.Events[iEv + 1].Start - ev.End < 0.3) { t3 = t2 + 0.1; } for (int i = -1; i <= 1; i++) { ass_out.Events.Add( ev.StartReplace(t2).EndReplace(t3).TextReplace( ASSEffect.move(x, y, x + i * 10, y) + ASSEffect.a(1, "00") + ASSEffect.c(1, "FFFFFF") + ASSEffect.a(3, "00") + ASSEffect.c(3, "FFFFFF") + ASSEffect.bord(0) + ASSEffect.blur(0) + ASSEffect.t(0, t3 - t2, ASSEffect.xbord(20).t() + ASSEffect.be(20).t()) + ASSEffect.fad(0, t3 - t2) + ke.KText)); } } else { double te = ev.End + 0.5; //if (iEv == 9) te -= 1; bt_hi = te - 0.5; ass_out.Events.Add( ev.EndReplace(te).LayerReplace(10).TextReplace( ASSEffect.pos(x, y) + ASSEffect.a(1, "77") + ASSEffect.c(1, "777777") + ASSEffect.a(3, "FF") + ASSEffect.fad(0, 0.5) + ke.KText)); } foreach (Beat bt in GetBeats()) { if (bt.Strength == 0) { continue; } if (bt.Time >= bt_lo && bt.Time < bt_hi) { string col = "FFFFFF"; int blurstr = 4; string ac = "44"; if (bt.Strength == 2) { col = "EEEEEE"; blurstr = 3; ac = "77"; } if (bt.Strength == 10) { blurstr = 5; ac = "00"; } if (!bbt(bt.Time)) { blurstr = 2; col = "111111"; } ass_out.Events.Add( ev.StartReplace(bt.Time).EndReplace(bt.Time + 0.3).LayerReplace(55).TextReplace( ASSEffect.pos(x, y) + ASSEffect.fad(0.05, 0.2) + ASSEffect.a(1, ac) + ASSEffect.c(1, col) + ASSEffect.a(3, ac) + ASSEffect.c(3, col) + ASSEffect.bord(blurstr) + ASSEffect.blur(blurstr) + ke.KText)); } } } } ass_out.SaveFile(OutFileName); Console.WriteLine("Lines : {0}", ass_out.Events.Count); }