Skip to content
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 Ability to initialise a LFXHSBColor instance with RGB Integers and Standard Android Color class. #8

Open
PercyBoyes opened this issue May 13, 2014 · 1 comment

Comments

@PercyBoyes
Copy link
Contributor

Explained in the title

@janheinrichmerker
Copy link

Could be easily done by adding the following lines to the LFXHSBColor class:

public static LFXHSBColor fromColor(@ColorInt int color, @IntRange(from = 0, to = 10000) int kelvin) {
    float[] hsb = new float[3];
    Color.colorToHSV(color, hsb);
    return getColor(hsb[0], hsb[1], hsb[2], kelvin);
}

public static LFXHSBColor fromRGB(@IntRange(from = 0, to = 255) int red,
        @IntRange(from = 0, to = 255) int green,
        @IntRange(from = 0, to = 255) int blue,
        @IntRange(from = 0, to = 10000) int kelvin) {
    int color = Color.rgb(red, green, blue);
    return fromColor(color, kelvin);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants