// Copyright (c) 2017, Marty Mills <daggerbot@gmail.com>
// This software is available under the terms of the zlib license.
// See COPYING.md for more information.

extern crate dnum;
#[cfg(feature = "serde_")]
extern crate serde;
#[cfg(feature = "serde_")]
#[macro_use]
extern crate serde_derive;

mod clamp;
mod consts;
mod conv;
mod lum;
mod ops;
mod rgb;

pub use clamp::{Clamp, ClampFrom, ClampInto};
pub use consts::{Color};
pub use conv::{FromColor, IntoColor};
pub use lum::{Lum, Luma, Luminance};
pub use rgb::{Rgb, Rgba};

/// Gets a color from an RGB constant.
pub fn rgb<T> (n: u32) -> T
    where Rgb<u8>: IntoColor<T>
{
    Rgb {
        r: (n >> 16) as u8,
        g: (n >> 8) as u8,
        b: n as u8,
    }.into_color()
}

/// Gets a color from an ARGB constant.
pub fn argb<T> (n: u32) -> T
    where Rgba<u8>: IntoColor<T>
{
    Rgba {
        r: (n >> 16) as u8,
        g: (n >> 8) as u8,
        b: n as u8,
        a: (n >> 24) as u8,
    }.into_color()
}
