An abstract, safe, and concise color conversion library for rust nightly This requires the feature adt_const_params

Overview

colortypes

crates.io Documentation

A type safe color conversion library

This crate provides many methods for converting between color types.

Everything is implemented abstractly, and is easily extensible by the user.

When converting you call the from_color method of the colortype struct on your color!

Implemented conversions:

From To Method
RGB XYZ Directly
RGB HSV Directly
RGB HSL Directly
RGB LCH Through XYZ
RGB LAB Through XYZ
LAB LCH Directly

Example usage

use colortypes::{Color, FromColorType, RefWhite::*, Rgba, Xyza};

fn main() {
    // You can directly call Rgba this way (defaults to D65)
    let color = Rgba::new([0.0, 0.0, 0.0, 1.0]);
    // You can directly call Rgba this way and specify white reference
    let color = Rgba::new_w::<{ D65 }>([0.0, 0.0, 0.0, 1.0]);
    // Or can call Color and specify Rgba this way
    let color = Color::<Rgba, { D65 }>::new([0.0, 0.0, 0.0, 1.0]);

    // To convert to Xyza
    let new_color = Xyza::from_color(color);
}

Images

This crate also provides a type for dealing with images, it's still work in progress

use colortypes::{Align, Image, RefWhite::*, Rgba, Xyya};

fn main() {
    let mut img = Image::<Rgba, { D65 }>::new((6000, 4000));

    img.put_pixel((0, 0), Rgba::new([0.7, 0.3, 0.2, 1.0]));

    let new_img = img.convert::<Xyya>();
    let new_img_b = img.convert::<Xyya>();
    let mut new_img = ((new_img + new_img_b) / 2.0).convert::<Rgba>();

    new_img = new_img.crop_align((Align::Front, Align::Front), (256, 256));

    let my_col = new_img.get_pixel((0, 0));
}
You might also like...
High-performance Javascript color gradient library powered by Rust + WebAssembly

colorgrad-js High-performance Javascript color gradient library powered by Rust + WebAssembly. No dependencies. Faster than d3-scale, chroma-js, culor

Efficient scan conversion of a line segment with clipping to a rectangular window.
Efficient scan conversion of a line segment with clipping to a rectangular window.

✂️ clipline 📏 clipline is a Rust crate for efficient scan conversion of a line segment with clipping to a rectangular window. It is an implementation

Blazingly fast interpolated LUT generator and applicator for arbitrary and popular color palettes.
Blazingly fast interpolated LUT generator and applicator for arbitrary and popular color palettes.

lutgen-rs A blazingly fast interpolated LUT generator and applicator for arbitrary and popular color palettes. Theme any image to your dekstop colorsc

A lightweight but incredibly powerful and feature-rich BitTorrent tracker. Supports UDP + HTTP(S) and a private tracker mode.

Torrust Tracker Project Description Torrust Tracker is a lightweight but incredibly powerful and feature-rich BitTorrent tracker made using Rust. Feat

A rust crate for working with colors and color spaces.
A rust crate for working with colors and color spaces.

Color Art A rust crate for working with colors and color spaces. Documentation See Color Art. Usage Add Dependency [dependencies] color-art = "0.2" Co

`ls` alternative with useful info and a splash of color 🎨
`ls` alternative with useful info and a splash of color 🎨

🎨 Natls 🎨 Why Natls? Showing file permissions Showing file size Showing the date that the file was modified last Showing the user that the file belo

Detects whether a terminal supports color, and gives details about that support

Detects whether a terminal supports color, and gives details about that support. It takes into account the NO_COLOR environment variable. This crate i

Convert your favorite images and wallpapers with your favorite color palettes/themes
Convert your favorite images and wallpapers with your favorite color palettes/themes

dipc doprz' image palette converter Convert your favorite images and wallpapers with your favorite color palettes/themes Color Palettes/Themes catppuc

🖥  A feature rich terminal UI file transfer and explorer with support for SCP/SFTP/FTP/S3
🖥 A feature rich terminal UI file transfer and explorer with support for SCP/SFTP/FTP/S3

🖥 A feature rich terminal UI file transfer and explorer with support for SCP/SFTP/FTP/S3

Owner
Jacob
I like image processing, I've been getting into the gradient domain lately! I like to use Rust or python :)
Jacob
Build Abstract Syntax Trees and tree-walking models quickly in Rust.

astmaker Build Abstract Syntax Trees and tree-walking models quickly in Rust. Example This example creates an AST for simple math expressions, and an

David Delassus 100 Jun 5, 2023
Rustato: A powerful, thread-safe global state management library for Rust applications, offering type-safe, reactive state handling with an easy-to-use macro-based API.

Rustato State Manager A generical thread-safe global state manager for Rust Introduction • Features • Installation • Usage • Advanced Usage • Api Refe

BiteCraft 8 Sep 16, 2024
SVG to PDF file conversion based on "svg2pdf" and "resvg" Rust projects

pysvg2pdf Blazingly Fast ™️ SVG to PDF file conversion for Python. This project is based on Rust's svg2pdf and resvg projects. The project uses pyo3 a

SuffleWaffle 4 Mar 28, 2024
Rust library to convert RGB 24-bit colors into ANSI 256 (8-bit) color codes with zero dependencies and at compile-time.

rgb2ansi256 rgb2ansi256 is a small Rust library to convert RGB 24-bit colors into ANSI 256 (8-bit) color codes with zero dependencies and const fn. Th

Linda_pp 7 Nov 17, 2022
Fast conversion between linear float and 8-bit sRGB

fast-srgb8 Small crate implementing fast conversion between linear float and 8-bit sRGB. Includes API for performing 4 simultaneous conversions, which

Thom Chiovoloni 13 Sep 3, 2022
Fixed point to floating point (and back) conversion utility

fixed2float Simple utility for fixed point to real number conversions, using the VisSim (Fxm.b) and Q (Qm.n) notations. Usage as a dependency of your

Francesco Urbani 2 Aug 5, 2022
Core Fiberplane data models and methods for transforming them (templates, providers, markdown conversion)

fiberplane This repository is a monorepo for Rust code that is used throughout Fiberplane's product. Overview base64uuid - A utility for working with

Fiberplane 18 Feb 22, 2023
A library that creates a terminal-like window with feature-packed drawing of text and easy input handling. MIRROR.

BearLibTerminal provides a pseudoterminal window with a grid of character cells and a simple yet powerful API for flexible textual output and uncompli

Tommy Ettinger 43 Oct 31, 2022
Rust implementation of custom numeric base conversion.

base_custom Use any characters as your own numeric base and convert to and from decimal. This can be taken advantage of in various ways: Mathematics:

Daniel P. Clark 5 Dec 28, 2021
A dead simple ANSI terminal color painting library for Rust.

yansi A dead simple ANSI terminal color painting library for Rust. use yansi::Paint; print!("{} light, {} light!", Paint::green("Green"), Paint::red(

Sergio Benitez 169 Dec 25, 2022