public override void WriteColorMap(int height, string filePath) { var width = 2 * height; if (ColorNoiseMap == null) { GenerateColorMap(height); } var bitmap = new DirectBitmap(width, height); var tempMean = Random.Uniform("life temperature mean", FreezingPoint, BoilingPoint); var tempVariance = Random.Uniform("life temperature variance", 20, 70); var sinPower = Random.Uniform("sin power", 0, 2); for (var x = 0; x < width; x++) { for (var y = 0; y < height; y++) { var value = ColorNoiseMap.GetValue(x, y); var col = OceanColor; if (!HasOcean || HeightNoiseMap.GetValue(x, y) > OceanLevel) { col = ColorScale.Color(value); } if (HasLife && HeightNoiseMap.GetValue(x, y) > OceanLevel) { var delta = Abs(TemperatureNoiseMap.GetValue(x, y) - tempMean) / tempVariance; if (delta < 0) { delta = 0; } if (delta > 1) { delta = 1; } delta *= (float)Pow(Sin(PI * y / height), sinPower); col = Interpolate(col, LifeColorScale.Color(value), delta); } if (HasAtmosphere && TemperatureNoiseMap.GetValue(x, y) < FreezingPoint * IceFactor) { col = IceColor; } bitmap.SetPixel(x, y, col); } } bitmap.Save(filePath); }
public override void WriteColorMap(int height, string filePath) { var width = 2 * height; if (ColorNoiseMap == null) { GenerateColorMap(height); } var bitmap = new DirectBitmap(width, height); for (var x = 0; x < width; x++) { for (var y = 0; y < height; y++) { var col = ColorScale.Color(ColorNoiseMap.GetValue(x, y)); bitmap.SetPixel(x, y, col); } } var total = 0.0; var count = 0; for (var x = 0; x < width; x += 10) { for (var y = 0; y < height; y += 10) { var col = bitmap.GetPixel(x, y); if (HasAtmosphere) { col = Interpolate(col, AtmosphereColor, AtmosphereOpacity); } var value = (col.R + col.G + col.B) / (255 * 3.0); value *= value; total += value; count++; } } Albedo = total / count; bitmap.Save(filePath); }