mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 05:40:03 -04:00
better naming
This commit is contained in:
@@ -242,13 +242,13 @@ impl<const AXIS: usize> Widget for AxisWidget<AXIS> {
|
|||||||
if spacing_in_points <= MIN_TEXT_SPACING {
|
if spacing_in_points <= MIN_TEXT_SPACING {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let line_weight = remap_clamp(
|
let line_strength = remap_clamp(
|
||||||
spacing_in_points,
|
spacing_in_points,
|
||||||
MIN_TEXT_SPACING..=FULL_CONTRAST_SPACING,
|
MIN_TEXT_SPACING..=FULL_CONTRAST_SPACING,
|
||||||
0.0..=1.0,
|
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
|
let galley = ui
|
||||||
.painter()
|
.painter()
|
||||||
.layout_no_wrap(text, font_id.clone(), line_color);
|
.layout_no_wrap(text, font_id.clone(), line_color);
|
||||||
|
|||||||
@@ -1741,7 +1741,7 @@ impl PreparedPlot {
|
|||||||
0.0..=1.0,
|
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 p0 = pos_in_gui;
|
||||||
let mut p1 = 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 bg = ui.visuals().extreme_bg_color;
|
||||||
let fg = ui.visuals().widgets.open.fg_stroke.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(
|
Color32::from_rgb(
|
||||||
lerp((bg.r() as f32)..=(fg.r() as f32), mix) as u8,
|
lerp((bg.r() as f32)..=(fg.r() as f32), mix) as u8,
|
||||||
lerp((bg.g() as f32)..=(fg.g() as f32), mix) as u8,
|
lerp((bg.g() as f32)..=(fg.g() as f32), mix) as u8,
|
||||||
|
|||||||
Reference in New Issue
Block a user