lib8: interpolate: add lerp8by8 and map8 functions
This commit is contained in:
parent
b468eb8533
commit
272bc49eaa
@ -82,6 +82,25 @@ pub fn lerp7by8(a: i8, b: i8, frac: u8) -> i8 {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn lerp8by8(a: u8, b: u8, frac: u8) -> u8 {
|
||||
if b > a {
|
||||
let delta = b - a;
|
||||
let scaled = scale8(delta, frac);
|
||||
return a + scaled;
|
||||
} else {
|
||||
let delta = a - b;
|
||||
let scaled = scale8(delta, frac);
|
||||
return a - scaled;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn map8(x: u8, range_start: u8, range_end: u8) -> u8 {
|
||||
let range_width = range_end - range_start;
|
||||
let mut out = scale8(x, range_width);
|
||||
out += range_start;
|
||||
return out;
|
||||
}
|
||||
|
||||
pub fn ease8InOutQuad(i: u8) -> u8 {
|
||||
let j = if i & 0x80 != 0 {
|
||||
255 - i
|
||||
|
Loading…
x
Reference in New Issue
Block a user