private void InitializeVoronoi() { _sitesToIgnore = new HashSet <Site>(); Console.Clear(); nudStepTo.Value = 0; Edge.EdgeCount = 0; var rand = new Random((int)nudSeed.Value); var w = splitPanel.Panel2.ClientSize.Width; var h = splitPanel.Panel2.ClientSize.Height; var numSites = (int)nudNumRegions.Value; var sites = new List <PointF>(); Console.WriteLine(w); Console.WriteLine(h); for (int i = 0; i < numSites; i++) { var p = new Point(rand.Next(w), rand.Next(h)); sites.Add(p); } if (nudRelax.Value > 0) { sites = RelaxPoints((int)nudRelax.Value, sites); } _voronoi = new Voronoi(sites, w, h, chDebug.Checked); _graph = _voronoi.Initialize(); }
private void btnAnimate_Click(object sender, EventArgs e) { if (_voronoi == null) { InitializeVoronoi(); } var startStep = nudStepTo.Value; Animate(); if (nudStepTo.Value == startStep) { _voronoi = null; btnAnimate_Click(sender, e); } }
private void InitializeVoronoi() { _sitesToIgnore = new HashSet<Site>(); Console.Clear(); nudStepTo.Value = 0; Edge.EdgeCount = 0; var rand = new Random((int)nudSeed.Value); var w = splitPanel.Panel2.ClientSize.Width; var h = splitPanel.Panel2.ClientSize.Height; var numSites = (int)nudNumRegions.Value; var sites = new List<PointF>(); Console.WriteLine(w); Console.WriteLine(h); for (int i = 0; i < numSites; i++) { var p = new Point(rand.Next(w), rand.Next(h)); sites.Add(p); } if (nudRelax.Value > 0) { sites = RelaxPoints((int)nudRelax.Value, sites); } _voronoi = new Voronoi(sites, w, h, chDebug.Checked); _graph = _voronoi.Initialize(); }