image.color
Constants #
const rgba_model = Model(ModelKind.rgba)
const rgba64_model = Model(ModelKind.rgba64)
const nrgba_model = Model(ModelKind.nrgba)
const nrgba64_model = Model(ModelKind.nrgba64)
const alpha_model = Model(ModelKind.alpha)
const alpha16_model = Model(ModelKind.alpha16)
const gray_model = Model(ModelKind.gray)
const gray16_model = Model(ModelKind.gray16)
const ycbcr_model = Model(ModelKind.ycbcr)
const nycbcra_model = Model(ModelKind.nycbcra)
const cmyk_model = Model(ModelKind.cmyk)
const black = Color(Gray16{})
const white = Color(Gray16{
y: 0xffff
})
const transparent = Color(Alpha16{})
const opaque = Color(Alpha16{
a: 0xffff
})
fn cmyk_to_rgb #
fn cmyk_to_rgb(c u8, m u8, y u8, k u8) (u8, u8, u8)
cmyk_to_rgb converts a CMYK quadruple to an RGB triple.
fn constant_model #
fn constant_model(c Color) Model
constant_model returns a model that converts every input color to c.
fn rgb_to_cmyk #
fn rgb_to_cmyk(r u8, g u8, b u8) (u8, u8, u8, u8)
rgb_to_cmyk converts an RGB triple to a CMYK quadruple.
fn rgb_to_ycbcr #
fn rgb_to_ycbcr(r u8, g u8, b u8) (u8, u8, u8)
rgb_to_ycbcr converts an RGB triple to a JFIF Y'CbCr triple.
fn to_alpha #
fn to_alpha(c Color) Alpha
to_alpha converts c to Alpha.
fn to_alpha16 #
fn to_alpha16(c Color) Alpha16
to_alpha16 converts c to Alpha16.
fn to_cmyk #
fn to_cmyk(c Color) CMYK
to_cmyk converts c to CMYK.
fn to_gray #
fn to_gray(c Color) Gray
to_gray converts c to Gray.
fn to_gray16 #
fn to_gray16(c Color) Gray16
to_gray16 converts c to Gray16.
fn to_nrgba #
fn to_nrgba(c Color) NRGBA
to_nrgba converts c to NRGBA.
fn to_nrgba64 #
fn to_nrgba64(c Color) NRGBA64
to_nrgba64 converts c to NRGBA64.
fn to_nycbcra #
fn to_nycbcra(c Color) NYCbCrA
to_nycbcra converts c to NYCbCrA.
fn to_rgba #
fn to_rgba(c Color) RGBA
to_rgba converts c to RGBA.
fn to_rgba64 #
fn to_rgba64(c Color) RGBA64
to_rgba64 converts c to RGBA64.
fn to_ycbcr #
fn to_ycbcr(c Color) YCbCr
to_ycbcr converts c to YCbCr.
fn ycbcr_to_rgb #
fn ycbcr_to_rgb(y u8, cb u8, cr u8) (u8, u8, u8)
ycbcr_to_rgb converts a JFIF Y'CbCr triple to an RGB triple.
fn ModelKind.from #
fn ModelKind.from[W](input W) !ModelKind
type Color #
type Color = Alpha
| Alpha16
| CMYK
| Gray
| Gray16
| NRGBA
| NRGBA64
| NYCbCrA
| RGBA
| RGBA64
| YCbCr
Color is the set of color types provided by this module.
fn (Color) rgba #
fn (c Color) rgba() (u32, u32, u32, u32)
rgba returns the alpha-premultiplied red, green, blue, and alpha channels as 16-bit values stored in u32s.
type Model #
type Model = ConstantModel | ModelKind | Palette
Model converts colors into a color model.
fn (Model) convert #
fn (m Model) convert(c Color) !Color
convert converts c into the receiver's color model.
enum ModelKind #
enum ModelKind {
rgba
rgba64
nrgba
nrgba64
alpha
alpha16
gray
gray16
ycbcr
nycbcra
cmyk
}
ModelKind identifies one of the standard color conversion models.
fn (ModelKind) convert #
fn (m ModelKind) convert(c Color) Color
convert converts c into the receiver's standard color model.
struct Alpha #
struct Alpha {
pub mut:
a u8
}
Alpha represents an 8-bit alpha color.
fn (Alpha) rgba #
fn (c Alpha) rgba() (u32, u32, u32, u32)
rgba returns the alpha channel copied into each alpha-premultiplied channel.
struct Alpha16 #
struct Alpha16 {
pub mut:
a u16
}
Alpha16 represents a 16-bit alpha color.
fn (Alpha16) rgba #
fn (c Alpha16) rgba() (u32, u32, u32, u32)
rgba returns the alpha channel copied into each alpha-premultiplied channel.
struct CMYK #
struct CMYK {
pub mut:
c u8
m u8
y u8
k u8
}
CMYK represents an opaque CMYK color.
fn (CMYK) rgba #
fn (c CMYK) rgba() (u32, u32, u32, u32)
rgba converts c to alpha-premultiplied 16-bit RGBA channels.
struct ConstantModel #
struct ConstantModel {
pub mut:
c Color
}
ConstantModel converts every input color to c.
fn (ConstantModel) convert #
fn (m ConstantModel) convert(c Color) Color
convert converts c into the receiver's constant color.
struct Gray #
struct Gray {
pub mut:
y u8
}
Gray represents an 8-bit grayscale color.
fn (Gray) rgba #
fn (c Gray) rgba() (u32, u32, u32, u32)
rgba returns the grayscale channel as opaque red, green, and blue channels.
struct Gray16 #
struct Gray16 {
pub mut:
y u16
}
Gray16 represents a 16-bit grayscale color.
fn (Gray16) rgba #
fn (c Gray16) rgba() (u32, u32, u32, u32)
rgba returns the grayscale channel as opaque red, green, and blue channels.
struct NRGBA #
struct NRGBA {
pub mut:
r u8
g u8
b u8
a u8
}
NRGBA represents a non-alpha-premultiplied 32-bit color.
fn (NRGBA) rgba #
fn (c NRGBA) rgba() (u32, u32, u32, u32)
rgba returns the alpha-premultiplied red, green, blue, and alpha channels as 16-bit values stored in u32s.
struct NRGBA64 #
struct NRGBA64 {
pub mut:
r u16
g u16
b u16
a u16
}
NRGBA64 represents a non-alpha-premultiplied 64-bit color.
fn (NRGBA64) rgba #
fn (c NRGBA64) rgba() (u32, u32, u32, u32)
rgba returns the alpha-premultiplied red, green, blue, and alpha channels as 16-bit values stored in u32s.
struct NYCbCrA #
struct NYCbCrA {
pub mut:
ycbcr YCbCr
a u8
}
NYCbCrA represents a non-alpha-premultiplied JFIF Y'CbCr-with-alpha color.
fn (NYCbCrA) rgba #
fn (c NYCbCrA) rgba() (u32, u32, u32, u32)
rgba converts c to alpha-premultiplied 16-bit RGBA channels.
struct Palette #
struct Palette {
pub mut:
colors []Color
}
Palette is an ordered list of colors.
fn (Palette) convert #
fn (p Palette) convert(c Color) !Color
convert returns the palette color closest to c.
fn (Palette) index #
fn (p Palette) index(c Color) int
index returns the index of the palette color closest to c in RGBA space.
struct RGBA #
struct RGBA {
pub mut:
r u8
g u8
b u8
a u8
}
RGBA represents a 32-bit alpha-premultiplied color.
fn (RGBA) rgba #
fn (c RGBA) rgba() (u32, u32, u32, u32)
rgba returns the alpha-premultiplied red, green, blue, and alpha channels as 16-bit values stored in u32s.
struct RGBA64 #
struct RGBA64 {
pub mut:
r u16
g u16
b u16
a u16
}
RGBA64 represents a 64-bit alpha-premultiplied color.
fn (RGBA64) rgba #
fn (c RGBA64) rgba() (u32, u32, u32, u32)
rgba returns the alpha-premultiplied red, green, blue, and alpha channels as 16-bit values stored in u32s.
struct YCbCr #
struct YCbCr {
pub mut:
y u8
cb u8
cr u8
}
YCbCr represents an opaque JFIF Y'CbCr color.
fn (YCbCr) rgba #
fn (c YCbCr) rgba() (u32, u32, u32, u32)
rgba converts c to alpha-premultiplied 16-bit RGBA channels.
- Constants
- fn cmyk_to_rgb
- fn constant_model
- fn rgb_to_cmyk
- fn rgb_to_ycbcr
- fn to_alpha
- fn to_alpha16
- fn to_cmyk
- fn to_gray
- fn to_gray16
- fn to_nrgba
- fn to_nrgba64
- fn to_nycbcra
- fn to_rgba
- fn to_rgba64
- fn to_ycbcr
- fn ycbcr_to_rgb
- fn ModelKind.from
- type Color
- type Model
- enum ModelKind
- struct Alpha
- struct Alpha16
- struct CMYK
- struct ConstantModel
- struct Gray
- struct Gray16
- struct NRGBA
- struct NRGBA64
- struct NYCbCrA
- struct Palette
- struct RGBA
- struct RGBA64
- struct YCbCr