Skip to main content

Crate color8

Crate color8 

Source
Expand description

color8 — fast 8-bit color primitives for no_std embedded targets.

This is a Rust port of FastLED’s colorutils: the CRGB/CHSV pixel types with their arithmetic and scaling operators, the HSV↔RGB conversions, and the array fill/gradient helpers used throughout FastLED’s effects.

The port targets FastLED 3.6.0 — the last release before upstream moved everything into the fl:: namespace and split colorutils.cpp apart. Every function here is validated bit-for-bit against a C transcription of that release (see the fastled-ref test crate).

All functions are pure integer math with defined overflow behavior (saturating, wrapping or truncating, matching the semantics of the original C) — nothing here panics or allocates.

Re-exports§

pub use blend::blend;
pub use blend::blend_hsv;
pub use blend::blend_hsv_slice;
pub use blend::blend_slice;
pub use blend::nblend;
pub use blend::nblend_hsv;
pub use blend::nblend_hsv_slice;
pub use blend::nblend_slice;
pub use fill::FromHsv;
pub use fill::GradientDirection;
pub use fill::fade_light_by;
pub use fill::fade_raw;
pub use fill::fade_to_black_by;
pub use fill::fade_using_color;
pub use fill::fade_video;
pub use fill::fill_gradient;
pub use fill::fill_gradient_range;
pub use fill::fill_gradient_rgb;
pub use fill::fill_gradient_rgb_range;
pub use fill::fill_gradient_rgb3;
pub use fill::fill_gradient_rgb4;
pub use fill::fill_gradient3;
pub use fill::fill_gradient4;
pub use fill::fill_rainbow;
pub use fill::fill_rainbow_circular;
pub use fill::fill_solid;
pub use fill::nscale8;
pub use fill::nscale8_raw;
pub use fill::nscale8_video;
pub use gradient_palette::crgb_palette16_from_gradient;
pub use gradient_palette::crgb_palette32_from_gradient;
pub use gradient_palette::crgb_palette256_from_gradient;
pub use heat::heat_color;
pub use hsv::Chsv;
pub use hsv::HsvHue;
pub use hsv::hsv2rgb_rainbow;
pub use hsv::hsv2rgb_spectrum;
pub use hsv::rgb2hsv_approximate;
pub use palette::ChsvPalette16;
pub use palette::ChsvPalette32;
pub use palette::ChsvPalette256;
pub use palette::ColorBlend;
pub use palette::CrgbPalette16;
pub use palette::CrgbPalette32;
pub use palette::CrgbPalette256;
pub use palette::Palette;
pub use palette::color_from_palette16;
pub use palette::color_from_palette16_hsv;
pub use palette::color_from_palette32;
pub use palette::color_from_palette32_hsv;
pub use palette::color_from_palette256;
pub use palette::color_from_palette256_hsv;
pub use palette::fill_palette;
pub use palette::fill_palette_circular;
pub use palette::nblend_palette_toward_palette;
pub use palette::upscale_palette16_to_32;
pub use palette::upscale_palette16_to_32_hsv;
pub use palette::upscale_palette16_to_256;
pub use palette::upscale_palette16_to_256_hsv;
pub use palette::upscale_palette32_to_256;
pub use palette::upscale_palette32_to_256_hsv;
pub use presets::CLOUD_COLORS;
pub use presets::FOREST_COLORS;
pub use presets::HEAT_COLORS;
pub use presets::LAVA_COLORS;
pub use presets::OCEAN_COLORS;
pub use presets::PARTY_COLORS;
pub use presets::PARTY_COLORS_GC22;
pub use presets::RAINBOW_COLORS;
pub use presets::RAINBOW_COLORS_GC22;
pub use presets::RAINBOW_GRADIENT_BYTES;
pub use presets::RAINBOW_STRIPE_COLORS;
pub use presets::RAINBOW_STRIPE_COLORS_GC22;
pub use presets::rainbow_gradient_palette16;
pub use rgb::Crgb;

Modules§

blend
Blending one color or strip toward another.
fill
Array fill and gradient helpers.
gradient_palette
Parsing FastLED’s gradient-palette byte format into CrgbPalette16/32/ 256, direct port of CRGBPalette16/32/256’s operator=(TProgmemRGBGradientPalette_bytes) in colorutils.h (FastLED 3.6.0), transcribed from the actual 3.6.0-tagged source.
heat
HeatColor — direct port of src/colorutils.cpp in FastLED 3.6.0.
hsv
The Chsv pixel type and the HSV↔RGB conversions.
palette
CrgbPalette16/32/256, ChsvPalette16/32/256, ColorFromPalette, nblendPaletteTowardPalette and UpscalePalette — direct port of the palette logic in FastLED 3.6.0’s colorutils.cpp, transcribed from the actual 3.6.0-tagged source (github.com/FastLED/FastLED, tag 3.6.0). Only the RAM-backed palette overloads are ported — not the TProgmemRGBPalette* ones, which color8 has no analogue of.
presets
FastLED’s predefined palettes (src/colorpalettes.cpp, FastLED 3.6.0), transcribed from the actual 3.6.0-tagged source. Named-color values (CRGB::Blue and friends) are taken from the standard HTML/CSS color hex codes FastLED’s CRGB enum uses (src/pixeltypes.h).
rgb
Crgb — an 8-bit RGB pixel and its arithmetic/scaling operators.