Use builtin fabs

This commit is contained in:
Adubbz 2018-02-23 00:13:04 +11:00 committed by plutoo
parent d534aaa834
commit 0cec4acd6b
3 changed files with 3 additions and 6 deletions

View File

@ -11,6 +11,7 @@
#include <sys/stat.h>
#include <unistd.h>
#include <malloc.h>
#include <math.h>
#ifdef SWITCH
#include <switch.h>
#endif

View File

@ -5,9 +5,5 @@
float approxSin(float x);
inline float clamp(float x, float min, float max) {
return x<min ? min : x>max ? max : x;
}
inline float nxfabs(float x) {
return x < 0 ? -x : x;
return x<min ? min : x > max ? max : x;
}

View File

@ -219,7 +219,7 @@ void drawWave(float timer, color_t color, float height, float phase, float speed
new_color = waveBlendAdd(existing_color, color, clamp(alpha, 0.0, 1.0) * 0.3);
}
else if (alpha < 0.3) { // anti-aliasing
alpha = nxfabs(alpha);
alpha = fabs(alpha);
new_color = MakeColor(color.r * (1.0 - alpha) + existing_color.r * alpha, color.g * (1.0 - alpha) + existing_color.g * alpha, color.b * (1.0 - alpha) + existing_color.b * alpha, 255);
}
else { // darken closer to bottom of the waves