Giter Site home page Giter Site logo

Comments (4)

kj800x avatar kj800x commented on August 20, 2024

Have you looked at the Android Color documentation? The color ints that HoloColorPicker creates is compliant with that class, and you can use that class to break a color into ARGB, HSVA or HSBA.

from holocolorpicker.

power7714 avatar power7714 commented on August 20, 2024

ok. will do. Quick question though, does HoloColorPicker create the int in a hex format that is compatible with web/css color codes?

from holocolorpicker.

theBlbDan avatar theBlbDan commented on August 20, 2024

Documentations says:

int com.larswerkman.holocolorpicker.ColorPicker.getColor()
Get the currently selected color.
Returns:
The ARGB value of the currently selected color.

"int in a hex format" does not compute. An int is an int. If you aren't familiar with ARGB or HSLA, you have some homework to do.

But, to be courteous, no. You need to use the Android Color class to help you get there.

    int color = picker.getColor();
    long highlight_id = 0;
    String alpha = String.format("%02x", Color.alpha(color)),
                red = String.format("%02x", Color.red(color)),
                green = String.format("%02x", Color.green(color)),
                blue = String.format("%02x", Color.blue(color));

Now you have four strings that look like four hex values that resemble the ARGB. You seem to be stuck in the mindset that CSS colors are always #AARRGGBB. https://developer.mozilla.org/en-US/docs/Web/CSS/color_value.

enjoy

from holocolorpicker.

devgutt avatar devgutt commented on August 20, 2024

I'm using this function
String.format("#%06X", 0x00FFFFFF & color);

from holocolorpicker.

Related Issues (20)

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.