Minor edits

master
Mark 2024-01-25 21:25:50 -08:00
parent 699e62a1c8
commit f184a40877
Signed by: Mark
GPG Key ID: C6D63995FE72FD80
1 changed files with 13 additions and 0 deletions

View File

@ -9,6 +9,7 @@ use nalgebra::{Point2, Vector2};
use crate::{RenderInput, RenderState}; use crate::{RenderInput, RenderState};
/// Represents a rectangular region inside a sprite. /// Represents a rectangular region inside a sprite.
#[derive(Debug, Clone, Copy)]
pub(crate) struct SpriteRect { pub(crate) struct SpriteRect {
/// The position of the top-left corner of this rectangle, in fractional units. /// The position of the top-left corner of this rectangle, in fractional units.
/// (0.0 is left edge of sprite, 1.0 is right edge) /// (0.0 is left edge of sprite, 1.0 is right edge)
@ -19,6 +20,18 @@ pub(crate) struct SpriteRect {
pub dim: Vector2<f32>, pub dim: Vector2<f32>,
} }
impl SpriteRect {
/// Northeast corner of this rect
pub fn ne_corner(&self) -> Point2<f32> {
self.pos + Vector2::new(-self.dim.x, self.dim.y) / 2.0
}
/// Southwest corner of this rect
pub fn sw_corner(&self) -> Point2<f32> {
self.pos + Vector2::new(self.dim.x, -self.dim.y) / 2.0
}
}
pub(super) trait UiElement { pub(super) trait UiElement {
fn push_to_buffer_child( fn push_to_buffer_child(
&self, &self,