Add Shape::image convenience method
This commit is contained in:
parent
734d4c57ad
commit
861e129ace
1 changed files with 7 additions and 1 deletions
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
text::{FontId, Fonts, Galley},
|
text::{FontId, Fonts, Galley},
|
||||||
Color32, Mesh, Stroke,
|
Color32, Mesh, Stroke, TextureId,
|
||||||
};
|
};
|
||||||
use emath::*;
|
use emath::*;
|
||||||
|
|
||||||
|
@ -184,6 +184,12 @@ impl Shape {
|
||||||
Self::Mesh(mesh)
|
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)
|
/// The visual bounding rectangle (includes stroke widths)
|
||||||
pub fn visual_bounding_rect(&self) -> Rect {
|
pub fn visual_bounding_rect(&self) -> Rect {
|
||||||
match self {
|
match self {
|
||||||
|
|
Loading…
Reference in a new issue