Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

Integration: #6837 hue_color and the Hue/Saturation spectrum use photocraft_color's hsb_to_rgb (the picker's own copy is gone on main)

aiongge1465cec6d18
diff --git a/crates/ui-egui/src/adjust_editors.rs b/crates/ui-egui/src/adjust_editors.rs
index 511b3d9de..877525ffb 100644
--- a/crates/ui-egui/src/adjust_editors.rs
+++ b/crates/ui-egui/src/adjust_editors.rs
@@ -881,7 +881,7 @@ fn adjusted_spectrum(v: &Value, n: usize) -> Vec<Color32> {
let rect = photocraft_geom::Rect::new(0, 0, n as i32, 1);
let px = (0..n)
.map(|i| {
- let c = crate::color_picker_ui::hsv_to_rgb(i as f32 / (n - 1).max(1) as f32 * 360.0, 1.0, 1.0);
+ let c = photocraft_color::convert::hsb_to_rgb([i as f32 / (n - 1).max(1) as f32 * 360.0, 1.0, 1.0]);
[c[0], c[1], c[2], 1.0]
})
.collect();
diff --git a/crates/ui-egui/src/widgets.rs b/crates/ui-egui/src/widgets.rs
index 753214431..4f88702f0 100644
--- a/crates/ui-egui/src/widgets.rs
+++ b/crates/ui-egui/src/widgets.rs
@@ -1451,7 +1451,7 @@ pub fn vline(ui: &mut Ui, height: f32) {
/// The fully saturated colour at hue `deg` (degrees), built on sRGB values as Photoshop's hue
/// tracks are: 0 is (255,0,0), 60 is (255,255,0), 120 is (0,255,0) and so on (#6540).
pub fn hue_color(deg: f32) -> Color32 {
- let [r, g, b] = crate::color_picker_ui::hsv_to_rgb(deg, 1.0, 1.0);
+ let [r, g, b] = photocraft_color::convert::hsb_to_rgb([deg, 1.0, 1.0]);
let q = |v: f32| (v.clamp(0.0, 1.0) * 255.0).round() as u8;
Color32::from_rgb(q(r), q(g), q(b))
}