pub mod pencil;
pub mod eraser;

use egui::Pos2;
use serde::Serialize;

pub enum Tool {
    Pencil,
    Eraser,
}

/// A simple event that can defines how a tool (e.g. the pen) is used on a [Handwriting].
#[derive(Debug, Serialize, Copy, Clone)]
pub enum ToolEvent {
    Press { at: Pos2 },
    Move { to: Pos2 },
    Release,
}

impl ToolEvent {
    pub const fn position(&self) -> Option<Pos2> {
        match self {
            &ToolEvent::Press { at } => Some(at),
            &ToolEvent::Move { to } => Some(to),
            ToolEvent::Release => None,
        }
    }
}
