Skip to main content

dear_imgui_rs/texture/
rect.rs

1use crate::sys;
2
3/// Coordinates of a rectangle within a texture
4#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
5pub struct TextureRect {
6    /// Upper-left X coordinate of rectangle to update
7    pub x: u16,
8    /// Upper-left Y coordinate of rectangle to update
9    pub y: u16,
10    /// Width of rectangle to update
11    pub w: u16,
12    /// Height of rectangle to update
13    pub h: u16,
14}
15
16impl From<sys::ImTextureRect> for TextureRect {
17    fn from(rect: sys::ImTextureRect) -> Self {
18        Self {
19            x: rect.x,
20            y: rect.y,
21            w: rect.w,
22            h: rect.h,
23        }
24    }
25}
26
27impl From<TextureRect> for sys::ImTextureRect {
28    fn from(rect: TextureRect) -> Self {
29        Self {
30            x: rect.x,
31            y: rect.y,
32            w: rect.w,
33            h: rect.h,
34        }
35    }
36}