CorsixTH engine (the C++ part)
Open source implementation of Theme Hospital
Loading...
Searching...
No Matches
Functions
th_lua_ui.h File Reference
#include "config.h"
#include <algorithm>
#include <cassert>

Go to the source code of this file.

Functions

constexpr uint8_t map_color_channel (int low, int high, int val, int start, int end)
 Remap a value between low and high to an output between start and end.
 

Function Documentation

◆ map_color_channel()

constexpr uint8_t map_color_channel ( int  low,
int  high,
int  val,
int  start,
int  end 
)
constexpr

Remap a value between low and high to an output between start and end.

Perform linear scaling of a value from one range to another. This function is primarily intended for mapping bytes to color channel values.

Parameters
lowLower bound of input range. Must be less than high. [0-255]
highUpper bound of input range. Must be greater than low. [0-255]
valValue in [low, high] to scale.
startLower bound of output range. May be greater than end. [0-255]
endUpper bound of output range. May be less than start. [0-255]
Returns
Scaled value in [start, end]