private int Threaded_Loop(int start, int end, Threading.ParamList paramList) { int counter = (int)paramList.Get("counter").Value; Engine.Threading.ThreadedLoop loop = new Threading.ThreadedLoop(); for (int ii = start; ii < end; ii++) { // collect pixels in each grid cell Engine.Color.Cell[] cells = new Engine.Color.Cell[t_cellSize * t_cellSize]; AutonomousParticle p = t_particles[ii]; Engine.Threading.ParamList paramList2 = new Threading.ParamList(); paramList2.Add("particle", typeof(AutonomousParticle), p); paramList2.Add("cells", typeof(Engine.Color.Cell[]), cells); paramList2.Add("counter", typeof(int), counter); loop.Loop(t_cellSize, Threaded_Loop_Cell_Part_1, paramList2); p.Move(); loop.Loop(t_cellSize, Threaded_Loop_Cell_Part_2, paramList2); } loop.Dispose(); return(0); }
private void SetGrid() { int numberRows = Width / t_gridCellWidth; int numberColumns = Height / t_gridCellHeight; /* * // depending on image ratio, portion of image may not be modified because there is one row missing * if (numberRows * t_gridCellWidth < Width) * { * numberRows++; * } * * // depending on image ratio, portion of image may not be modified because there is one column missing * if (numberColumns * t_gridCellHeight < Height) * { * numberColumns++; * }*/ t_cells = new PressureGridCell[numberRows, numberColumns]; Engine.Threading.ThreadedLoop loop = new Threading.ThreadedLoop(); Engine.Threading.ParamList paramList = new Threading.ParamList(); paramList.Add("numCol", typeof(int), numberColumns); loop.Loop(numberRows, Threaded_SetGrid, paramList); loop.Dispose(); }
internal override void Draw(MousePoint p) { if (t_particles.Length == 0) { return; } if (!t_skipper.Skip()) { return; } // atractor must follow the pen between each call to draw int[] delta = MousePoint.Delta(t_previousPoint, p); Engine.Calc.Vector d = new Engine.Calc.Vector(delta[0], delta[1]); t_attractor.Move(d); if (t_imageSource.IsOutOfBounds(p.X, p.Y)) { return; } Engine.Threading.ThreadedLoop loop = new Threading.ThreadedLoop(); Engine.Threading.ParamList paramList = new Threading.ParamList(); paramList.Add("x", typeof(int), p.X); paramList.Add("y", typeof(int), p.Y); loop.Loop(t_particles.Length, Threaded_Draw, paramList); loop.Dispose(); t_previousPoint = p; }
private void CreateFlowField() { t_flowField = new Engine.Calc.Vector[t_imageSource.Width, t_imageSource.Height]; Engine.Threading.ThreadedLoop loop = new Threading.ThreadedLoop(); Engine.Threading.ParamList paramList = new Threading.ParamList(); loop.Loop(t_imageSource.Height, Threaded_CreateFlowField, paramList); loop.Dispose(); }
public Engine.Effects.Code.Particles.AutonomousParticle[] GetParticles() { Engine.Effects.Code.Particles.AutonomousParticle[] particles = new Effects.Code.Particles.AutonomousParticle[t_cells.GetLength(0) * t_cells.GetLength(1)]; Engine.Threading.ParamList paramList = new Threading.ParamList(); paramList.Add("particles", typeof(int), particles); Engine.Threading.ThreadedLoop loop = new Threading.ThreadedLoop(); loop.Loop(t_cells.GetLength(0), Threaded_GetParticles, paramList); loop.Dispose(); return(particles); }
private void Loop() { Engine.Threading.ThreadedLoop loop = new Threading.ThreadedLoop(); for (int i = 0; i < t_flowLength; i++) { Engine.Threading.ParamList paramList = new Threading.ParamList(); paramList.Add("counter", typeof(int), i); loop.Loop(t_particles.Length, Threaded_Loop, paramList); } loop.Dispose(); }
/// <summary> /// /// </summary> /// <param name="x"></param> private void ParticleFlow(int x, float divSpread) { double divSpread255 = divSpread / 255; double divSpread2f = divSpread / 2f; Engine.Threading.ThreadedLoop loop = new Threading.ThreadedLoop(); Engine.Threading.ParamList paramList = new Threading.ParamList(); paramList.Add(paramName_X, typeof(int), x); paramList.Add(paramName_divSpread255, typeof(double), divSpread255); paramList.Add(paramName_divSpread2f, typeof(double), divSpread2f); loop.Loop(t_imageSource.Height, Threaded_ParticleFlow, paramList); loop.Dispose(); }
public static Engine.Surface.Canvas CreatePerlinNoisePlane(Engine.Surface.Canvas source, double frequency, int seed, int octaves) { Engine.Effects.Noise.IModule module = new Engine.Effects.Noise.Perlin(); ((Perlin)module).Frequency = frequency; ((Perlin)module).NoiseQuality = NoiseQuality.Standard; ((Perlin)module).Seed = seed; ((Perlin)module).OctaveCount = octaves; ((Perlin)module).Lacunarity = 2.0; ((Perlin)module).Persistence = 0.5; Engine.Surface.Canvas perlinSurface = new Canvas(source.Width, source.Height); Engine.Threading.ThreadedLoop loop = new Threading.ThreadedLoop(); Engine.Threading.ParamList paramList = new Threading.ParamList(); paramList.Add(paramName_module, typeof(Engine.Effects.Noise.IModule), module); paramList.Add(paramName_canvas, typeof(Engine.Surface.Canvas), perlinSurface); loop.Loop(source.Height, Threaded_CreatePerlinNoisePlane, paramList); loop.Dispose(); return(perlinSurface); }
private void Flow() { // starting with step 0 only gives transparent horizontal lines // because it reduces the alpha value to 0 for (int s = 1; s <= steps; s++) { byte alpha = (byte)(Engine.ColorOpacity.Opaque * s / steps); //byte alpha = 127; // particles need to be reset to left of image at each pass // otherwise they go off and only one layer of alpha particles are saved in image CreateParticles(alpha); Engine.Threading.ThreadedLoop loop = new Threading.ThreadedLoop(); loop.Loop(t_particles.Length, ParticleFlow, null); loop.Dispose(); // for some reason, last image refresh does not always work // bug exists only when threading Flow() System.Threading.Thread.Sleep(200); //ParticleFlow(0, t_particles.Length, null); } }
private void ThreadedProcess() { if (t_noiseType == NoiseTypes.Undefined) { t_noiseType = NoiseTypes.FastNoise; } Engine.Effects.Noise.IModule module; // switch block : source and info at : https://libnoisedotnet.codeplex.com/downloads/get/720936 // and http://libnoise.sourceforge.net/tutorials/tutorial8.html switch (t_noiseType) { case NoiseTypes.Billow: module = new Engine.Effects.Noise.Billow(); ((Billow)module).Frequency = t_frequency; ((Billow)module).NoiseQuality = NoiseQuality.Standard; ((Billow)module).Seed = t_seed; ((Billow)module).OctaveCount = t_octaves; ((Billow)module).Lacunarity = t_lacunarity; ((Billow)module).Persistence = t_persistence; break; case NoiseTypes.FastBillow: module = new Engine.Effects.Noise.FastBillow(); ((FastBillow)module).Frequency = t_frequency; ((FastBillow)module).NoiseQuality = NoiseQuality.Standard; ((FastBillow)module).Seed = t_seed; ((FastBillow)module).OctaveCount = t_octaves; ((FastBillow)module).Lacunarity = t_lacunarity; ((FastBillow)module).Persistence = t_persistence; break; case NoiseTypes.FastNoise: module = new Engine.Effects.Noise.FastNoise(); ((FastNoise)module).Frequency = t_frequency; ((FastNoise)module).NoiseQuality = NoiseQuality.Standard; ((FastNoise)module).Seed = t_seed; ((FastNoise)module).OctaveCount = t_octaves; ((FastNoise)module).Lacunarity = t_lacunarity; ((FastNoise)module).Persistence = t_persistence; break; default: module = new Engine.Effects.Noise.Perlin(); ((Perlin)module).Frequency = t_frequency; ((Perlin)module).NoiseQuality = NoiseQuality.Standard; ((Perlin)module).Seed = t_seed; ((Perlin)module).OctaveCount = t_octaves; ((Perlin)module).Lacunarity = t_lacunarity; ((Perlin)module).Persistence = t_persistence; break; } t_imageProcessed = new Engine.Surface.Canvas(t_imageSource.Width, t_imageSource.Height); t_workflow.AllowInvalidate = true; Engine.Threading.ThreadedLoop loop = new Threading.ThreadedLoop(); Engine.Threading.ParamList paramList = new Threading.ParamList(); paramList.Add(paramName_module, typeof(Engine.Effects.Noise.IModule), module); loop.Loop(t_imageSource.Height, Threaded_Process, paramList); loop.Dispose(); base.PostProcess(); }