diff --git a/epaint/src/shape.rs b/epaint/src/shape.rs index 1d846fb2..57d3cef1 100644 --- a/epaint/src/shape.rs +++ b/epaint/src/shape.rs @@ -2,7 +2,7 @@ use crate::{ text::{FontId, Fonts, Galley}, - Color32, Mesh, Stroke, + Color32, Mesh, Stroke, TextureId, }; use emath::*; @@ -184,6 +184,12 @@ impl Shape { Self::Mesh(mesh) } + 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); + Shape::mesh(mesh) + } + /// The visual bounding rectangle (includes stroke widths) pub fn visual_bounding_rect(&self) -> Rect { match self {