diff --git a/crates/egui/src/painter.rs b/crates/egui/src/painter.rs index 47ac4458..d8cee6e9 100644 --- a/crates/egui/src/painter.rs +++ b/crates/egui/src/painter.rs @@ -352,6 +352,16 @@ impl Painter { self.line_segment([tip, tip - tip_length * (rot * dir)], stroke); self.line_segment([tip, tip - tip_length * (rot.inverse() * dir)], stroke); } + + /// An image at the given position. + /// + /// `uv` should normally be `Rect::from_min_max(pos2(0.0, 0.0), pos2(1.0, 1.0))` + /// unless you want to crop or flip the image. + /// + /// `tint` is a color multiplier. Use [`Color32::WHITE`] if you don't want to tint the image. + pub fn image(&self, texture_id: epaint::TextureId, rect: Rect, uv: Rect, tint: Color32) { + self.add(Shape::image(texture_id, rect, uv, tint)); + } } /// ## Text diff --git a/crates/epaint/src/shape.rs b/crates/epaint/src/shape.rs index 3a72bc32..a12788c5 100644 --- a/crates/epaint/src/shape.rs +++ b/crates/epaint/src/shape.rs @@ -233,6 +233,12 @@ impl Shape { Self::Mesh(mesh) } + /// An image at the given position. + /// + /// `uv` should normally be `Rect::from_min_max(pos2(0.0, 0.0), pos2(1.0, 1.0))` + /// unless you want to crop or flip the image. + /// + /// `tint` is a color multiplier. Use [`Color32::WHITE`] if you don't want to tint the image. pub fn image(texture_id: TextureId, rect: Rect, uv: Rect, tint: Color32) -> Self { let mut mesh = Mesh::with_texture(texture_id); mesh.add_rect_with_uv(rect, uv, tint);