Remove params from GenImageGradientSquare
This commit is contained in:
parent
42156ffd76
commit
0f6f2677e7
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
#define NUM_TEXTURES 10 // Currently we have 8 generation algorithms but some are have multiple purposes (Linear and Square Gradients)
|
#define NUM_TEXTURES 9 // Currently we have 8 generation algorithms but some are have multiple purposes (Linear and Square Gradients)
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
// Program main entry point
|
// Program main entry point
|
||||||
|
|
@ -31,8 +31,7 @@ int main(void)
|
||||||
Image horizontalGradient = GenImageGradientLinear(screenWidth, screenHeight, 90, RED, BLUE);
|
Image horizontalGradient = GenImageGradientLinear(screenWidth, screenHeight, 90, RED, BLUE);
|
||||||
Image diagonalGradient = GenImageGradientLinear(screenWidth, screenHeight, 45, RED, BLUE);
|
Image diagonalGradient = GenImageGradientLinear(screenWidth, screenHeight, 45, RED, BLUE);
|
||||||
Image radialGradient = GenImageGradientRadial(screenWidth, screenHeight, 0.0f, WHITE, BLACK);
|
Image radialGradient = GenImageGradientRadial(screenWidth, screenHeight, 0.0f, WHITE, BLACK);
|
||||||
Image squareGradient = GenImageGradientSquare(screenWidth, screenHeight, screenHeight*0.9, screenHeight*0.9, 0.0f, WHITE, BLACK);
|
Image squareGradient = GenImageGradientSquare(screenWidth, screenHeight, 0.0f, WHITE, BLACK);
|
||||||
Image rectangularGradient = GenImageGradientSquare(screenWidth, screenHeight, screenWidth, screenHeight, 0.0f, WHITE, BLACK);
|
|
||||||
Image checked = GenImageChecked(screenWidth, screenHeight, 32, 32, RED, BLUE);
|
Image checked = GenImageChecked(screenWidth, screenHeight, 32, 32, RED, BLUE);
|
||||||
Image whiteNoise = GenImageWhiteNoise(screenWidth, screenHeight, 0.5f);
|
Image whiteNoise = GenImageWhiteNoise(screenWidth, screenHeight, 0.5f);
|
||||||
Image perlinNoise = GenImagePerlinNoise(screenWidth, screenHeight, 50, 50, 4.0f);
|
Image perlinNoise = GenImagePerlinNoise(screenWidth, screenHeight, 50, 50, 4.0f);
|
||||||
|
|
@ -45,11 +44,10 @@ int main(void)
|
||||||
textures[2] = LoadTextureFromImage(diagonalGradient);
|
textures[2] = LoadTextureFromImage(diagonalGradient);
|
||||||
textures[3] = LoadTextureFromImage(radialGradient);
|
textures[3] = LoadTextureFromImage(radialGradient);
|
||||||
textures[4] = LoadTextureFromImage(squareGradient);
|
textures[4] = LoadTextureFromImage(squareGradient);
|
||||||
textures[5] = LoadTextureFromImage(rectangularGradient);
|
textures[5] = LoadTextureFromImage(checked);
|
||||||
textures[6] = LoadTextureFromImage(checked);
|
textures[6] = LoadTextureFromImage(whiteNoise);
|
||||||
textures[7] = LoadTextureFromImage(whiteNoise);
|
textures[7] = LoadTextureFromImage(perlinNoise);
|
||||||
textures[8] = LoadTextureFromImage(perlinNoise);
|
textures[8] = LoadTextureFromImage(cellular);
|
||||||
textures[9] = LoadTextureFromImage(cellular);
|
|
||||||
|
|
||||||
// Unload image data (CPU RAM)
|
// Unload image data (CPU RAM)
|
||||||
UnloadImage(verticalGradient);
|
UnloadImage(verticalGradient);
|
||||||
|
|
@ -97,11 +95,10 @@ int main(void)
|
||||||
case 2: DrawText("DIAGONAL GRADIENT", 540, 10, 20, RAYWHITE); break;
|
case 2: DrawText("DIAGONAL GRADIENT", 540, 10, 20, RAYWHITE); break;
|
||||||
case 3: DrawText("RADIAL GRADIENT", 580, 10, 20, LIGHTGRAY); break;
|
case 3: DrawText("RADIAL GRADIENT", 580, 10, 20, LIGHTGRAY); break;
|
||||||
case 4: DrawText("SQUARE GRADIENT", 580, 10, 20, LIGHTGRAY); break;
|
case 4: DrawText("SQUARE GRADIENT", 580, 10, 20, LIGHTGRAY); break;
|
||||||
case 5: DrawText("RECTANGULAR GRADIENT", 530, 10, 20, LIGHTGRAY); break;
|
case 5: DrawText("CHECKED", 680, 10, 20, RAYWHITE); break;
|
||||||
case 6: DrawText("CHECKED", 680, 10, 20, RAYWHITE); break;
|
case 6: DrawText("WHITE NOISE", 640, 10, 20, RED); break;
|
||||||
case 7: DrawText("WHITE NOISE", 640, 10, 20, RED); break;
|
case 7: DrawText("PERLIN NOISE", 640, 10, 20, RED); break;
|
||||||
case 8: DrawText("PERLIN NOISE", 640, 10, 20, RED); break;
|
case 8: DrawText("CELLULAR", 670, 10, 20, RAYWHITE); break;
|
||||||
case 9: DrawText("CELLULAR", 670, 10, 20, RAYWHITE); break;
|
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6307,14 +6307,6 @@
|
||||||
"type": "int",
|
"type": "int",
|
||||||
"name": "height"
|
"name": "height"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "int",
|
|
||||||
"name": "gradientWidth"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "int",
|
|
||||||
"name": "gradientHeight"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "float",
|
"type": "float",
|
||||||
"name": "density"
|
"name": "density"
|
||||||
|
|
|
||||||
|
|
@ -5026,8 +5026,6 @@ return {
|
||||||
params = {
|
params = {
|
||||||
{type = "int", name = "width"},
|
{type = "int", name = "width"},
|
||||||
{type = "int", name = "height"},
|
{type = "int", name = "height"},
|
||||||
{type = "int", name = "gradientWidth"},
|
|
||||||
{type = "int", name = "gradientHeight"},
|
|
||||||
{type = "float", name = "density"},
|
{type = "float", name = "density"},
|
||||||
{type = "Color", name = "inner"},
|
{type = "Color", name = "inner"},
|
||||||
{type = "Color", name = "outer"}
|
{type = "Color", name = "outer"}
|
||||||
|
|
|
||||||
|
|
@ -2434,17 +2434,15 @@ Function 247: GenImageGradientRadial() (5 input parameters)
|
||||||
Param[3]: density (type: float)
|
Param[3]: density (type: float)
|
||||||
Param[4]: inner (type: Color)
|
Param[4]: inner (type: Color)
|
||||||
Param[5]: outer (type: Color)
|
Param[5]: outer (type: Color)
|
||||||
Function 248: GenImageGradientSquare() (7 input parameters)
|
Function 248: GenImageGradientSquare() (5 input parameters)
|
||||||
Name: GenImageGradientSquare
|
Name: GenImageGradientSquare
|
||||||
Return type: Image
|
Return type: Image
|
||||||
Description: Generate image: square gradient
|
Description: Generate image: square gradient
|
||||||
Param[1]: width (type: int)
|
Param[1]: width (type: int)
|
||||||
Param[2]: height (type: int)
|
Param[2]: height (type: int)
|
||||||
Param[3]: gradientWidth (type: int)
|
Param[3]: density (type: float)
|
||||||
Param[4]: gradientHeight (type: int)
|
Param[4]: inner (type: Color)
|
||||||
Param[5]: density (type: float)
|
Param[5]: outer (type: Color)
|
||||||
Param[6]: inner (type: Color)
|
|
||||||
Param[7]: outer (type: Color)
|
|
||||||
Function 249: GenImageChecked() (6 input parameters)
|
Function 249: GenImageChecked() (6 input parameters)
|
||||||
Name: GenImageChecked
|
Name: GenImageChecked
|
||||||
Return type: Image
|
Return type: Image
|
||||||
|
|
|
||||||
|
|
@ -1563,11 +1563,9 @@
|
||||||
<Param type="Color" name="inner" desc="" />
|
<Param type="Color" name="inner" desc="" />
|
||||||
<Param type="Color" name="outer" desc="" />
|
<Param type="Color" name="outer" desc="" />
|
||||||
</Function>
|
</Function>
|
||||||
<Function name="GenImageGradientSquare" retType="Image" paramCount="7" desc="Generate image: square gradient">
|
<Function name="GenImageGradientSquare" retType="Image" paramCount="5" desc="Generate image: square gradient">
|
||||||
<Param type="int" name="width" desc="" />
|
<Param type="int" name="width" desc="" />
|
||||||
<Param type="int" name="height" desc="" />
|
<Param type="int" name="height" desc="" />
|
||||||
<Param type="int" name="gradientWidth" desc="" />
|
|
||||||
<Param type="int" name="gradientHeight" desc="" />
|
|
||||||
<Param type="float" name="density" desc="" />
|
<Param type="float" name="density" desc="" />
|
||||||
<Param type="Color" name="inner" desc="" />
|
<Param type="Color" name="inner" desc="" />
|
||||||
<Param type="Color" name="outer" desc="" />
|
<Param type="Color" name="outer" desc="" />
|
||||||
|
|
|
||||||
|
|
@ -213,7 +213,7 @@ ImageColorReplace|void|(Image *image, Color color, Color replace);|
|
||||||
GenImageColor|Image|(int width, int height, Color color);|
|
GenImageColor|Image|(int width, int height, Color color);|
|
||||||
GenImageGradientLinear|Image|(int width, int height, int direction, Color start, Color end);|
|
GenImageGradientLinear|Image|(int width, int height, int direction, Color start, Color end);|
|
||||||
GenImageGradientRadial|Image|(int width, int height, float density, Color inner, Color outer);|
|
GenImageGradientRadial|Image|(int width, int height, float density, Color inner, Color outer);|
|
||||||
GenImageGradientSquare|Image|(int width, int height, int gradientWidth, int gradientHeight, float density, Color inner, Color outer);|
|
GenImageGradientSquare|Image|(int width, int height, float density, Color inner, Color outer);|
|
||||||
GenImageChecked|Image|(int width, int height, int checksX, int checksY, Color col1, Color col2);|
|
GenImageChecked|Image|(int width, int height, int checksX, int checksY, Color col1, Color col2);|
|
||||||
GenImageWhiteNoise|Image|(int width, int height, float factor);|
|
GenImageWhiteNoise|Image|(int width, int height, float factor);|
|
||||||
GenImagePerlinNoise|Image|(int width, int height, int offsetX, int offsetY, float scale);|
|
GenImagePerlinNoise|Image|(int width, int height, int offsetX, int offsetY, float scale);|
|
||||||
|
|
|
||||||
|
|
@ -1400,8 +1400,6 @@
|
||||||
<Overload retVal="Image" descr="Generate image: square gradient">
|
<Overload retVal="Image" descr="Generate image: square gradient">
|
||||||
<Param name="int width" />
|
<Param name="int width" />
|
||||||
<Param name="int height" />
|
<Param name="int height" />
|
||||||
<Param name="int gradiantWidth" />
|
|
||||||
<Param name="int gradientHeight" />
|
|
||||||
<Param name="float density" />
|
<Param name="float density" />
|
||||||
<Param name="Color inner" />
|
<Param name="Color inner" />
|
||||||
<Param name="Color outer" />
|
<Param name="Color outer" />
|
||||||
|
|
|
||||||
|
|
@ -319,7 +319,7 @@ RLAPI bool ExportImageAsCode(Image image, const char *fileName);
|
||||||
RLAPI Image GenImageColor(int width, int height, Color color); // Generate image: plain color
|
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
|
RLAPI Image GenImageGradientLinear(int width, int height, int direction, Color start, Color end); // Generate image: linear gradient
|
||||||
RLAPI Image GenImageGradientRadial(int width, int height, float density, Color inner, Color outer); // Generate image: radial 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 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 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
|
RLAPI Image GenImagePerlinNoise(int width, int height, int offsetX, int offsetY, float scale); // Generate image: perlin noise
|
||||||
|
|
|
||||||
|
|
@ -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 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 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 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 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 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
|
RLAPI Image GenImagePerlinNoise(int width, int height, int offsetX, int offsetY, float scale); // Generate image: perlin noise
|
||||||
|
|
|
||||||
|
|
@ -765,16 +765,13 @@ Image GenImageGradientRadial(int width, int height, float density, Color inner,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate image: square gradient
|
// 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));
|
Color *pixels = (Color *)RL_MALLOC(width*height*sizeof(Color));
|
||||||
|
|
||||||
float centerX = (float)width/2.0f;
|
float centerX = (float)width/2.0f;
|
||||||
float centerY = (float)height/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 y = 0; y < height; y++)
|
||||||
{
|
{
|
||||||
for (int x = 0; x < width; x++)
|
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);
|
float distY = fabsf(y - centerY);
|
||||||
|
|
||||||
// Normalize the distances by the dimensions of the gradient rectangle
|
// Normalize the distances by the dimensions of the gradient rectangle
|
||||||
float normalizedDistX = distX / gradientCenterX;
|
float normalizedDistX = distX / centerX;
|
||||||
float normalizedDistY = distY / gradientCenterY;
|
float normalizedDistY = distY / centerY;
|
||||||
|
|
||||||
// Calculate the total normalized Manhattan distance
|
// Calculate the total normalized Manhattan distance
|
||||||
float manhattanDist = fmax(normalizedDistX, normalizedDistY);
|
float manhattanDist = fmax(normalizedDistX, normalizedDistY);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user