-
-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Hex and a Random Variant to Colors Enum #168
Comments
Hey @nazmulidris. Can you assign this issue to me. By the way, should I be using |
@LuciAkirami Great question about rand crate. We have a ColorWheel implementation in the r3bl_tui crate (in the tui folder of the repo). Maybe take a look there to see if you can find how ColorWheel does it. If this is not enough information to go on, PLMK and I will dig deeper into this later & give you more info 👍🏽 |
Hi @nazmulidris Working on this after a really long time, sorry for that (busy with office work dangg). So, I'm thinking of doing something like the below
As for the conversion, below is the code
Yet to add checking if the given hex is valid or not. I just want to get a confirmation that I'm going in a right direction |
@LuciAkirami This is the right direction. Thanks for sharing the code. It looks good. Looking forward to the PR. Also if you feel like the PR isn't ready and you want us to take a look at it, just mark it as draft and share it for review. We will understand that since it's marked as draft that the code is in very early stages of development 👍🏽 Also I put your code in Rust playground and it is pretty cool. I didn't know that fn main() {
let hex_string = "abc".to_string();
let hex_string_ref = &hex_string;
let it = HexColor { hex: hex_string_ref };
takes_hex(it);
std::mem::drop(it);
println!("{:?}", it);
}
fn takes_hex(arg: HexColor) {
// Drops arg!
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct HexColor<'a>{
pub hex: &'a str,
} |
Currently the Color Enum contains two variants, RBG and ANSI256. Apart from these, the following two variants can be added
AnsiStyledText { text: "Print a bold text w/ random color", style: &[ Style::Bold, Style::Foreground(Color::Random), ], }.println();
should print a bold text with a random color.The text was updated successfully, but these errors were encountered: