Пример #1
0
    public static void TempImage(World world, Image img)
    {
        double[,] tempMap = world.GetMap <double>("temperature");
        Tuple <double, double> bounds = TerrainGenDemo.ArrayBounds2D(tempMap);

        double minTemp = bounds.Item1;
        double maxTemp = bounds.Item2;

        //int maxTemp = (int)world.GetProperty("maxtemp");
        //int minTemp = (int)world.GetProperty("mintemp");
        double tempDif = maxTemp - minTemp;

        Color hotColor  = new Color(255, 0, 0, 150);
        Color coldColor = new Color(255, 0, 0, 0);

        for (int x = 0; x < world.Width; x++)
        {
            for (int y = 0; y < world.Height; y++)
            {
                double t      = (tempMap[x, y] - minTemp) / tempDif;
                Color  pixCol = TerrainGenDemo.ColorLerp(coldColor, hotColor, t);
                img.SetPixel((uint)x, (uint)y, pixCol);
            }
        }
    }
 public Color GetPixelColor()
 {
     if (TreeTropical > 0 && TreeTropical >= TreeConifer && TreeTropical >= TreeDeciduous && TreeTropical >= Grass)
     {
         return(new Color(0, 230, 0, 255));
     }
     if (TreeDeciduous > 0 && TreeDeciduous >= TreeConifer && TreeDeciduous >= Grass)
     {
         return(new Color(50, 180, 50, 255));
     }
     if (TreeConifer > 0 && TreeConifer >= Grass)
     {
         return(new Color(20, 100, 20, 255));
     }
     if (Grass > 0)
     {
         //return new Color(100,200,100,255);
         return(TerrainGenDemo.ColorLerp(new Color(200, 200, 50, 255), new Color(100, 200, 100, 255), Math.Min(Grass / 20.0, 1.0)));
     }
     return(new Color(0, 0, 0, 0));
 }