public static SwiftBitmap Generate(int Width, int Height, int NumberOfPoints, int Seed)
        {
            float[,] DistanceBuffer = new float[Width, Height];
            float MinimumDistance = float.MaxValue;
            float MaxDistance     = float.MinValue;
            var   Map             = new CellularMap(Seed, Width, Height, NumberOfPoints);

            MaxDistance     = Map.MaxDistance;
            MinimumDistance = Map.MinDistance;
            DistanceBuffer  = Map.Distances;
            var ReturnValue = new SwiftBitmap(Width, Height);

            ReturnValue.Lock();
            for (int x = 0; x < Width; ++x)
            {
                for (int y = 0; y < Height; ++y)
                {
                    float Value = GetHeight(x, y, DistanceBuffer, MinimumDistance, MaxDistance);
                    Value *= 255;
                    int RGBValue = ((int)Value).Clamp(255, 0);
                    ReturnValue.SetPixel(x, y, Color.FromArgb(RGBValue, RGBValue, RGBValue));
                }
            }
            return(ReturnValue.Unlock());
        }
        public static SwiftBitmap Generate(int Width, int Height, int NumberFaults, int Seed)
        {
            float[,] Heights = new float[Width, Height];
            float IncreaseVal = 0.1f;
            var   Generator   = new System.Random(Seed);

            for (int x = 0; x < NumberFaults; ++x)
            {
                IncreaseVal = GenerateFault(Width, Height, NumberFaults, Heights, IncreaseVal, Generator);
            }
            var ReturnValue = new SwiftBitmap(Width, Height);

            ReturnValue.Lock();
            for (int x = 0; x < Width; ++x)
            {
                for (int y = 0; y < Height; ++y)
                {
                    float Value = Heights[x, y];
                    Value  = (Value * 0.5f) + 0.5f;
                    Value *= 255;
                    int RGBValue = ((int)Value).Clamp(255, 0);
                    ReturnValue.SetPixel(x, y, Color.FromArgb(RGBValue, RGBValue, RGBValue));
                }
            }
            return(ReturnValue.Unlock());
        }
 public static SwiftBitmap Generate(int Width, int Height, int MaxRGBValue, int MinRGBValue,
     float Frequency, float Amplitude, float Persistance, int Octaves, int Seed)
 {
     var ReturnValue = new SwiftBitmap(Width, Height);
     ReturnValue.Lock();
     var Noise = GenerateNoise(Seed, Width, Height);
     for (int x = 0; x < Width; ++x)
     {
         for (int y = 0; y < Height; ++y)
         {
             var Value = GetValue(x, y, Width, Height, Frequency, Amplitude, Persistance, Octaves, Noise);
             Value = (Value * 0.5f) + 0.5f;
             Value *= 255;
             var RGBValue = ((int)Value).Clamp(MaxRGBValue, MinRGBValue);
             ReturnValue.SetPixel(x, y, Color.FromArgb(RGBValue, RGBValue, RGBValue));
         }
     }
     return ReturnValue.Unlock();
 }
示例#4
0
        public static SwiftBitmap Generate(int Width, int Height, int MaxRGBValue, int MinRGBValue,
                                           float Frequency, float Amplitude, float Persistance, int Octaves, int Seed)
        {
            var ReturnValue = new SwiftBitmap(Width, Height);

            ReturnValue.Lock();
            float[,] Noise = GenerateNoise(Seed, Width, Height);
            for (int x = 0; x < Width; ++x)
            {
                for (int y = 0; y < Height; ++y)
                {
                    float Value = GetValue(x, y, Width, Height, Frequency, Amplitude, Persistance, Octaves, Noise);
                    Value  = (Value * 0.5f) + 0.5f;
                    Value *= 255;
                    int RGBValue = ((int)Value).Clamp(MaxRGBValue, MinRGBValue);
                    ReturnValue.SetPixel(x, y, Color.FromArgb(RGBValue, RGBValue, RGBValue));
                }
            }
            return(ReturnValue.Unlock());
        }
 public static SwiftBitmap Generate(int Width, int Height, int NumberOfPoints, int Seed)
 {
     float[,] DistanceBuffer = new float[Width, Height];
     float MinimumDistance = float.MaxValue;
     float MaxDistance = float.MinValue;
     var Map = new CellularMap(Seed, Width, Height, NumberOfPoints);
     MaxDistance = Map.MaxDistance;
     MinimumDistance = Map.MinDistance;
     DistanceBuffer = Map.Distances;
     var ReturnValue = new SwiftBitmap(Width, Height);
     ReturnValue.Lock();
     for (int x = 0; x < Width; ++x)
     {
         for (int y = 0; y < Height; ++y)
         {
             var Value = GetHeight(x, y, DistanceBuffer, MinimumDistance, MaxDistance);
             Value *= 255;
             var RGBValue = ((int)Value).Clamp(255, 0);
             ReturnValue.SetPixel(x, y, Color.FromArgb(RGBValue, RGBValue, RGBValue));
         }
     }
     return ReturnValue.Unlock();
 }
 public static SwiftBitmap Generate(int Width, int Height, int NumberFaults, int Seed)
 {
     float[,] Heights = new float[Width, Height];
     float IncreaseVal = 0.1f;
     var Generator = new System.Random(Seed);
     for (int x = 0; x < NumberFaults; ++x)
     {
         IncreaseVal = GenerateFault(Width, Height, NumberFaults, Heights, IncreaseVal, Generator);
     }
     var ReturnValue = new SwiftBitmap(Width, Height);
     ReturnValue.Lock();
     for (int x = 0; x < Width; ++x)
     {
         for (int y = 0; y < Height; ++y)
         {
             float Value = Heights[x, y];
             Value = (Value * 0.5f) + 0.5f;
             Value *= 255;
             int RGBValue = ((int)Value).Clamp(255, 0);
             ReturnValue.SetPixel(x, y, Color.FromArgb(RGBValue, RGBValue, RGBValue));
         }
     }
     return ReturnValue.Unlock();
 }