module

Image::Color

Image Foundation - Color Types

This module provides standard color and pixel value types for the Crystal image ecosystem.

Design principles:

  • Value types (structs) for zero-cost abstraction
  • Explicit semantics (premultiplied vs non-premultiplied alpha)
  • Clear bit depth (8-bit vs 16-bit)
  • RGB values implicitly use sRGB color space

Class methods

alpha(a : UInt8) : Alpha8

Factory method for creating Alpha8 values

Source
alpha16(a : UInt16) : Alpha16

Factory method for creating Alpha16 values

Source
cmyk(c : UInt8, m : UInt8, y : UInt8, k : UInt8) : CMYK8

Factory method for creating CMYK8 colors

Source
gray(y : UInt8) : Gray8

Factory method for creating Gray8 colors

Source
gray16(y : UInt16) : Gray16

Factory method for creating Gray16 colors

Source
hsl(h : Float64, s : Float64, l : Float64) : HSL

Factory method for creating HSL colors

Source
hsv(h : Float64, s : Float64, v : Float64) : HSV

Factory method for creating HSV colors

Source
lab(l : Float64, a : Float64, b : Float64) : LAB

Factory method for creating LAB colors

Source
nrgba(r : UInt8, g : UInt8, b : UInt8, a : UInt8 = 255_u8) : NRGBA8

Factory method for creating NRGBA8 colors

Source
nrgba16(r : UInt16, g : UInt16, b : UInt16, a : UInt16 = 65535_u16) : NRGBA16

Factory method for creating NRGBA16 colors

Source
nycbcra(y : UInt8, cb : UInt8, cr : UInt8, a : UInt8) : NYCbCrA8

Factory method for creating NYCbCrA8 colors

Source
rgb(r : UInt8, g : UInt8, b : UInt8) : RGB8

Factory method for creating RGB8 colors

Source
rgb16(r : UInt16, g : UInt16, b : UInt16) : RGB16

Factory method for creating RGB16 colors

Source
rgba(r : UInt8, g : UInt8, b : UInt8, a : UInt8 = 255_u8) : RGBA8

Factory method for creating RGBA8 colors

Source
rgba16(r : UInt16, g : UInt16, b : UInt16, a : UInt16 = 65535_u16) : RGBA16

Factory method for creating RGBA16 colors

Source
ycbcr(y : UInt8, cb : UInt8, cr : UInt8) : YCbCr8

Factory method for creating YCbCr8 colors

Source

Nested types