1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-26 22:53:14 -04:00

better naming

This commit is contained in:
Emil Ernerfeldt
2023-08-14 14:11:04 +02:00
parent bb987bb50b
commit c81cfeb24d
2 changed files with 6 additions and 5 deletions

View File

@@ -242,13 +242,13 @@ impl<const AXIS: usize> Widget for AxisWidget<AXIS> {
if spacing_in_points <= MIN_TEXT_SPACING {
continue;
}
let line_weight = remap_clamp(
let line_strength = remap_clamp(
spacing_in_points,
MIN_TEXT_SPACING..=FULL_CONTRAST_SPACING,
0.0..=1.0,
);
let line_color = super::color_from_contrast(ui, line_weight);
let line_color = super::color_from_strength(ui, line_strength);
let galley = ui
.painter()
.layout_no_wrap(text, font_id.clone(), line_color);

View File

@@ -1741,7 +1741,7 @@ impl PreparedPlot {
0.0..=1.0,
);
let line_color = color_from_contrast(ui, line_strength);
let line_color = color_from_strength(ui, line_strength);
let mut p0 = pos_in_gui;
let mut p1 = pos_in_gui;
@@ -1875,10 +1875,11 @@ pub fn format_number(number: f64, num_decimals: usize) -> String {
}
}
pub fn color_from_contrast(ui: &Ui, contrast: f32) -> Color32 {
/// Determine a color from a 0-1 strength value.
pub fn color_from_strength(ui: &Ui, strength: f32) -> Color32 {
let bg = ui.visuals().extreme_bg_color;
let fg = ui.visuals().widgets.open.fg_stroke.color;
let mix = 0.5 * contrast.sqrt();
let mix = 0.5 * strength.sqrt();
Color32::from_rgb(
lerp((bg.r() as f32)..=(fg.r() as f32), mix) as u8,
lerp((bg.g() as f32)..=(fg.g() as f32), mix) as u8,