string_art 0.1.0-alpha.1

Convert images into thread patterns for creating string art. It generates detailed instructions in text format and provides graphical previews of the resulting patterns.
Documentation
use crate::Float;

pub trait Darkness<S>: Send + Sync {
    fn compute(&self, weight: S) -> S;
}

#[derive(Clone, Copy)]
pub struct FlatDarkness<S>(pub S);

impl<T: Float> Darkness<T> for FlatDarkness<T> {
    fn compute(&self, weight: T) -> T {
        (weight - self.0).max(T::ZERO)
    }
}

#[derive(Clone, Copy)]
pub struct PercentageDarkness<S>(pub S);

impl<S: Float> Darkness<S> for PercentageDarkness<S> {
    fn compute(&self, weight: S) -> S {
        self.0 * weight
    }
}