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::from

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

    Alpha::new

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

    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::from

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

    Alpha16::new

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

    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::from

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

    CMYK::new

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

    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::from

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

    Gray::new

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

    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::from

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

    Gray16::new

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

    ModelFunc

    type ModelFunc

    impl Model for ModelFunc

    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::from

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

    NRGBA::new

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

    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::from

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

    NRGBA64::new

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

    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::new

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

    Palette

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

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

    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::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::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::from

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

    RGBA::new

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

    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::from

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

    RGBA64::new

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

    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::from

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

    YCbCr::new

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

    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.

    Source Files

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io