HYJ4HJQVLLDTE6JYKEYQK2LBWREOQUATESGB3QP7WDJB3IMVS6OAC
}
/// alpha is clamped to [0.0, 1.0]
fn lerp_mix(a: Color, b: Color, alpha: f32) -> Color {
use palette::{
blend::{BlendWith, PreAlpha},
LinSrgb, Srgba,
};
type PreRgba = PreAlpha<LinSrgb<f32>>;
let alpha = alpha.clamp(0.0, 1.0);
let a_rgb = Srgba::from(a.as_rgba_f32()).into_linear();
let b_rgb = Srgba::from(b.as_rgba_f32()).into_linear();
let mixed = a_rgb.blend_with(b_rgb, |a: PreRgba, b: PreRgba| {
// lerp em colors togethter
PreAlpha {
color: LinSrgb::new(
a.red + (b.red - a.red) * alpha,
a.green + (b.green - a.green) * alpha,
a.blue + (b.blue - a.blue) * alpha,
),
alpha: a.alpha + (b.alpha - a.alpha) * alpha,
}
});
Color::rgba(mixed.red, mixed.green, mixed.blue, mixed.alpha)
// TODO let this scale
const POINTER_DISTANCE: f32 = 45.0;
// Color shenanigans
const MIN_COLOR: Color = Color::BLUE;
const MAX_COLOR: Color = Color::RED;
if let Some(tex) = maybe_tex {
let mixed = lerp_mix(MIN_COLOR, MAX_COLOR, md.1 / MAX_SPEED);
// tex handle is present, so expect it points to a valid color material
materials
.get_mut(tex)
.expect("MP Color Texture handle exists, but doesn't point to valid handle")
.color = mixed;
}
const MIN_POINTER_DISTANCE: f32 = 45.0;
// How big is the pointer range between fastest and slowest
const MAX_POINTER_DELTA: f32 = 35.0;
]
[[package]]
name = "palette"
version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebfc23a4b76642983d57e4ad00bb4504eb30a8ce3c70f4aee1f725610e36d97a"
dependencies = [
"approx",
"fast-srgb8",
"palette_derive",
"phf",
]
[[package]]
name = "palette_derive"
version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8890702dbec0bad9116041ae586f84805b13eecd1d8b1df27c29998a9969d6d"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.52",
]
[[package]]
name = "phf"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc"
dependencies = [
"phf_macros",
"phf_shared",
]
[[package]]
name = "phf_generator"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0"
dependencies = [
"phf_shared",
"rand",
]
[[package]]
name = "phf_macros"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3444646e286606587e49f3bcf1679b8cef1dc2c5ecc29ddacaffc305180d464b"
dependencies = [
"phf_generator",
"phf_shared",
"proc-macro2",
"quote",
"syn 2.0.52",