Remove params from GenImageGradientSquare

This commit is contained in:
dane_madsen 2023-05-22 20:35:59 +10:00
commit 0f6f2677e7
2 changed files with 21 additions and 43 deletions

View file

@ -1241,7 +1241,7 @@ RLAPI bool ExportImageAsCode(Image image, const char *fileName);
RLAPI Image GenImageColor(int width, int height, Color color); // Generate image: plain color
RLAPI Image GenImageGradientLinear(int width, int height, int direction, Color start, Color end); // Generate image: linear gradient, direction in degrees [0..360], 0=Vertical gradient
RLAPI Image GenImageGradientRadial(int width, int height, float density, Color inner, Color outer); // Generate image: radial gradient
RLAPI Image GenImageGradientSquare(int width, int height, int gradientWidth, int gradientHeight, float density, Color inner, Color outer); // Generate image: square gradient
RLAPI Image GenImageGradientSquare(int width, int height, float density, Color inner, Color outer); // Generate image: square gradient
RLAPI Image GenImageChecked(int width, int height, int checksX, int checksY, Color col1, Color col2); // Generate image: checked
RLAPI Image GenImageWhiteNoise(int width, int height, float factor); // Generate image: white noise
RLAPI Image GenImagePerlinNoise(int width, int height, int offsetX, int offsetY, float scale); // Generate image: perlin noise

View file

@ -765,16 +765,13 @@ Image GenImageGradientRadial(int width, int height, float density, Color inner,
}
// Generate image: square gradient
Image GenImageGradientSquare(int width, int height, int gradientWidth, int gradientHeight, float density, Color inner, Color outer)
Image GenImageGradientSquare(int width, int height, float density, Color inner, Color outer)
{
Color *pixels = (Color *)RL_MALLOC(width*height*sizeof(Color));
float centerX = (float)width/2.0f;
float centerY = (float)height/2.0f;
float gradientCenterX = gradientWidth / 2.0f;
float gradientCenterY = gradientHeight / 2.0f;
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
@ -784,8 +781,8 @@ Image GenImageGradientSquare(int width, int height, int gradientWidth, int gradi
float distY = fabsf(y - centerY);
// Normalize the distances by the dimensions of the gradient rectangle
float normalizedDistX = distX / gradientCenterX;
float normalizedDistY = distY / gradientCenterY;
float normalizedDistX = distX / centerX;
float normalizedDistY = distY / centerY;
// Calculate the total normalized Manhattan distance
float manhattanDist = fmax(normalizedDistX, normalizedDistY);