Sign in

    gmlewis/image/color does not have a README file

    Color

    pub(open) trait Color {
    fn rgba(Self) -> (UInt, UInt, UInt, UInt)
    fn model(Self) -> String
    fn raw(Self) -> (UInt, UInt, UInt, UInt)
    }

    Color can convert itself to alpha-premultiplied 16-bits per channel RGBA. The conversion may be lossy.

    Model

    pub(open) trait Model {
    fn convert(Self, &Color) -> &Color
    fn name(Self) -> String
    fn get_palette(Self) -> Palette?
    }

    Model can convert any [&Color] to one from its own color model. The conversion may be lossy.

    Alpha

    pub(all) struct Alpha {
    a : Byte
    } derive(Eq)

    Alpha represents an 8-bit alpha color.
    impl Color for Alpha
    impl Show for Alpha

    Alpha::equal

    fn Alpha::equal(Alpha, Alpha) -> Bool

    Alpha::from

    fn Alpha::from(c : &Color) -> Alpha

    Alpha::model

    fn Alpha::model(_self : Alpha) -> String

    Alpha::new

    fn Alpha::new(a : Byte) -> Alpha

    Alpha::raw

    fn Alpha::raw(self : Alpha) -> (UInt, UInt, UInt, UInt)

    Alpha::rgba

    fn Alpha::rgba(self : Alpha) -> (UInt, UInt, UInt, UInt)

    Alpha::to_string

    fn Alpha::to_string(self : Alpha) -> String

    Alpha16

    pub(all) struct Alpha16 {
    a : UInt
    } derive(Eq)

    Alpha16 represents a 16-bit alpha color.
    impl Color for Alpha16
    impl Show for Alpha16

    Alpha16::equal

    fn Alpha16::equal(Alpha16, Alpha16) -> Bool

    Alpha16::from

    fn Alpha16::from(c : &Color) -> Alpha16

    Alpha16::model

    fn Alpha16::model(_self : Alpha16) -> String

    Alpha16::new

    fn Alpha16::new(a : UInt) -> Alpha16

    Alpha16::raw

    fn Alpha16::raw(self : Alpha16) -> (UInt, UInt, UInt, UInt)

    Alpha16::rgba

    fn Alpha16::rgba(self : Alpha16) -> (UInt, UInt, UInt, UInt)

    Alpha16::to_string

    fn Alpha16::to_string(self : Alpha16) -> String

    CMYK

    pub(all) struct CMYK {
    c : Byte
    m : Byte
    y : Byte
    k : Byte
    } derive(Eq)

    CMYK represents a fully opaque CMYK color, having 8 bits for each of cyan, magenta, yellow and black.

    It is not associated with any particular color profile.
    impl Color for CMYK
    impl Show for CMYK

    CMYK::equal

    fn CMYK::equal(CMYK, CMYK) -> Bool

    CMYK::from

    fn CMYK::from(c : &Color) -> CMYK

    CMYK::model

    fn CMYK::model(_self : CMYK) -> String

    CMYK::new

    fn CMYK::new(c : Byte, m : Byte, y : Byte, k : Byte) -> CMYK

    CMYK::raw

    fn CMYK::raw(self : CMYK) -> (UInt, UInt, UInt, UInt)

    CMYK::rgba

    fn CMYK::rgba(self : CMYK) -> (UInt, UInt, UInt, UInt)

    CMYK::to_string

    fn CMYK::to_string(self : CMYK) -> String

    Gray

    pub(all) struct Gray {
    y : Byte
    } derive(Eq)

    Gray represents an 8-bit grayscale color.
    impl Color for Gray
    impl Show for Gray

    Gray::equal

    fn Gray::equal(Gray, Gray) -> Bool

    Gray::from

    fn Gray::from(c : &Color) -> Gray

    Gray::model

    fn Gray::model(_self : Gray) -> String

    Gray::new

    fn Gray::new(y : Byte) -> Gray

    Gray::raw

    fn Gray::raw(self : Gray) -> (UInt, UInt, UInt, UInt)

    Gray::rgba

    fn Gray::rgba(self : Gray) -> (UInt, UInt, UInt, UInt)

    Gray::to_string

    fn Gray::to_string(self : Gray) -> String

    Gray16

    pub(all) struct Gray16 {
    y : UInt
    } derive(Eq)

    Gray16 represents a 16-bit grayscale color.
    impl Color for Gray16
    impl Show for Gray16

    Gray16::equal

    fn Gray16::equal(Gray16, Gray16) -> Bool

    Gray16::from

    fn Gray16::from(c : &Color) -> Gray16

    Gray16::model

    fn Gray16::model(_self : Gray16) -> String

    Gray16::new

    fn Gray16::new(y : UInt) -> Gray16

    Gray16::raw

    fn Gray16::raw(self : Gray16) -> (UInt, UInt, UInt, UInt)

    Gray16::rgba

    fn Gray16::rgba(self : Gray16) -> (UInt, UInt, UInt, UInt)

    Gray16::to_string

    fn Gray16::to_string(self : Gray16) -> String

    ModelFunc

    type ModelFunc

    impl Model for ModelFunc

    ModelFunc::convert

    fn ModelFunc::convert(self : ModelFunc, c : &Color) -> &Color

    ModelFunc::get_palette

    fn ModelFunc::get_palette(self : ModelFunc) -> Palette?

    ModelFunc::name

    fn ModelFunc::name(self : ModelFunc) -> String

    NRGBA

    pub(all) struct NRGBA {
    r : Byte
    g : Byte
    b : Byte
    a : Byte
    } derive(Eq)

    NRGBA represents a non-alpha-premultiplied 32-bit color.
    impl Color for NRGBA
    impl Show for NRGBA

    NRGBA::equal

    fn NRGBA::equal(NRGBA, NRGBA) -> Bool

    NRGBA::from

    fn NRGBA::from(c : &Color) -> NRGBA

    NRGBA::model

    fn NRGBA::model(_self : NRGBA) -> String

    NRGBA::new

    fn NRGBA::new(r : Byte, g : Byte, b : Byte, a : Byte) -> NRGBA

    NRGBA::raw

    fn NRGBA::raw(self : NRGBA) -> (UInt, UInt, UInt, UInt)

    NRGBA::rgba

    fn NRGBA::rgba(self : NRGBA) -> (UInt, UInt, UInt, UInt)

    NRGBA::to_string

    fn NRGBA::to_string(self : NRGBA) -> String

    NRGBA64

    pub(all) struct NRGBA64 {
    r : UInt
    g : UInt
    b : UInt
    a : UInt
    } derive(Eq)

    NRGBA64 represents a non-alpha-premultiplied 64-bit color, having 16 bits for each of red, green, blue and alpha.
    impl Color for NRGBA64
    impl Show for NRGBA64

    NRGBA64::equal

    fn NRGBA64::equal(NRGBA64, NRGBA64) -> Bool

    NRGBA64::from

    fn NRGBA64::from(c : &Color) -> NRGBA64

    NRGBA64::model

    fn NRGBA64::model(_self : NRGBA64) -> String

    NRGBA64::new

    fn NRGBA64::new(r : UInt, g : UInt, b : UInt, a : UInt) -> NRGBA64

    NRGBA64::raw

    fn NRGBA64::raw(self : NRGBA64) -> (UInt, UInt, UInt, UInt)

    NRGBA64::rgba

    fn NRGBA64::rgba(self : NRGBA64) -> (UInt, UInt, UInt, UInt)

    NRGBA64::to_string

    fn NRGBA64::to_string(self : NRGBA64) -> String

    NYCbCrA

    pub(all) struct NYCbCrA {
    y : Byte
    cb : Byte
    cr : Byte
    a : Byte
    } derive(Eq)

    NYCbCrA represents a non-alpha-premultiplied Y'CbCr-with-alpha color, having 8 bits each for one luma, two chroma and one alpha component.
    impl Color for NYCbCrA
    impl Show for NYCbCrA

    NYCbCrA::equal

    fn NYCbCrA::equal(NYCbCrA, NYCbCrA) -> Bool

    NYCbCrA::model

    fn NYCbCrA::model(_self : NYCbCrA) -> String

    NYCbCrA::new

    fn NYCbCrA::new(y : Byte, cb : Byte, cr : Byte, a : Byte) -> NYCbCrA

    NYCbCrA::raw

    fn NYCbCrA::raw(self : NYCbCrA) -> (UInt, UInt, UInt, UInt)

    NYCbCrA::rgba

    fn NYCbCrA::rgba(self : NYCbCrA) -> (UInt, UInt, UInt, UInt)

    NYCbCrA::to_string

    fn NYCbCrA::to_string(self : NYCbCrA) -> String

    Palette

    pub(all) struct Palette(
    Slice
    [&Color])

    Palette is a palette of colors and satisfies the Model trait.
    impl Model for Palette

    Palette::convert

    fn Palette::convert(self : Palette, c : &Color) -> &Color

    Palette::from

    fn Palette::from(arr : Array[&Color]) -> Palette

    Palette::from makes a new palette from the provided colors.

    Palette::get

    #alias("_[_]")
    fn Palette::get(self : Palette, idx : Int) -> &Color

    Palette::get_palette

    fn Palette::get_palette(self : Palette) -> Palette?

    Palette::index

    fn Palette::index(self : Palette, c : &Color) -> Int

    index returns the index of the palette color closest to c in Euclidean R,G,B,A space.

    Palette::length

    fn Palette::length(self : Palette) -> Int

    Palette::name

    fn Palette::name(_self : Palette) -> String

    Palette::new

    fn Palette::new(n : Int) -> Palette

    Palette::new makes a new palette with n colors (initially all black).

    Palette::new_empty

    fn Palette::new_empty() -> Palette

    Palette::set

    #alias("_[_]=_")
    fn Palette::set(self : Palette, idx : Int, c : &Color) -> Unit

    Palette::sub

    #alias("_[_:_]")
    fn Palette::sub(self : Palette, start? : Int, end~ : Int) -> Palette

    RGBA

    pub(all) struct RGBA {
    r : Byte
    g : Byte
    b : Byte
    a : Byte
    } derive(Eq)

    RGBA represents a traditional 32-bit alpha-premultiplied color, having 8 bits for each of red, green, blue and alpha.

    An alpha-premultiplied color component C has been scaled by alpha (A), so has valid values 0 <= C <= A.
    impl Color for RGBA
    impl Show for RGBA

    RGBA::equal

    fn RGBA::equal(RGBA, RGBA) -> Bool

    RGBA::from

    fn RGBA::from(c : &Color) -> RGBA

    RGBA::model

    fn RGBA::model(_self : RGBA) -> String

    RGBA::new

    fn RGBA::new(r : Byte, g : Byte, b : Byte, a : Byte) -> RGBA

    RGBA::raw

    fn RGBA::raw(self : RGBA) -> (UInt, UInt, UInt, UInt)

    RGBA::rgba

    fn RGBA::rgba(self : RGBA) -> (UInt, UInt, UInt, UInt)

    RGBA::to_string

    fn RGBA::to_string(self : RGBA) -> String

    RGBA64

    pub(all) struct RGBA64 {
    r : UInt
    g : UInt
    b : UInt
    a : UInt
    } derive(Eq)

    RGBA64 represents a 64-bit alpha-premultiplied color, having 16 bits for each of red, green, blue and alpha.

    An alpha-premultiplied color component C has been scaled by alpha (A), so has valid values 0 <= C <= A.
    impl Color for RGBA64
    impl Show for RGBA64

    RGBA64::equal

    fn RGBA64::equal(RGBA64, RGBA64) -> Bool

    RGBA64::from

    fn RGBA64::from(c : &Color) -> RGBA64

    RGBA64::model

    fn RGBA64::model(_self : RGBA64) -> String

    RGBA64::new

    fn RGBA64::new(r : UInt, g : UInt, b : UInt, a : UInt) -> RGBA64

    RGBA64::raw

    fn RGBA64::raw(self : RGBA64) -> (UInt, UInt, UInt, UInt)

    RGBA64::rgba

    fn RGBA64::rgba(self : RGBA64) -> (UInt, UInt, UInt, UInt)

    RGBA64::to_string

    fn RGBA64::to_string(self : RGBA64) -> String

    YCbCr

    pub(all) struct YCbCr {
    y : Byte
    cb : Byte
    cr : Byte
    } derive(Eq)

    YCbCr represents a fully opaque 24-bit Y'CbCr color, having 8 bits each for one luma and two chroma components.

    JPEG, VP8, the MPEG family and other codecs use this color model. Such codecs often use the terms YUV and Y'CbCr interchangeably, but strictly speaking, the term YUV applies only to analog video signals, and Y' (luma) is Y (luminance) after applying gamma correction.

    Conversion between RGB and Y'CbCr is lossy and there are multiple, slightly different formulae for converting between the two. This package follows the JFIF specification at https://www.w3.org/Graphics/JPEG/jfif3.pdf.
    impl Color for YCbCr
    impl Show for YCbCr

    YCbCr::equal

    fn YCbCr::equal(YCbCr, YCbCr) -> Bool

    YCbCr::from

    fn YCbCr::from(c : &Color) -> YCbCr

    YCbCr::model

    fn YCbCr::model(_self : YCbCr) -> String

    YCbCr::new

    fn YCbCr::new(y : Byte, cb : Byte, cr : Byte) -> YCbCr

    YCbCr::raw

    fn YCbCr::raw(self : YCbCr) -> (UInt, UInt, UInt, UInt)

    YCbCr::rgba

    fn YCbCr::rgba(self : YCbCr) -> (UInt, UInt, UInt, UInt)

    YCbCr::to_string

    fn YCbCr::to_string(self : YCbCr) -> String

    alpha16_model

    let alpha16_model : &Model

    alpha_model

    let alpha_model : &Model

    black

    let black : Gray16

    Standard colors.

    cmyk_model

    let cmyk_model : &Model

    cmyk_model is the [Model] for CMYK colors.

    cmyk_to_rgb

    fn cmyk_to_rgb(c : Byte, m : Byte, y : Byte, k : Byte) -> (Byte, Byte, Byte)

    cmyk_to_rgb converts a [CMYK] quadruple to an RGB triple.

    gray16_model

    let gray16_model : &Model

    gray_model

    let gray_model : &Model

    model_func

    fn model_func(f : (&Color) -> &Color, name : String, palette : Palette?) -> &Model

    model_func returns a [Model] that invokes f to implement the conversion.

    n_y_cb_cr_a_model

    let n_y_cb_cr_a_model : &Model

    n_y_cb_cr_a_model is the [Model] for non-alpha-premultiplied Y'CbCr-with-alpha colors.

    nrgba64_model

    let nrgba64_model : &Model

    nrgba_model

    let nrgba_model : &Model

    opaque_

    let opaque_ : Alpha16

    rgb_to_cmyk

    fn rgb_to_cmyk(r : Byte, g : Byte, b : Byte) -> (Byte, Byte, Byte, Byte)

    rgb_to_cmyk converts an RGB triple to a CMYK quadruple.

    rgb_to_y_cb_cr

    fn rgb_to_y_cb_cr(r : Byte, g : Byte, b : Byte) -> (Byte, Byte, Byte)

    rgb_to_y_cb_cr converts an RGB triple to a Y'CbCr triple.

    rgba64_model

    let rgba64_model : &Model

    rgba_model

    let rgba_model : &Model

    Models for the standard color types.

    transparent

    let transparent : Alpha16

    white

    let white : Gray16

    y_cb_cr_model

    let y_cb_cr_model : &Model

    y_cb_cr_model is the [Model] for Y'CbCr colors.

    y_cb_cr_to_rgb

    fn y_cb_cr_to_rgb(y : Byte, cb : Byte, cr : Byte) -> (Byte, Byte, Byte)

    y_cb_cr_to_rgb converts a Y'CbCr triple to an RGB triple.