ConsoleEngineMath Class
Description
The ConsoleEngineMath class provides utility methods for calculating Perlin noise and color mapping.
Methods
CalculatePerlinNoise(int x, int y, float scaleX, float scaleY, int seed): float
: Calculates Perlin noise value at the specified coordinates.GetColorFromPerlinValue(float perlinValue, ConsoleColor consoleColor1 = ConsoleColor.Blue, ConsoleColor consoleColor2 = ConsoleColor.Cyan, ConsoleColor consoleColor3 = ConsoleColor.Green, ConsoleColor consoleColor4 = ConsoleColor.Yellow, ConsoleColor consoleColor5 = ConsoleColor.White): ConsoleColor
: Maps the Perlin value to a ConsoleColor based on predefined thresholds.
Usage
To calculate Perlin noise at a specific position, you can use the CalculatePerlinNoise
method:
// Example usage
int x = 10;
int y = 5;
float scaleX = 0.1f;
float scaleY = 0.2f;
int seed = 12345;
float perlinValue = ConsoleEngineMath.CalculatePerlinNoise(x, y, scaleX, scaleY, seed);
To map a Perlin value to a ConsoleColor, you can use the GetColorFromPerlinValue
method:
// Example usage
float perlinValue = 0.35f;
ConsoleColor color = ConsoleEngineMath.GetColorFromPerlinValue(perlinValue);
The GetColorFromPerlinValue
method maps the Perlin value to a ConsoleColor based on predefined thresholds. You can customize the color mapping by providing your own ConsoleColor values or modifying the method implementation.