MCPcopy Create free account
hub / github.com/Vulae/pkmc / hue

Method hue

pkmc-util/src/color.rs:13–24  ·  view source on GitHub ↗
(hue: f32)

Source from the content-addressed store, hash-verified

11 }
12
13 pub fn hue(hue: f32) -> Self {
14 let mut rgb = [0f32; 3];
15 rgb.iter_mut().enumerate().for_each(|(i, c)| {
16 let h = hue + (i as f32) / 3.0;
17 *c = f32::clamp(6.0 * f32::abs(h - f32::floor(h) - 0.5) - 1.0, 0.0, 1.0);
18 });
19 Self::new(
20 (rgb[0] * 255.0) as u8,
21 (rgb[1] * 255.0) as u8,
22 (rgb[2] * 255.0) as u8,
23 )
24 }
25
26 pub const BLACK: Color = Color::new(0x00, 0x00, 0x00);
27 pub const DARK_BLUE: Color = Color::new(0x00, 0x00, 0xAA);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected