Parse hex colors to tui rgb colors

Overview

Color -> Tui

build build

Parse hex colors to tui rgb colors

#c3f111 -> Color::Rgb(195,241,17)

Note that the indexed colors are NOT HEX
#142 -> Color::Indexed(142)

Example

, } let color_text = r###"{ "color" : "#12FC1C", "optional_color" : "#123" }"### let t: ColorStruct = serde_json::from_str:: (color_text).unwrap(); let c = ColorStruct { color: Color::Rgb(18, 252, 28), optional_color: Option , }; assert_eq!(t, c); ">
#[derive(Serialize, Deserialize, PartialEq)]
sruct ColorStruct {
    #[serde(with = "color_to_tui"]
    color: tui::style::Color,
    #[serde(with = "color_to_tui::optional"]
    optional_color: Option<tui::style::Color>,
}

let color_text =  r###"{ "color" : "#12FC1C", "optional_color" : "#123" }"###
let t: ColorStruct = serde_json::from_str::
     (color_text).
     unwrap();


     let c 
     = ColorStruct {
    color: Color
     ::
     Rgb(
     18, 
     252, 
     28),
    optional_color: 
     Option
     <Color
     ::
     Indexed(
     123)
     >,
};


     assert_eq!(t, c);

    
You might also like...
A template for bootstrapping a Rust TUI application with tui-rs & crossterm
A template for bootstrapping a Rust TUI application with tui-rs & crossterm

rust-tui-template A template for bootstrapping a Rust TUI application with tui-rs & crossterm. tui-rs The library is based on the principle of immedia

RGB (Rust Game Boy) is a simple emulator for the original game boy
RGB (Rust Game Boy) is a simple emulator for the original game boy

RGB RGB (Rust Game Boy) is a simple emulator for the original game boy and the color game boy. Warning: This no longer compiles in the latest versions

Controls the RGB on the keyboard for the Legion 5 Pro from Lenovo. Mostly used for learning a bit of rust.

L5P Keyboard RGB Control Program A fun little experiment. Probably contains bugs. ⚠️ Use at your own risk, the developer is not responsible for any da

Cherry RGB Keyboard Library

Cherry RGB Keyboard Library Tested with Cherry Keyboard G80-3000N RGB (046a:00dd) Features Done Set LED animation Set single-/multi-color (rainbow) Se

Some tools for streaming frames to rpi-rgb-led-matrix using ZeroMQ, written in Rust.

led_matrix_zmq Some tools for streaming frames to rpi-rgb-led-matrix using ZeroMQ, written in Rust. This repository includes: Rust client and server l

RGB smart contracts: client-facing library & command-line for desktop and mobile

RGB smart contracts RGB is confidential & scalable client-validated smart contracts for Bitcoin & Lightning. It embraces the concepts of private & mut

RGB20 Contract Demo based on RGB v0.11.0-beta.6

RGB20 Demo based on RGB v0.11 Pre-request To complete the demo, you need to set up the following toolchains: Git Rust RGB-CLI Bitcoin Local Env RGB-CL

Cork is a simple command-line calculator, mainly targeted towards people who deal with hex numbers
Cork is a simple command-line calculator, mainly targeted towards people who deal with hex numbers

Cork is a simple command-line calculator, mainly targeted towards people who deal with hex numbers. It deals only with integer arithmetic. Expressions may involve mixed bases (limited to decimal, hexadecimal, octal and binary numbers). The global output format may be set to a particular radix - by default it is hex.

TIF is a terminal_image_format. (theres no TIF editor, so i made TIF images through a hex editor lol)

Colors these are the colors you can use when displaying images on the terminal BYTES: 5A = BLUE 5B = BLACK 5C = RED 5D = GREEN 5E = PURPLE 5F = WHITE

hexyl is a simple hex viewer for the terminal. It uses a colored output to distinguish different categories of bytes
hexyl is a simple hex viewer for the terminal. It uses a colored output to distinguish different categories of bytes

hexyl is a simple hex viewer for the terminal. It uses a colored output to distinguish different categories of bytes (NULL bytes, printable ASCII characters, ASCII whitespace characters, other ASCII characters and non-ASCII).

A user-friendly re-implementation of existing hex tools in Rust
A user-friendly re-implementation of existing hex tools in Rust

Hex A project to create alternate (and more user friendly) versions of existing hex tools. The project can be installed as a extension to the github-c

convert nostr keys and note-ids between hex and bech32

Key-Convertr People are copy-pasting nostr private keys into webpages to convert between the original hex-encoding and bech32-encoding (specified in N

SHA256 sentence: discover a SHA256 checksum that matches a sentence's description of hex digit words.

SHA256 sentence "The SHA256 for this sentence begins with: one, eight, two, a, seven, c and nine." Inspired by @lauriewired post Inspired by @humbleha

Command-Line program that takes images and produces the copy of the image with a thin frame and palette made of the 10 most frequent colors.
Command-Line program that takes images and produces the copy of the image with a thin frame and palette made of the 10 most frequent colors.

paleatra v.0.0.1 Command-Line program that takes an image and produces the copy of the image with a thin frame and palette made of the 10 most frequen

A CLI utility installed as
A CLI utility installed as "ansi" to quickly get ANSI escape sequences. Supports the most basic ones, like colors and styles as bold or italic.

'ansi' - a CLI utility to quickly get ANSI escape codes This Rust project called ansi-escape-sequences-cli provides an executable called ansi which ca

Simple ansi colors

Simple ansi colors

Not the fastest terminal colors library. Don't even ask about size.
Not the fastest terminal colors library. Don't even ask about size.

TROLOLORS Not the fastest terminal colors library. Don't even ask about size. Why? Don't even try to use it. But maybe you need to say to your boss th

Vari (Väri) is a Rust library for formatting strings with colors and cosmetic stuff to the terminal.
Vari (Väri) is a Rust library for formatting strings with colors and cosmetic stuff to the terminal.

Vari Vari (Väri) is a Rust library for formatting strings with colors and cosmetic stuff to the terminal. Like Rich library for Python. Väri means "co

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

Comments
  • Slight changes to README's formatting

    Slight changes to README's formatting

    Check me out.

    • I linked to tui-rs and the Rgb enum in case someone wandering the interwebs has no idea what TUI or RGB means.
    • I also added a shorthand hex color example.

    Note: the span has no effect on the formatting.

    opened by grtcdr 10
  • Bump `tui` dependency to v0.18.0

    Bump `tui` dependency to v0.18.0

    Hey, Uttarayan :)

    I recently tried to bump all of macchina's dependencies and wasn't able to do so because this crate has an older version. This PR, like the title suggests, bumps tui to its latest version.

    opened by grtcdr 3
Owner
Uttarayan Mondal
I write suff
Uttarayan Mondal
Cherry RGB Keyboard Library

Cherry RGB Keyboard Library Tested with Cherry Keyboard G80-3000N RGB (046a:00dd) Features Done Set LED animation Set single-/multi-color (rainbow) Se

null 10 Dec 20, 2022
Simple ansi colors

Simple ansi colors

null 1 Dec 24, 2021
mach-dump can parse Mach-O core dumps taken with lldb from macOS and iOS devices.

mach-dump mach-dump can parse Mach-O core dumps taken with lldb from macOS and iOS devices. It has no external dependencies. Example use std::path::Pa

Tobi 8 Sep 16, 2022
A simple to use rust package to generate or parse Twitter snowflake IDs,generate time sortable 64 bits unique ids for distributed systems

A simple to use rust package to generate or parse Twitter snowflake IDs,generate time sortable 64 bits unique ids for distributed systems (inspired from twitter snowflake)

houseme 5 Oct 6, 2022
A crate providing a tracing-subscriber layer for formatting events so Datadog can parse them

Datadog Formatting Layer A crate providing a tracing-subscriber layer for formatting events so Datadog can parse them. Features Provides a layer for t

Open Schnick 4 Jun 22, 2023
Simple git/hg tui client focused on keyboard shortcuts

verco A simple Git/Hg tui client focused on keyboard shortcuts Screenshots Platforms This project uses Cargo and pure Rust stable and works on latest

Matheus Lessa Rodrigues 214 Dec 26, 2022
A CLI tool to convet Hex color code or RGB to color code, RGB, HSL and color name(if exists)

iro -色- A CLI tool to convert the hex color code or RGB to color code, RGB, HSL, color name(if exists, according to jonathantneal/color-names). Usage

Kyohei Uto 3 Dec 9, 2022
Parse hex colors to tui::style::Color

Color -> Tui Parse hex colors to tui rgb colors #c3f111 -> Color::Rgb(195,241,17) Note that the indexed colors are NOT HEX #142 -> Color::Indexed(142)

Uttarayan Mondal 1 Nov 8, 2021
List of Persian Colors and hex colors for CSS, SCSS, PHP, JS, Python, and Ruby.

Persian Colors (Iranian colors) List of Persian Colors and hex colors for CSS, SCSS, PHP, C++, QML, JS, Python, Ruby and CSharp. Persian colors Name H

Max Base 12 Sep 3, 2022
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