diff --git a/src/audio.cpp b/src/audio.cpp index 2d739b0..6c82d10 100644 --- a/src/audio.cpp +++ b/src/audio.cpp @@ -96,8 +96,8 @@ struct MusicEntity { terminateFade(); - volume = bound(volume, 0, 100); - pitch = bound(pitch, 50, 150); + volume = clamp(volume, 0, 100); + pitch = clamp(pitch, 50, 150); if (filename == this->filename && volume == (int)music.getVolume() @@ -386,7 +386,7 @@ struct SoundEntity { (void) pitch; - volume = bound(volume, 0, 100); + volume = clamp(volume, 0, 100); sf::SoundBuffer &buffer = allocateBuffer(filename); diff --git a/src/bitmap.cpp b/src/bitmap.cpp index 9f9e1f7..d6839da 100644 --- a/src/bitmap.cpp +++ b/src/bitmap.cpp @@ -208,7 +208,7 @@ void Bitmap::stretchBlt(const IntRect &destRect, { GUARD_DISPOSED; - opacity = bound(opacity, 0, 255); + opacity = clamp(opacity, 0, 255); if (opacity == 0) { diff --git a/src/etc-internal.h b/src/etc-internal.h index f223d81..6d34b69 100644 --- a/src/etc-internal.h +++ b/src/etc-internal.h @@ -243,7 +243,7 @@ struct NormValue void operator =(int value) { - unNorm = bound(value, 0, 255); + unNorm = clamp(value, 0, 255); norm = unNorm / 255.0; } diff --git a/src/etc.cpp b/src/etc.cpp index 0f4d4b4..9161b63 100644 --- a/src/etc.cpp +++ b/src/etc.cpp @@ -81,33 +81,33 @@ void Color::set(double red, double green, double blue, double alpha) void Color::setRed(double value) { red = value; - norm.x = bound(value, 0, 255) / 255; + norm.x = clamp(value, 0, 255) / 255; } void Color::setGreen(double value) { green = value; - norm.y = bound(value, 0, 255) / 255; + norm.y = clamp(value, 0, 255) / 255; } void Color::setBlue(double value) { blue = value; - norm.z = bound(value, 0, 255) / 255; + norm.z = clamp(value, 0, 255) / 255; } void Color::setAlpha(double value) { alpha = value; - norm.w = bound(value, 0, 255) / 255; + norm.w = clamp(value, 0, 255) / 255; } void Color::toSDLColor(SDL_Color &c) const { - c.r = bound(red, 0, 255); - c.g = bound(green, 0, 255); - c.b = bound(blue, 0, 255); -// c.a = bound(alpha, 0, 255); + c.r = clamp(red, 0, 255); + c.g = clamp(green, 0, 255); + c.b = clamp(blue, 0, 255); +// c.a = clamp(alpha, 0, 255); c.a = 255; } @@ -166,10 +166,10 @@ bool Tone::operator==(const Tone &o) const void Tone::updateInternal() { - norm.x = (float) bound(red, -255, 255) / 255; - norm.y = (float) bound(green, -255, 255) / 255; - norm.z = (float) bound(blue, -255, 255) / 255; - norm.w = (float) bound(gray, 0, 255) / 255; + norm.x = (float) clamp(red, -255, 255) / 255; + norm.y = (float) clamp(green, -255, 255) / 255; + norm.z = (float) clamp(blue, -255, 255) / 255; + norm.w = (float) clamp(gray, 0, 255) / 255; } void Tone::set(double red, double green, double blue, double gray) @@ -185,25 +185,25 @@ void Tone::set(double red, double green, double blue, double gray) void Tone::setRed(double value) { red = value; - norm.x = (float) bound(value, -255, 255) / 255; + norm.x = (float) clamp(value, -255, 255) / 255; } void Tone::setGreen(double value) { green = value; - norm.y = (float) bound(value, -255, 255) / 255; + norm.y = (float) clamp(value, -255, 255) / 255; } void Tone::setBlue(double value) { blue = value; - norm.z = (float) bound(value, -255, 255) / 255; + norm.z = (float) clamp(value, -255, 255) / 255; } void Tone::setGray(double value) { gray = value; - norm.w = (float) bound(value, 0, 255) / 255; + norm.w = (float) clamp(value, 0, 255) / 255; } /* Serializable */ diff --git a/src/graphics.cpp b/src/graphics.cpp index f047c12..667bf17 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -673,7 +673,7 @@ void Graphics::transition(int duration, const char *filename, int vague) { - vague = bound(vague, 0, 512); + vague = clamp(vague, 0, 512); Bitmap *transMap = filename ? new Bitmap(filename) : 0; setBrightness(255); @@ -770,8 +770,8 @@ int Graphics::height() const void Graphics::resizeScreen(int width, int height) { - width = bound(width, 1, 640); - height = bound(height, 1, 480); + width = clamp(width, 1, 640); + height = clamp(height, 1, 480); Vec2i size(width, height); @@ -811,13 +811,13 @@ DEF_ATTR_SIMPLE(Graphics, FrameCount, int, p->frameCount) void Graphics::setFrameRate(int value) { - p->frameRate = bound(value, 10, 120); + p->frameRate = clamp(value, 10, 120); p->fpsLimiter.setDesiredFPS(p->frameRate); } void Graphics::setBrightness(int value) { - value = bound(value, 0, 255); + value = clamp(value, 0, 255); if (p->brightness == value) return; diff --git a/src/util.h b/src/util.h index 8ff4bcd..76844ad 100644 --- a/src/util.h +++ b/src/util.h @@ -35,7 +35,7 @@ wrapRange(int value, int min, int max) } template -static inline T bound(T value, T min, T max) +static inline T clamp(T value, T min, T max) { if (value < min) return min;