MCPcopy Create free account
hub / github.com/emilk/egui_plot / shapes

Method shapes

egui_plot/src/items/text.rs:89–114  ·  view source on GitHub ↗
(&self, ui: &Ui, transform: &PlotTransform, shapes: &mut Vec<Shape>)

Source from the content-addressed store, hash-verified

87
88impl PlotItem for Text {
89 fn shapes(&self, ui: &Ui, transform: &PlotTransform, shapes: &mut Vec<Shape>) {
90 let color = if self.color == Color32::TRANSPARENT {
91 ui.style().visuals.text_color()
92 } else {
93 self.color
94 };
95
96 let galley =
97 self.text
98 .clone()
99 .into_galley(ui, Some(egui::TextWrapMode::Extend), f32::INFINITY, TextStyle::Small);
100
101 let pos = transform.position_from_point(&self.position);
102 let rect = self.anchor.anchor_size(pos, galley.size());
103
104 shapes.push(TextShape::new(rect.min, galley, color).into());
105
106 if self.base.highlight {
107 shapes.push(Shape::rect_stroke(
108 rect.expand(1.0),
109 1.0,
110 Stroke::new(0.5, color),
111 egui::StrokeKind::Outside,
112 ));
113 }
114 }
115
116 fn initialize(&mut self, _x_range: RangeInclusive<f64>) {}
117

Callers

nothing calls this directly

Calls 3

position_from_pointMethod · 0.80
sizeMethod · 0.80
styleMethod · 0.45

Tested by

no test coverage detected