utils: add Sign function

This commit is contained in:
Sebastian Krzyszkowiak 2018-07-03 04:22:30 +02:00
parent 7b93ced844
commit c2f6aa73cd
2 changed files with 5 additions and 0 deletions

View file

@ -162,6 +162,10 @@ SYMBOL_EXPORT double Lerp(double left, double right, double pos) {
return left + (right - left) * pos; return left + (right - left) * pos;
} }
SYMBOL_EXPORT double Sign(double val) {
return val / fabs(val);
}
/* linear filtering code written by SiegeLord */ /* linear filtering code written by SiegeLord */
SYMBOL_EXPORT ALLEGRO_COLOR InterpolateColor(ALLEGRO_COLOR c1, ALLEGRO_COLOR c2, float frac) { SYMBOL_EXPORT ALLEGRO_COLOR InterpolateColor(ALLEGRO_COLOR c1, ALLEGRO_COLOR c2, float frac) {
return al_map_rgba_f(c1.r + frac * (c2.r - c1.r), return al_map_rgba_f(c1.r + frac * (c2.r - c1.r),

View file

@ -61,6 +61,7 @@ double VectorLength(double x, double y, double z);
double Wrap(double left, double right, double val); double Wrap(double left, double right, double val);
double Clamp(double left, double right, double val); double Clamp(double left, double right, double val);
double Lerp(double left, double right, double pos); double Lerp(double left, double right, double pos);
double Sign(double val);
ALLEGRO_COLOR InterpolateColor(ALLEGRO_COLOR c1, ALLEGRO_COLOR c2, float frac); ALLEGRO_COLOR InterpolateColor(ALLEGRO_COLOR c1, ALLEGRO_COLOR c2, float frac);
void ScaleBitmap(ALLEGRO_BITMAP* source, int width, int height); void ScaleBitmap(ALLEGRO_BITMAP* source, int width, int height);