GithubHelp home page GithubHelp logo

cichlid's Introduction

Cichlid

cichlid crate cichlid docs

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 and u16 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 and ColorRGB structures. Different means of converting from HSV to ColorRGB 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 cichlid::{HSV, ColorRGB};

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);

Using HSV (Hue, Saturation, Value) and converting to ColorRGB:

use cichlid::{HSV, ColorRGB};

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::{HSV, ColorRGB, GradientDirection, prelude::*};
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);

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.