From fa3dc2caef1d38ebebbf417eb19bbd8140f69957 Mon Sep 17 00:00:00 2001 From: Sawyer McLane Date: Fri, 27 Sep 2024 11:08:33 -0600 Subject: [PATCH] Refactor slider resolution constant in color_slider function --- src/ui.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ui.rs b/src/ui.rs index 9973a2c..b4935b0 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -437,7 +437,7 @@ pub fn toggle_button( response } -const N: u32 = 6 * 6; +const SLIDER_RESOLUTION: u32 = 6 * 6; pub fn color_slider( ui: &mut Ui, @@ -473,19 +473,19 @@ pub fn color_slider( { // fill color: let mut mesh = Mesh::default(); - for i in 0..=N { - let t = i as f32 / (N as f32); + for i in 0..=SLIDER_RESOLUTION { + let t = i as f32 / (SLIDER_RESOLUTION as f32); let color = color_at((t * u16::MAX as f32) as u16); let x = lerp(rect.left()..=rect.right(), t); // round edges: - let y_offset = if i == 0 || i == N { + let y_offset = if i == 0 || i == SLIDER_RESOLUTION { (ui.spacing().slider_rail_height / 2.0) - 2. } else { ui.spacing().slider_rail_height / 2.0 }; mesh.colored_vertex(pos2(x, rect.center().y + y_offset), color); mesh.colored_vertex(pos2(x, rect.center().y - y_offset), color); - if i < N { + if i < SLIDER_RESOLUTION { mesh.add_triangle(2 * i, 2 * i + 1, 2 * i + 2); mesh.add_triangle(2 * i + 1, 2 * i + 2, 2 * i + 3); }