rust-ppm 0.1.1

Small RGB image and plotting library for generating PPM graphics
Documentation
use crate::Pixel;

/// Styling for a connected line series.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct LineStyle {
    /// Line color in RGB.
    pub color: Pixel,
    /// Line thickness in pixels.
    pub width: usize,
}

impl LineStyle {
    /// Creates a default blue line style.
    pub const fn new() -> Self {
        Self {
            color: Pixel::rgb(0, 0, 255),
            width: 1,
        }
    }

    /// Sets the line color.
    pub const fn color(mut self, color: Pixel) -> Self {
        self.color = color;
        self
    }

    /// Sets the line width in pixels.
    pub const fn width(mut self, width: usize) -> Self {
        self.width = width;
        self
    }
}

impl Default for LineStyle {
    fn default() -> Self {
        Self::new()
    }
}

/// Styling for a scatter marker series.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct MarkerStyle {
    /// Marker color in RGB.
    pub color: Pixel,
    /// Marker diameter in pixels.
    pub size: usize,
}

impl MarkerStyle {
    /// Creates a default red marker style.
    pub const fn new() -> Self {
        Self {
            color: Pixel::rgb(255, 0, 0),
            size: 1,
        }
    }

    /// Sets the marker color.
    pub const fn color(mut self, color: Pixel) -> Self {
        self.color = color;
        self
    }

    /// Sets the marker size in pixels.
    pub const fn size(mut self, size: usize) -> Self {
        self.size = size;
        self
    }
}

impl Default for MarkerStyle {
    fn default() -> Self {
        Self::new()
    }
}