Movatterモバイル変換


[0]ホーム

URL:


color

packagestandard library
go1.25.4Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2025 License:BSD-3-ClauseImports:0Imported by:41,142

Details

Repository

cs.opensource.google/go/go

Links

Documentation

Overview

Package color implements a basic color library.

Index

Constants

This section is empty.

Variables

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

Standard colors.

Functions

funcCMYKToRGBadded ingo1.5

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

CMYKToRGB converts aCMYK quadruple to an RGB triple.

funcRGBToCMYKadded ingo1.5

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

RGBToCMYK converts an RGB triple to a CMYK quadruple.

funcRGBToYCbCr

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

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

funcYCbCrToRGB

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

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

Types

typeAlpha

type Alpha struct {Auint8}

Alpha represents an 8-bit alpha color.

func (Alpha)RGBA

func (cAlpha) RGBA() (r, g, b, auint32)

typeAlpha16

type Alpha16 struct {Auint16}

Alpha16 represents a 16-bit alpha color.

func (Alpha16)RGBA

func (cAlpha16) RGBA() (r, g, b, auint32)

typeCMYKadded ingo1.5

type CMYK struct {C, M, Y, Kuint8}

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.

func (CMYK)RGBAadded ingo1.5

func (cCMYK) RGBA() (uint32,uint32,uint32,uint32)

typeColor

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, auint32)}

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

typeGray

type Gray struct {Yuint8}

Gray represents an 8-bit grayscale color.

func (Gray)RGBA

func (cGray) RGBA() (r, g, b, auint32)

typeGray16

type Gray16 struct {Yuint16}

Gray16 represents a 16-bit grayscale color.

func (Gray16)RGBA

func (cGray16) RGBA() (r, g, b, auint32)

typeModel

type Model interface {Convert(cColor)Color}

Model can convert anyColor to one from its own color model. The conversionmay be lossy.

var (RGBAModelModel =ModelFunc(rgbaModel)RGBA64ModelModel =ModelFunc(rgba64Model)NRGBAModelModel =ModelFunc(nrgbaModel)NRGBA64ModelModel =ModelFunc(nrgba64Model)AlphaModelModel =ModelFunc(alphaModel)Alpha16ModelModel =ModelFunc(alpha16Model)GrayModelModel =ModelFunc(grayModel)Gray16ModelModel =ModelFunc(gray16Model))

Models for the standard color types.

var CMYKModelModel =ModelFunc(cmykModel)

CMYKModel is theModel for CMYK colors.

var NYCbCrAModelModel =ModelFunc(nYCbCrAModel)

NYCbCrAModel is theModel for non-alpha-premultiplied Y'CbCr-with-alphacolors.

var YCbCrModelModel =ModelFunc(yCbCrModel)

YCbCrModel is theModel for Y'CbCr colors.

funcModelFunc

func ModelFunc(f func(Color)Color)Model

ModelFunc returns aModel that invokes f to implement the conversion.

typeNRGBA

type NRGBA struct {R, G, B, Auint8}

NRGBA represents a non-alpha-premultiplied 32-bit color.

func (NRGBA)RGBA

func (cNRGBA) RGBA() (r, g, b, auint32)

typeNRGBA64

type NRGBA64 struct {R, G, B, Auint16}

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

func (NRGBA64)RGBA

func (cNRGBA64) RGBA() (r, g, b, auint32)

typeNYCbCrAadded ingo1.6

type NYCbCrA struct {YCbCrAuint8}

NYCbCrA represents a non-alpha-premultiplied Y'CbCr-with-alpha color, having8 bits each for one luma, two chroma and one alpha component.

func (NYCbCrA)RGBAadded ingo1.6

func (cNYCbCrA) RGBA() (uint32,uint32,uint32,uint32)

typePalette

type Palette []Color

Palette is a palette of colors.

func (Palette)Convert

func (pPalette) Convert(cColor)Color

Convert returns the palette color closest to c in Euclidean R,G,B space.

func (Palette)Index

func (pPalette) Index(cColor)int

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

typeRGBA

type RGBA struct {R, G, B, Auint8}

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

An alpha-premultiplied color component C has been scaled by alpha (A), sohas valid values 0 <= C <= A.

func (RGBA)RGBA

func (cRGBA) RGBA() (r, g, b, auint32)

typeRGBA64

type RGBA64 struct {R, G, B, Auint16}

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

An alpha-premultiplied color component C has been scaled by alpha (A), sohas valid values 0 <= C <= A.

func (RGBA64)RGBA

func (cRGBA64) RGBA() (r, g, b, auint32)

typeYCbCr

type YCbCr struct {Y, Cb, Cruint8}

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

JPEG, VP8, the MPEG family and other codecs use this color model. Suchcodecs often use the terms YUV and Y'CbCr interchangeably, but strictlyspeaking, 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, slightlydifferent formulae for converting between the two. This package followsthe JFIF specification athttps://www.w3.org/Graphics/JPEG/jfif3.pdf.

func (YCbCr)RGBA

func (cYCbCr) RGBA() (uint32,uint32,uint32,uint32)

Source Files

View all Source files

Directories

PathSynopsis
Package palette provides standard color palettes.
Package palette provides standard color palettes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp