diff --git a/src/lib8/interpolate.rs b/src/lib8/interpolate.rs index 10f5d21..a338931 100644 --- a/src/lib8/interpolate.rs +++ b/src/lib8/interpolate.rs @@ -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