Skip to main content

gecol_core/extract/
mod.rs

1mod config;
2mod extractor;
3mod scores;
4
5use std::fmt::Display;
6
7pub use config::ExtractionConfig;
8pub use extractor::Extractor;
9
10#[derive(Debug, Clone, Copy, PartialEq, Eq)]
11pub enum ExtractStep {
12    CheckingCache,
13    FinishedWithCache,
14
15    OpeningImage,
16    ResizingImage,
17    ExtractingColors,
18    Clustering,
19    Finished,
20}
21
22impl ExtractStep {
23    /// Checks if the current step is the final step.
24    pub fn is_final(&self) -> bool {
25        matches!(self, ExtractStep::Finished)
26            || matches!(self, ExtractStep::FinishedWithCache)
27    }
28}
29
30impl Display for ExtractStep {
31    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
32        match self {
33            ExtractStep::CheckingCache => write!(f, "Checking cache..."),
34            ExtractStep::FinishedWithCache => {
35                write!(f, "Color loaded from cache!")
36            }
37
38            ExtractStep::OpeningImage => write!(f, "Opening image..."),
39            ExtractStep::ResizingImage => write!(f, "Resizing image..."),
40            ExtractStep::ExtractingColors => {
41                write!(f, "Extracting perception-aware colors...")
42            }
43            ExtractStep::Clustering => {
44                write!(f, "Running K-Means clustering...")
45            }
46            ExtractStep::Finished => write!(f, "Color extracted!"),
47        }
48    }
49}