use valo_geometry::Matrix;
use super::draw_context::DepthRange;
pub(super) const ONE_DRAW_LAYER: DepthRange = DepthRange::new(0, 2);
#[derive(Clone, Copy, Debug)]
pub(super) struct DrawState {
pub transform: Matrix,
pub z: f32,
pub alpha: f32,
}
impl DrawState {
pub fn in_layer(transform: Matrix, z: f32) -> Self {
Self {
transform,
z,
alpha: 1.0,
}
}
pub fn alone_in_layer(transform: Matrix) -> Self {
Self::in_layer(transform, ONE_DRAW_LAYER.z(1))
}
pub fn with_transform(&self, transform: Matrix) -> Self {
Self { transform, ..*self }
}
pub fn faded(&self, alpha: f32) -> Self {
Self {
alpha: self.alpha * alpha,
..*self
}
}
}