no-std compatible library for fast color math, intended for use in programming
Currently this library is geared toward use in embedded systems, but does contain useful APIs that are more generally useful.
u16math — Cichlid includes functions for scaling, dimming, and brightening single and double byte values. Basic trigonometric functions (sine, cosine) are implemented as well.
HSV and RGB support — Full control over each color is provided by the
ColorRGBstructures. Different means of converting from
ColorRGBare also implemented.
Axial (Two Point) Color Gradients — Create smooth transitions between any two colors for any number of steps.
Power Consumption Estimating — Estimating power requirements can be done with structs implementing the
This Library is still in its infancy, and as such there may be a lack of documentation and vigorous testing.
General Color operations:
use cichlid::*; let red = ColorRGB::Red; let blue = ColorRGB::Blue; let mut purple = red + blue; assert_eq!(purple, ColorRGB::new(255, 0, 255)); purple.scale(128); // Scale by half assert_eq!(purple, ColorRGB::new(128, 0, 128)); purple *= 2; // Multiple all components by two assert_eq!(purple, red + blue);
HSV (Hue, Saturation, Value) and converting to
use cichlid::*; let red_hsv = HSV::new(0, 255, 255); let red_rgb = ColorRGB::from(red_hsv); assert_eq!(red_rgb, ColorRGB::Red);
Creating a gradient is very easy, simply import the trait and call the method:
use cichlid::*; let mut colors = [ColorRGB::Black; 100]; let start = HSV::new(0, 255, 255); let end = HSV::new(100, 255, 180); colors.gradient_fill(start, end, GradientDirection::Longest);
To use in a
no-std environment, simply add the following to your project's
[dependencies.cichlid] version = "*" features = ["no-std"]
low-mem feature creates a binary that is smaller due to relying less on in memory
tables, preferring direct computation instead. The only drawback of this is a slight
This library takes heavy inspiration and code-reuse from FastLED, an Arduino library for talking to addressable LEDs.
Raw Color codes.
Various Functions and traits for colors.
Contains the HSV (hue, saturation, value) representation of a color.
Collection of math Traits and functions for manipulating integers.
Allows for estimating the power consumption of a strand of
Easy importing of integer and color auto traits.
Contains the structure and associated methods for a RGB Object.