Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

round_pos_to_pixels() to round_to_pixels() #62

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 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,

Check failure on line 7 in egui_plot/src/items/mod.rs

View workflow job for this annotation

GitHub Actions / Check wasm32

unresolved import `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 @@

// 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()),

Check failure on line 229 in egui_plot/src/items/mod.rs

View workflow job for this annotation

GitHub Actions / Check wasm32

no method named `round_to_pixels` found for struct `Pos2` in the current scope

Check failure on line 229 in egui_plot/src/items/mod.rs

View workflow job for this annotation

GitHub Actions / Check wasm32

no method named `pixels_per_point` found for reference `&Ui` in the current scope
transform
.position_from_point(&PlotPoint::new(transform.bounds().max[0], *y))
.round_to_pixels(ui.pixels_per_point()),

Check failure on line 232 in egui_plot/src/items/mod.rs

View workflow job for this annotation

GitHub Actions / Check wasm32

no method named `round_to_pixels` found for struct `Pos2` in the current scope

Check failure on line 232 in egui_plot/src/items/mod.rs

View workflow job for this annotation

GitHub Actions / Check wasm32

no method named `pixels_per_point` found for reference `&Ui` in the current scope
];
style.style_line(points, *stroke, *highlight, shapes);
}
Expand Down Expand Up @@ -371,12 +372,12 @@

// 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()),

Check failure on line 377 in egui_plot/src/items/mod.rs

View workflow job for this annotation

GitHub Actions / Check wasm32

no method named `round_to_pixels` found for struct `Pos2` in the current scope

Check failure on line 377 in egui_plot/src/items/mod.rs

View workflow job for this annotation

GitHub Actions / Check wasm32

no method named `pixels_per_point` found for reference `&Ui` in the current scope
transform
.position_from_point(&PlotPoint::new(*x, transform.bounds().max[1]))
.round_to_pixels(ui.pixels_per_point()),

Check failure on line 380 in egui_plot/src/items/mod.rs

View workflow job for this annotation

GitHub Actions / Check wasm32

no method named `round_to_pixels` found for struct `Pos2` in the current scope

Check failure on line 380 in egui_plot/src/items/mod.rs

View workflow job for this annotation

GitHub Actions / Check wasm32

no method named `pixels_per_point` found for reference `&Ui` in the current scope
];
style.style_line(points, *stroke, *highlight, shapes);
}
Expand Down Expand Up @@ -586,7 +587,7 @@
let last = values_tf[n_values - 1];
mesh.colored_vertex(last, fill_color);
mesh.colored_vertex(pos2(last.x, y), fill_color);
shapes.push(Shape::Mesh(mesh));
shapes.push(Shape::Mesh(std::sync::Arc::new(mesh)));
}
style.style_line(values_tf, *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 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,

Check failure on line 22 in egui_plot/src/lib.rs

View workflow job for this annotation

GitHub Actions / Check wasm32

unresolved import `egui::emath::GuiRounding`
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 @@

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
Loading