-
Beta Was this translation helpful? Give feedback.
Answered by
YgorSouza
Sep 16, 2023
Replies: 1 comment
-
You could do something like this: let scale = plot_ui.transform().rect_from_values(&[0.0, 0.0].into(), &[1.0, 1.0].into()).size();
let text_size = scale.max_elem().clamp(0.001, 250.0);
let stroke_width = scale.max_elem().clamp(0.001, 2500.0) * 0.1;
plot_ui.text(Text::new([0.0, 0.0].into(), RichText::new("Plot Text").size(text_size)));
plot_ui.polygon(Polygon::new(PlotPoints::new(vec![[-4.0, -1.5], [4.0, -1.5], [4.0, 1.5], [-4.0, 1.5]])).stroke(Stroke::new(stroke_width, Color32::BLUE))); You have to limit the font size because egui will panic if it is too large (250 is already pushing it). And you have to decide what should happen if the X and Y scales are different, since you can't distort the elements along one dimension. As for the stroke not joining at the ends, it's missing the "stroke-linejoin" and "stroke-linecap" properties from SVG that would fix that, so you can open a feature request about it. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
tgross35
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You could do something like this:
You have to limit the font size because egui will panic if it is too large (250 is already pushing it). And you have to decide what should happen if the X and Y scales are different, since you can't distor…