Skip to content

Commit 424dfba

Browse files
committed
Draw the shape preview translucent
The cells a dragged shape will change are drawn at 70% opacity, so the picture they cover stays visible.
1 parent 808a89d commit 424dfba

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

  • crates/icy_draw/src/bin/icy_draw_egui

‎crates/icy_draw/src/bin/icy_draw_egui/app.rs‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@ fn filter_match_ranges(name: &str, filter: &str) -> Vec<std::ops::Range<usize>>
183183
lower_name.match_indices(&filter).map(|(start, value)| start..start + value.len()).collect()
184184
}
185185

186+
/// How opaque the preview of a shape being dragged is drawn over the picture.
187+
const PREVIEW_OPACITY: f32 = 0.7;
188+
186189
/// Document kinds offered by the New dialog and the start screen.
187190
#[derive(Clone, Copy, PartialEq, Eq)]
188191
pub enum NewKind {
@@ -2012,7 +2015,8 @@ impl DrawApp {
20122015
painter.rect_filled(rect, 0, Color32::from_rgba_unmultiplied(red, green, blue, 160));
20132016
}
20142017
} else {
2015-
// The operation tried on a copy: its cells as they will look, drawn over the picture.
2018+
// The operation tried on a copy: its cells as they will look, drawn over the picture
2019+
// translucent, so what they cover stays visible.
20162020
let character = egui::vec2(info.font_width, info.font_height * if info.scan_lines { 2.0 } else { 1.0 });
20172021
let (fonts, palette) = self.document.with_state(|state| {
20182022
let buffer = state.get_buffer();
@@ -2021,7 +2025,7 @@ impl DrawApp {
20212025
});
20222026
let rgb = |color: icy_engine::AttributeColor, index: u32| {
20232027
let (red, green, blue) = color.as_rgb().unwrap_or_else(|| palette.rgb(index));
2024-
Color32::from_rgb(red, green, blue)
2028+
Color32::from_rgb(red, green, blue).gamma_multiply(PREVIEW_OPACITY)
20252029
};
20262030
for (point, ch) in &self.document.preview_cells {
20272031
let rect = egui::Rect::from_min_size(

0 commit comments

Comments
 (0)