Cichlid
A simple Rust library for managing RGB colorings. Works with no-std
environments as well.
Currently this library is geared toward use in embedded systems, but does contain useful APIs that are more generally useful.
-
Fast
u8
andu16
math — 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
HSV
andColorRGB
structures. Different means of converting fromHSV
toColorRGB
are 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
PowerEstimator
trait.
This Library is still in its infancy, and as such there may be a lack of documentation and vigorous testing.
Examples
General Color operations:
use *;
let red = Red;
let blue = Blue;
let mut purple = red + blue;
assert_eq!;
purple.scale; // Scale by half
assert_eq!;
purple *= 2; // Multiple all components by two
assert_eq!;
Using HSV
(Hue, Saturation, Value) and converting to ColorRGB
:
use *;
let red_hsv = HSV new;
let red_rgb = from;
assert_eq!;
Creating a gradient is very easy, simply import the trait and call the method:
use *;
let mut colors = ;
let start = HSV new;
let end = HSV new;
colors.gradient_fill;
Contributing
Any and all contributions are welcome! Open up a PR to contribute some improvements. Look at the Issues tab to see what needs some help.
License
Cichlid is distributed under the terms of the MIT license. See LICENSE-MIT for details. Opening a pull requests is assumed to signal agreement with these licensing terms.