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 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(); }