Review coding conventions

This commit is contained in:
Ray 2023-05-22 16:06:03 +02:00
parent a4a6d4da8a
commit 2937f2010c

View file

@ -696,23 +696,22 @@ Image GenImageGradientLinear(int width, int height, int direction, Color start,
float cosDir = cos(radianDirection);
float sinDir = sin(radianDirection);
int i, j;
for (i = 0; i < width; i++)
for (int i = 0; i < width; i++)
{
for (j = 0; j < height; j++)
for (int j = 0; j < height; j++)
{
// Calculate the relative position of the pixel along the gradient direction
float pos = (i*cosDir + j*sinDir)/(width*cosDir + height*sinDir);
float factor = pos;
factor = (factor > 1.f) ? 1.f : factor; // Clamp to [0,1]
factor = (factor < 0.f) ? 0.f : factor; // Clamp to [0,1]
factor = (factor > 1.0f)? 1.0f : factor; // Clamp to [0,1]
factor = (factor < 0.0f)? 0.0f : factor; // Clamp to [0,1]
// Generate the color for this pixel
pixels[j * width + i].r = (int)((float)end.r*factor + (float)start.r*(1.f - factor));
pixels[j * width + i].g = (int)((float)end.g*factor + (float)start.g*(1.f - factor));
pixels[j * width + i].b = (int)((float)end.b*factor + (float)start.b*(1.f - factor));
pixels[j * width + i].a = (int)((float)end.a*factor + (float)start.a*(1.f - factor));
pixels[j*width + i].r = (int)((float)end.r*factor + (float)start.r*(1.0f - factor));
pixels[j*width + i].g = (int)((float)end.g*factor + (float)start.g*(1.0f - factor));
pixels[j*width + i].b = (int)((float)end.b*factor + (float)start.b*(1.0f - factor));
pixels[j*width + i].a = (int)((float)end.a*factor + (float)start.a*(1.0f - factor));
}
}
@ -792,7 +791,7 @@ Image GenImageGradientSquare(int width, int height, float density, Color inner,
float factor = (manhattanDist - density)/(1.0f - density);
// Clamp the factor between 0 and 1
factor = fminf(fmaxf(factor, 0.f), 1.f);
factor = fminf(fmaxf(factor, 0.0f), 1.0f);
// Blend the colors based on the calculated factor
pixels[y*width + x].r = (int)((float)outer.r*factor + (float)inner.r*(1.0f - factor));