Quellcode durchsuchen

Fixing GenImagePerlinNoise() being stretched, if Image is not rectangular (#4276)

pull/4282/head
Bugsia vor 7 Monaten
committed von GitHub
Ursprung
Commit
77172e34db
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden GPG-Schlüssel-ID: B5690EEEBB952194
1 geänderte Dateien mit 5 neuen und 0 gelöschten Zeilen
  1. +5
    -0
      src/rtextures.c

+ 5
- 0
src/rtextures.c Datei anzeigen

@ -1112,6 +1112,7 @@ Image GenImagePerlinNoise(int width, int height, int offsetX, int offsetY, float
{
Color *pixels = (Color *)RL_MALLOC(width*height*sizeof(Color));
float aspectRatio = (float)width / (float)height;
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
@ -1119,6 +1120,10 @@ Image GenImagePerlinNoise(int width, int height, int offsetX, int offsetY, float
float nx = (float)(x + offsetX)*(scale/(float)width);
float ny = (float)(y + offsetY)*(scale/(float)height);
// Apply aspect ratio compensation to wider side
if (width > height) nx *= aspectRatio;
else ny /= aspectRatio;
// Basic perlin noise implementation (not used)
//float p = (stb_perlin_noise3(nx, ny, 0.0f, 0, 0, 0);

Laden…
Abbrechen
Speichern