Skip to content

Commit

Permalink
Merge branch 'patch3' into egui-update
Browse files Browse the repository at this point in the history
  • Loading branch information
Wumpf committed Jan 3, 2025
2 parents f8ccabf + 10cc0b8 commit 314318e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
25 changes: 13 additions & 12 deletions egui_plot/src/items/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use std::ops::RangeInclusive;

use egui::{
emath::GuiRounding,
emath::Rot2,
epaint::{CircleShape, TextShape},
pos2, vec2, Align2, Color32, Id, ImageOptions, Mesh, NumExt as _, Pos2, Rect, Rgba, Rounding,
Expand Down Expand Up @@ -223,12 +224,12 @@ impl PlotItem for HLine {

// Round to minimize aliasing:
let points = vec![
ui.painter().round_pos_to_pixels(
transform.position_from_point(&PlotPoint::new(transform.bounds().min[0], *y)),
),
ui.painter().round_pos_to_pixels(
transform.position_from_point(&PlotPoint::new(transform.bounds().max[0], *y)),
),
transform
.position_from_point(&PlotPoint::new(transform.bounds().min[0], *y))
.round_to_pixels(ui.pixels_per_point()),
transform
.position_from_point(&PlotPoint::new(transform.bounds().max[0], *y))
.round_to_pixels(ui.pixels_per_point()),
];
style.style_line(points, *stroke, *highlight, shapes);
}
Expand Down Expand Up @@ -371,12 +372,12 @@ impl PlotItem for VLine {

// Round to minimize aliasing:
let points = vec![
ui.painter().round_pos_to_pixels(
transform.position_from_point(&PlotPoint::new(*x, transform.bounds().min[1])),
),
ui.painter().round_pos_to_pixels(
transform.position_from_point(&PlotPoint::new(*x, transform.bounds().max[1])),
),
transform
.position_from_point(&PlotPoint::new(*x, transform.bounds().min[1]))
.round_to_pixels(ui.pixels_per_point()),
transform
.position_from_point(&PlotPoint::new(*x, transform.bounds().max[1]))
.round_to_pixels(ui.pixels_per_point()),
];
style.style_line(points, *stroke, *highlight, shapes);
}
Expand Down
10 changes: 5 additions & 5 deletions egui_plot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ use std::{cmp::Ordering, ops::RangeInclusive, sync::Arc};

use ahash::HashMap;
use egui::{
epaint, remap_clamp, vec2, Align2, Color32, CursorIcon, Id, Layout, NumExt, PointerButton,
Pos2, Rangef, Rect, Response, Rounding, Sense, Shape, Stroke, TextStyle, Ui, Vec2, Vec2b,
WidgetText,
emath::GuiRounding, epaint, remap_clamp, vec2, Align2, Color32, CursorIcon, Id, Layout, NumExt,
PointerButton, Pos2, Rangef, Rect, Response, Rounding, Sense, Shape, Stroke, TextStyle, Ui,
Vec2, Vec2b, WidgetText,
};
use emath::Float as _;

Expand Down Expand Up @@ -1666,8 +1666,8 @@ impl<'a> PreparedPlot<'a> {

if self.sharp_grid_lines {
// Round to avoid aliasing
p0 = ui.painter().round_pos_to_pixels(p0);
p1 = ui.painter().round_pos_to_pixels(p1);
p0 = p0.round_to_pixels(ui.pixels_per_point());
p1 = p1.round_to_pixels(ui.pixels_per_point());
}

shapes.push((
Expand Down

0 comments on commit 314318e

Please sign in to comment.