コード例 #1
0
        /// <summary>
        /// Generate points and store them into a list
        /// </summary>
        private void GeneratePoints(int amount)
        {
            //clear previous data
            _points.Clear();
            _voronoiDiagram.Clear();
            _cityData.Clear();

            //fill settings
            _voronoiSettings = new GenerationSettings
            {
                VoronoiAlgorithm = VoronoiAlgorithm,
                PointAlgorithm   = PointAlgorithm,
                Width            = Width,
                Length           = Height,
                StartX           = StartX,
                StartY           = StartY,
                UseSeed          = UseSeed,
                Seed             = Seed,
                Amount           = PointsToGenerate,
                CircleRadius     = Radius
            };

            //generate points
            var timer = Stopwatch.StartNew();

            _points = PointGenerator.Generate(_voronoiSettings);
            timer.Stop();

            //update generation timer
            var time = timer.ElapsedMilliseconds / 1000.0;

            GenerationTimeText = $"Generated {_points.Count} points in {time} seconds.";

            //update randomly generated seed
            if (UseSeed == false)
            {
                Seed = _voronoiSettings.Seed;
            }

            //update canvas
            RefreshCanvas();
        }