override public void Process(Spectra s, Dictionary <String, Variant> v, byte[] b) { for (int i = 0; i < b.Length; i++) { b[i] = (byte)Convert.ToInt32(exp.DynamicInvoke(new object[] { b, (int)b[i], b.Length, i, s, v, s.GetBuffers() })); } }
override public void Process(Spectra s, Dictionary <String, Variant> v, byte[] b) { for (int i = 0; i < b.Length; i++) { b[i] = (byte)(255 - b[i]); } }
override public void Process(Spectra s, Dictionary <String, Variant> v, byte[] b) { var copy = s.GetBuffer(args[0].s); for (int i = 0; i < b.Length; i++) { b[i] = copy[i]; } }
override public void Process(Spectra s, Dictionary <String, Variant> v, byte[] b) { float dvdx = (args[END].i - args[START].i) / (float)(b.Length - 1); for (int i = 0; i < b.Length; i++) { b[i] = (byte)(args[START].i + dvdx * i); } }
override public void Process(Spectra s, Dictionary <String, Variant> v, byte[] b) { byte value = (byte)args[CONSTANT].i; for (int i = 0; i < b.Length; i++) { b[i] = value; } }
override public void Process(Spectra s, Dictionary <String, Variant> v, byte[] b) { for (int i = 0; i < b.Length; i++) { if (r.NextDouble() < args[0].f) { b[i] = (byte)args[1].i; } } }
override public void Process(Spectra s, Dictionary <String, Variant> v, byte[] b) { var opt = args[0].s; var opn = args[1].f; var func = funcs[opt]; for (int i = 0; i < b.Length; i++) { b[i] = (byte)Convert.ToInt32(func((float)b[i], opn)); } }
override public void Process(Spectra s, Dictionary <String, Variant> v, byte[] b) { if (gradients == null) { heights = new float[b.Length]; gradients = new float[b.Length]; } for (int i = 1; i < b.Length - 1; i++) { if (b[i] == 255) { heights[i] = 255; } } float momentum = args[0].f; float speed = args[1].f; float decay = args[2].f; gradients[0] = gradients[0] * momentum + (b[1] - b[0]) * (1 - momentum); gradients[b.Length - 1] = gradients[b.Length - 1] * momentum + (b[b.Length - 2] - b[b.Length - 1]) * (1 - momentum); for (int i = 1; i < b.Length - 1; i++) { gradients[i] = gradients[i] * momentum + ((b[i - 1] - b[i]) * (1 - momentum) + (b[i + 1] - b[i]) * (1 - momentum)) * 0.5f; } float dt = v["SPECTRA_DELTA_TIME"].f; for (int i = 0; i < b.Length; i++) { heights[i] = (heights[i] + gradients[i] * speed * dt); b[i] = (byte)heights[i]; heights[i] *= decay; gradients[i] *= decay; } }
public static void Main(string[] args) { var spectra = new Spectra(); spectra.RunSpectraCommandLine(); }
abstract public void Process(Spectra s, Dictionary <String, Variant> v, byte[] b);