Giter Site home page Giter Site logo

hex_color's People

Contributors

max-ishere avatar seancroach avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

m-kuzmin aaaton

hex_color's Issues

HexColor::lighten(f32), darken(f32), brightness(f32)

Similar to the CSS rules for lighten, darken, brightness.

Because this is too annoying:

        // Lighten 20%
        const LIGHTEN_AMT: f32 = 1.2;
        let (r, g, b, _a) = HexColor::from_u24(0x66bbff).split();
        let (r, g, b) = (
            (r as f32 * LIGHTEN_AMT).max(u8::MAX as f32) as u8,
            (g as f32 * LIGHTEN_AMT).max(u8::MAX as f32) as u8,
            (b as f32 * LIGHTEN_AMT).max(u8::MAX as f32) as u8,
        );
        HexColor::from_u24(
            (0xff & r as u32) << 16
                | (0xff & g as u32) << 8
                | (0xff & b as u32),
        )

Printing defaults

Hey! I thought this was abandoned. Thanks for getting around to it all!

Currently println!("{}", my_color) will print #RRGGBB
Currently println!("{:?}", my_color) will print #RRGGBBAA

I'm not satisfied with how this works. For one, {:?} is supposed to be a debug print. This is standard across Rust. If you rely on the current behavior, it would confuse a code reviewer what's actually going on here.

I was going to suggest next to set the default Display to print the full color: #RRGGBBAA
And use #[derive(Debug)] to handle the debug print, as one would expect.

To maintain functionality, we could add sugary functions for more readability/context:
color.rgb_str() and color.rgba_str()

[Feature Request] Color Inversion

Feature Request

  • I would like to work on this feature!

Lovely library! I just made a function that naively inverts colors and I'd like to add it as a method to the main struct

const fn invert_color(color: HexColor) -> HexColor {
    let r = 0xFF - color.r;
    let g = 0xFF - color.g;
    let b = 0xFF - color.b;
    HexColor::new(r, g, b)
}

Maybe later I can implement a gamma corrected invert function.

Do you think this is a good idea? If not, I don't mind if you close this.

[Feature Request] Alpha support

Hi, thanks to the library! It helps get things done easily.

Currently alpha channel is not supported yet, is there any plan to work on it?

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.