(color: Color, alpha: f64)
| 376 | } |
| 377 | |
| 378 | fn blend_alpha(color: Color, alpha: f64) -> Color { |
| 379 | let (r, g, b) = color_to_rgb(color); |
| 380 | let a = alpha.clamp(0.0, 1.0); |
| 381 | Color::Rgb( |
| 382 | ((r as f64) * a).round().clamp(0.0, 255.0) as u8, |
| 383 | ((g as f64) * a).round().clamp(0.0, 255.0) as u8, |
| 384 | ((b as f64) * a).round().clamp(0.0, 255.0) as u8, |
| 385 | ) |
| 386 | } |
| 387 | |
| 388 | fn color_to_rgb(color: Color) -> (u8, u8, u8) { |
| 389 | match color { |
no test coverage detected