Rename 'bound' to 'clamp'
This commit is contained in:
parent
f81e20cc68
commit
84db116d0c
|
@ -96,8 +96,8 @@ struct MusicEntity
|
|||
{
|
||||
terminateFade();
|
||||
|
||||
volume = bound<int>(volume, 0, 100);
|
||||
pitch = bound<int>(pitch, 50, 150);
|
||||
volume = clamp<int>(volume, 0, 100);
|
||||
pitch = clamp<int>(pitch, 50, 150);
|
||||
|
||||
if (filename == this->filename
|
||||
&& volume == (int)music.getVolume()
|
||||
|
@ -386,7 +386,7 @@ struct SoundEntity
|
|||
{
|
||||
(void) pitch;
|
||||
|
||||
volume = bound<int>(volume, 0, 100);
|
||||
volume = clamp<int>(volume, 0, 100);
|
||||
|
||||
sf::SoundBuffer &buffer = allocateBuffer(filename);
|
||||
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -243,7 +243,7 @@ struct NormValue
|
|||
|
||||
void operator =(int value)
|
||||
{
|
||||
unNorm = bound(value, 0, 255);
|
||||
unNorm = clamp(value, 0, 255);
|
||||
norm = unNorm / 255.0;
|
||||
}
|
||||
|
||||
|
|
32
src/etc.cpp
32
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<double>(value, 0, 255) / 255;
|
||||
norm.x = clamp<double>(value, 0, 255) / 255;
|
||||
}
|
||||
|
||||
void Color::setGreen(double value)
|
||||
{
|
||||
green = value;
|
||||
norm.y = bound<double>(value, 0, 255) / 255;
|
||||
norm.y = clamp<double>(value, 0, 255) / 255;
|
||||
}
|
||||
|
||||
void Color::setBlue(double value)
|
||||
{
|
||||
blue = value;
|
||||
norm.z = bound<double>(value, 0, 255) / 255;
|
||||
norm.z = clamp<double>(value, 0, 255) / 255;
|
||||
}
|
||||
|
||||
void Color::setAlpha(double value)
|
||||
{
|
||||
alpha = value;
|
||||
norm.w = bound<double>(value, 0, 255) / 255;
|
||||
norm.w = clamp<double>(value, 0, 255) / 255;
|
||||
}
|
||||
|
||||
void Color::toSDLColor(SDL_Color &c) const
|
||||
{
|
||||
c.r = bound<double>(red, 0, 255);
|
||||
c.g = bound<double>(green, 0, 255);
|
||||
c.b = bound<double>(blue, 0, 255);
|
||||
// c.a = bound<double>(alpha, 0, 255);
|
||||
c.r = clamp<double>(red, 0, 255);
|
||||
c.g = clamp<double>(green, 0, 255);
|
||||
c.b = clamp<double>(blue, 0, 255);
|
||||
// c.a = clamp<double>(alpha, 0, 255);
|
||||
c.a = 255;
|
||||
}
|
||||
|
||||
|
@ -166,10 +166,10 @@ bool Tone::operator==(const Tone &o) const
|
|||
|
||||
void Tone::updateInternal()
|
||||
{
|
||||
norm.x = (float) bound<double>(red, -255, 255) / 255;
|
||||
norm.y = (float) bound<double>(green, -255, 255) / 255;
|
||||
norm.z = (float) bound<double>(blue, -255, 255) / 255;
|
||||
norm.w = (float) bound<double>(gray, 0, 255) / 255;
|
||||
norm.x = (float) clamp<double>(red, -255, 255) / 255;
|
||||
norm.y = (float) clamp<double>(green, -255, 255) / 255;
|
||||
norm.z = (float) clamp<double>(blue, -255, 255) / 255;
|
||||
norm.w = (float) clamp<double>(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<double>(value, -255, 255) / 255;
|
||||
norm.x = (float) clamp<double>(value, -255, 255) / 255;
|
||||
}
|
||||
|
||||
void Tone::setGreen(double value)
|
||||
{
|
||||
green = value;
|
||||
norm.y = (float) bound<double>(value, -255, 255) / 255;
|
||||
norm.y = (float) clamp<double>(value, -255, 255) / 255;
|
||||
}
|
||||
|
||||
void Tone::setBlue(double value)
|
||||
{
|
||||
blue = value;
|
||||
norm.z = (float) bound<double>(value, -255, 255) / 255;
|
||||
norm.z = (float) clamp<double>(value, -255, 255) / 255;
|
||||
}
|
||||
|
||||
void Tone::setGray(double value)
|
||||
{
|
||||
gray = value;
|
||||
norm.w = (float) bound<double>(value, 0, 255) / 255;
|
||||
norm.w = (float) clamp<double>(value, 0, 255) / 255;
|
||||
}
|
||||
|
||||
/* Serializable */
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -35,7 +35,7 @@ wrapRange(int value, int min, int max)
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
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;
|
||||
|
|
Loading…
Reference in New Issue