//--- Public methods --- public FluidSimulator(Progress prog, RandomJames _rnd = null) { // particles: particles = null; activeParticles = 0; TotalSpawned = 0L; // boundaries: walls = null; xMin = 0.0; xMax = 3.0; yMin = 0.0; yMax = 1.0; InitWalls(); progress = prog; // random generator: rnd = _rnd; if (rnd == null) { rnd = new RandomJames(); rnd.Randomize(); } }
static public void Generate() { wasGenerated = true; // !!!{{ TODO - generate and draw maze in SVG format string fileName = CmdOptions.options.outputFileName; if (string.IsNullOrEmpty(fileName)) { fileName = CmdOptions.options.html ? "out.html" : "out.svg"; } string outFn = Path.Combine(CmdOptions.options.outDir, fileName); // SVG output: using (StreamWriter wri = new StreamWriter(outFn)) { if (CmdOptions.options.html) { wri.WriteLine("<!DOCTYPE html>"); wri.WriteLine("<meta charset=\"utf-8\">"); wri.WriteLine($"<title>SVG test ({CmdOptions.options.name})</title>"); wri.WriteLine(string.Format(CultureInfo.InvariantCulture, "<svg width=\"{0:f0}\" height=\"{1:f0}\">", CmdOptions.options.width, CmdOptions.options.height)); } else { wri.WriteLine(string.Format(CultureInfo.InvariantCulture, "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"{0:f0}\" height=\"{1:f0}\">", CmdOptions.options.width, CmdOptions.options.height)); } List <Vector2> workList = new List <Vector2>(); RandomJames rnd = new RandomJames(); if (CmdOptions.options.seed > 0L) { rnd.Reset(CmdOptions.options.seed); } else { rnd.Randomize(); } for (int i = 0; i < CmdOptions.options.columns; i++) { workList.Add(new Vector2(rnd.RandomFloat(0.0f, (float)CmdOptions.options.width), rnd.RandomFloat(0.0f, (float)CmdOptions.options.height))); } drawCurve(wri, workList, 0, 0, string.Format("#{0:X2}{0:X2}{0:X2}", 0)); wri.WriteLine("</svg>"); // !!!}} } }
/// <summary> /// Random generator init. /// </summary> /// <param name="seed">Random seed or 0L for Randomize().</param> /// <returns></returns> public long SetSeed(long seed) { if (seed <= 0L) { seed = rnd.Randomize(); } else { rnd.Reset(seed); } return(seed); }