Package color

import "image/color"
Overview
Index
Subdirectories

Overview ▾

包颜色实现一个基本的颜色库.

Variables

标准颜色.

var (
    Black       = Gray16{0}
    White       = Gray16{0xffff}
    Transparent = Alpha16{0}
    Opaque      = Alpha16{0xffff}
)

func CMYKToRGB 1.5

func CMYKToRGB(c, m, y, k uint8) (uint8, uint8, uint8)

CMYKToRGB将CMYK四元转换为RGB三元.

func RGBToCMYK 1.5

func RGBToCMYK(r, g, b uint8) (uint8, uint8, uint8, uint8)

RGBToCMYK将RGB三重转换为CMYK四重.

func RGBToYCbCr

func RGBToYCbCr(r, g, b uint8) (uint8, uint8, uint8)

RGBToYCbCr将RGB三元组转换为Y'CbCr三元组.

func YCbCrToRGB

func YCbCrToRGB(y, cb, cr uint8) (uint8, uint8, uint8)

YCbCrToRGB将Y'CbCr三元组转换为RGB三元组.

type Alpha

Alpha代表8位Alpha颜色.

type Alpha struct {
    A uint8
}

func (Alpha) RGBA

func (c Alpha) RGBA() (r, g, b, a uint32)

type Alpha16

Alpha16代表16位alpha颜色.

type Alpha16 struct {
    A uint16
}

func (Alpha16) RGBA

func (c Alpha16) RGBA() (r, g, b, a uint32)

type CMYK 1.5

CMYK表示完全不透明的CMYK颜色,对于青色,品红色,黄色和黑色分别具有8位.

它与任何特定的颜色配置文件都不相关.

type CMYK struct {
    C, M, Y, K uint8
}

func (CMYK) RGBA 1.5

func (c CMYK) RGBA() (uint32, uint32, uint32, uint32)

type Color

颜色可以将其自身转换为每个通道RGBA的alpha预乘16位. 转换可能是有损的.

type Color interface {
    // RGBA returns the alpha-premultiplied red, green, blue and alpha values
    // for the color. Each value ranges within [0, 0xffff], but is represented
    // by a uint32 so that multiplying by a blend factor up to 0xffff will not
    // overflow.
    //
    // An alpha-premultiplied color component c has been scaled by alpha (a),
    // so has valid values 0 <= c <= a.
    RGBA() (r, g, b, a uint32)
}

type Gray

灰色表示8位灰度色.

type Gray struct {
    Y uint8
}

func (Gray) RGBA

func (c Gray) RGBA() (r, g, b, a uint32)

type Gray16

Gray16表示16位灰度色.

type Gray16 struct {
    Y uint16
}

func (Gray16) RGBA

func (c Gray16) RGBA() (r, g, b, a uint32)

type Model

模型可以将任何颜色从其自己的颜色模型转换为一种颜色. 转换可能是有损的.

type Model interface {
    Convert(c Color) Color
}

标准颜色类型的模型.

var (
    RGBAModel    Model = ModelFunc(rgbaModel)
    RGBA64Model  Model = ModelFunc(rgba64Model)
    NRGBAModel   Model = ModelFunc(nrgbaModel)
    NRGBA64Model Model = ModelFunc(nrgba64Model)
    AlphaModel   Model = ModelFunc(alphaModel)
    Alpha16Model Model = ModelFunc(alpha16Model)
    GrayModel    Model = ModelFunc(grayModel)
    Gray16Model  Model = ModelFunc(gray16Model)
)

CMYKModel是CMYK颜色的模型.

var CMYKModel Model = ModelFunc(cmykModel)

NYCbCrAModel是非Alpha预乘Y'CbCr-alpha颜色的模型.

var NYCbCrAModel Model = ModelFunc(nYCbCrAModel)

YCbCrModel是Y'CbCr颜色的模型.

var YCbCrModel Model = ModelFunc(yCbCrModel)

func ModelFunc

func ModelFunc(f func(Color) Color) Model

ModelFunc返回一个调用f来实现转换的Model.

type NRGBA

NRGBA表示非alpha预乘的32位颜色.

type NRGBA struct {
    R, G, B, A uint8
}

func (NRGBA) RGBA

func (c NRGBA) RGBA() (r, g, b, a uint32)

type NRGBA64

NRGBA64表示非alpha乘以的64位颜色,红色,绿色,蓝色和alpha分别具有16位.

type NRGBA64 struct {
    R, G, B, A uint16
}

func (NRGBA64) RGBA

func (c NRGBA64) RGBA() (r, g, b, a uint32)

type NYCbCrA 1.6

NYCbCrA表示非alpha乘以Y'CbCr-alpha的颜色,每个颜色具有8位,分别代表一个亮度,两个色度和一个alpha分量.

type NYCbCrA struct {
    YCbCr
    A uint8
}

func (NYCbCrA) RGBA 1.6

func (c NYCbCrA) RGBA() (uint32, uint32, uint32, uint32)

type Palette

调色板是颜色的调色板.

type Palette []Color

func (Palette) Convert

func (p Palette) Convert(c Color) Color

Convert返回在欧几里得R,G,B空间中最接近c的调色板颜色.

func (Palette) Index

func (p Palette) Index(c Color) int

Index返回在欧几里得R,G,B,A空间中最接近c的调色板颜色的索引.

type RGBA

RGBA代表传统的32位alpha乘以颜色,红色,绿色,蓝色和alpha分别具有8位.

预先乘以alpha的颜色分量C已按alpha(A)进行缩放,因此有效值0 <= C <=A.

type RGBA struct {
    R, G, B, A uint8
}

func (RGBA) RGBA

func (c RGBA) RGBA() (r, g, b, a uint32)

type RGBA64

RGBA64表示64位alpha乘以的颜色,红色,绿色,蓝色和alpha分别具有16位.

预先乘以alpha的颜色分量C已按alpha(A)进行缩放,因此有效值0 <= C <=A.

type RGBA64 struct {
    R, G, B, A uint16
}

func (RGBA64) RGBA

func (c RGBA64) RGBA() (r, g, b, a uint32)

type YCbCr

YCbCr表示完全不透明的24位Y'CbCr颜色,一个亮度和两个色度分量各具有8位.

JPEG,VP8,MPEG系列和其他编解码器使用此颜色模型. 这样的编解码器经常互换使用术语YUV和Y'CbCr,但是严格来说,术语YUV仅适用于模拟视频信号,并且在应用伽马校正后,Y'(亮度)为Y(亮度).

RGB和Y'CbCr之间的转换是有损耗的,并且在两者之间存在多个略有不同的公式. 该软件包遵循JFIF规范, 网址https://www.w3.org/Graphics/JPEG/jfif3.pdf .

type YCbCr struct {
    Y, Cb, Cr uint8
}

func (YCbCr) RGBA

func (c YCbCr) RGBA() (uint32, uint32, uint32, uint32)

Subdirectories

Name Synopsis
..
palette 包装调色板提供标准的调色板.

by  ICOPY.SITE