Skip to content

Commit

Permalink
cleanup and color picking speedup
Browse files Browse the repository at this point in the history
  • Loading branch information
woelper committed Dec 28, 2024
1 parent 067996a commit 9c91fca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
Binary file modified icon.ico
Binary file not shown.
19 changes: 9 additions & 10 deletions src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,6 @@ impl EguiExt for Ui {
/// Draw a justified icon from a string starting with an emoji
fn label_right(&mut self, text: impl Into<WidgetText>) -> Response {
self.with_layout(egui::Layout::right_to_left(Align::Center), |ui| {
// self.horizontal(|ui| {

ui.label(text);
})
.response
Expand Down Expand Up @@ -488,8 +486,6 @@ impl EguiExt for Ui {
#[allow(unused)]
pub fn image_ui(ctx: &Context, state: &mut OculanteState, gfx: &mut Graphics) {
if let Some(texture) = &state.current_texture.get() {
//let tex_id = gfx.egui_register_texture(&texture.texture_array[0]); //TODO: Adapt if needed

let image_rect = Rect::from_center_size(
Pos2::new(
state.image_geometry.offset.x
Expand Down Expand Up @@ -543,12 +539,15 @@ pub fn info_ui(ctx: &Context, state: &mut OculanteState, _gfx: &mut Graphics) ->
img
};

if let Some(p) = get_pixel_checked(
img,
state.cursor_relative.x as u32,
state.cursor_relative.y as u32,
) {
state.sampled_color = [p[0] as f32, p[1] as f32, p[2] as f32, p[3] as f32];
// don't do this every frame for performance reasons
if ctx.frame_nr() % 5 == 0 {
if let Some(p) = get_pixel_checked(
img,
state.cursor_relative.x as u32,
state.cursor_relative.y as u32,
) {
state.sampled_color = [p[0] as f32, p[1] as f32, p[2] as f32, p[3] as f32];
}
}
}

Expand Down

0 comments on commit 9c91fca

Please sign in to comment.