Add Shape::image convenience method

This commit is contained in:
Emil Ernerfeldt 2022-03-20 20:39:39 +01:00
parent 734d4c57ad
commit 861e129ace

View file

@ -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 {