コード例 #1
0
    /// <summary>
    /// Generate the voronoi diagram
    /// </summary>
    public void GenerateVoronoi()
    {
        /*
         * Test seeds
         * 1056279151
         * 1188430406
         * 916508404
         * 1161899265
         * 1969582979
         * 380612368
         * 1517822890
         * 1720479531
         * 1817852180
         * 571502800
         * 981687587
         * 1884839221
         * 1869074966
         * 90542208
         * 1961817730
         * 1342973776
         * 1654753252
         * 355825481
         * 1316400197
         * 1401185548
         * 924199008
         */

        Random.InitState((int)System.DateTime.Now.Ticks);

        //check if we need to generate a random seed
        if (RandomSeed)
        {
            Seed = Random.Range(0, int.MaxValue);
        }
        //Setup the Voronoi with sites
        _voronoi.RandomCells(Voronoi.SiteCount, Voronoi.GridSize, Seed);
        //Calculate the voronoi diagram
        _voronoi.Calculate();
        //clip the voronoi diagram
        _voronoi.Clip(Voronoi.GridSize);
    }