use tessera_ui::{Color, DrawCommand};
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct CheckmarkCommand {
pub color: Color,
pub stroke_width: f32,
pub progress: f32,
pub padding: [f32; 2], }
impl CheckmarkCommand {
pub fn new() -> Self {
Self {
color: Color::new(0.0, 0.6, 0.0, 1.0), stroke_width: 5.0,
progress: 1.0, padding: [2.0, 2.0],
}
}
pub fn with_color(mut self, color: Color) -> Self {
self.color = color;
self
}
pub fn with_stroke_width(mut self, width: f32) -> Self {
self.stroke_width = width;
self
}
pub fn with_progress(mut self, progress: f32) -> Self {
self.progress = progress.clamp(0.0, 1.0);
self
}
pub fn with_padding(mut self, horizontal: f32, vertical: f32) -> Self {
self.padding = [horizontal, vertical];
self
}
}
impl Default for CheckmarkCommand {
fn default() -> Self {
Self::new()
}
}
impl DrawCommand for CheckmarkCommand {
fn sample_region(&self) -> Option<tessera_ui::SampleRegion> {
None
}
fn apply_opacity(&mut self, opacity: f32) {
self.color = self
.color
.with_alpha(self.color.a * opacity.clamp(0.0, 1.0));
}
}