mirror of
https://github.com/emilk/egui.git
synced 2026-09-01 06:10:06 -04:00
Support additive colors in color picker
This commit is contained in:
@@ -57,7 +57,7 @@ impl super::View for DancingStrings {
|
||||
let thickness = 10.0 / mode;
|
||||
cmds.push(paint::PaintCmd::line(
|
||||
points,
|
||||
Stroke::new(thickness, Color32::additive_luminance(196)),
|
||||
Stroke::new(thickness, Color32::from_additive_luminance(196)),
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ impl DemoWindow {
|
||||
let painter = ui.painter();
|
||||
let c = response.rect.center();
|
||||
let r = response.rect.width() / 2.0 - 1.0;
|
||||
let color = Color32::gray(128);
|
||||
let color = Color32::from_gray(128);
|
||||
let stroke = Stroke::new(1.0, color);
|
||||
painter.circle_stroke(c, r, stroke);
|
||||
painter.line_segment([c - vec2(0.0, r), c + vec2(0.0, r)], stroke);
|
||||
@@ -210,7 +210,7 @@ impl BoxPainting {
|
||||
ui.painter().rect(
|
||||
response.rect,
|
||||
self.corner_radius,
|
||||
Color32::gray(64),
|
||||
Color32::from_gray(64),
|
||||
Stroke::new(self.stroke_width, Color32::WHITE),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -40,8 +40,8 @@ pub fn toggle(ui: &mut egui::Ui, on: &mut bool) -> egui::Response {
|
||||
// "how should something that is being interacted with be painted?".
|
||||
// This will, for instance, give us different colors when the widget is hovered or clicked.
|
||||
let visuals = ui.style().interact(&response);
|
||||
let off_bg_fill = egui::Rgba::new(0.0, 0.0, 0.0, 0.0);
|
||||
let on_bg_fill = egui::Rgba::new(0.0, 0.5, 0.25, 1.0);
|
||||
let off_bg_fill = egui::Rgba::TRANSPARENT;
|
||||
let on_bg_fill = egui::Rgba::from_rgb(0.0, 0.5, 0.25);
|
||||
let bg_fill = egui::lerp(off_bg_fill..=on_bg_fill, how_on);
|
||||
// All coordinates are in absolute screen coordinates so we use `rect` to place the elements.
|
||||
let rect = response.rect;
|
||||
@@ -67,8 +67,8 @@ fn toggle_compact(ui: &mut egui::Ui, on: &mut bool) -> egui::Response {
|
||||
|
||||
let how_on = ui.ctx().animate_bool(response.id, *on);
|
||||
let visuals = ui.style().interact(&response);
|
||||
let off_bg_fill = egui::Rgba::new(0.0, 0.0, 0.0, 0.0);
|
||||
let on_bg_fill = egui::Rgba::new(0.0, 0.5, 0.25, 1.0);
|
||||
let off_bg_fill = egui::Rgba::TRANSPARENT;
|
||||
let on_bg_fill = egui::Rgba::from_rgb(0.0, 0.5, 0.25);
|
||||
let bg_fill = egui::lerp(off_bg_fill..=on_bg_fill, how_on);
|
||||
let rect = response.rect;
|
||||
let radius = 0.5 * rect.height();
|
||||
|
||||
@@ -35,7 +35,7 @@ impl Default for Widgets {
|
||||
count: 0,
|
||||
sliders: Default::default(),
|
||||
angle: std::f32::consts::TAU / 3.0,
|
||||
color: (Rgba::new(0.0, 1.0, 0.5, 1.0) * 0.75).into(),
|
||||
color: (Rgba::from_rgb(0.0, 1.0, 0.5) * 0.75).into(),
|
||||
single_line_text_input: "Hello World!".to_owned(),
|
||||
multiline_text_input: "Text can both be so wide that it needs a line break, but you can also add manual line break by pressing enter, creating new paragraphs.\nThis is the start of the next paragraph.\n\nClick me to edit me!".to_owned(),
|
||||
toggle_switch: false,
|
||||
|
||||
Reference in New Issue
Block a user