IT. Expert System.

Android Reference

Color


android.graphics

Class Color



  • public class Color
    extends Object
    The Color class defines methods for creating and converting color ints. Colors are represented as packed ints, made up of 4 bytes: alpha, red, green, blue. The values are unpremultiplied, meaning any transparency is stored solely in the alpha component, and not in the color components. The components are stored as follows (alpha << 24) | (red << 16) | (green << 8) | blue. each component ranges between 0..255 with 0 meaning no contribution for that component, and 255 meaning 100% contribution. thus opaque-black would be 0xff000000 (100% opaque but no contributions from red, green, or blue), and opaque-white would be 0xffffffff
    • Constructor Summary

      Constructors
      Constructor and Description
      Color()
    • Method Summary

      Methods
      Modifier and Type Method and Description
      static int alpha(int color)
      Return the alpha component of a color int.
      static int argb(int alpha, int red, int green, int blue)
      Return a color-int from alpha, red, green, blue components.
      static int blue(int color)
      Return the blue component of a color int.
      static float brightness(int color)
      Returns the brightness component of a color int.
      static void colorToHSV(int color, float[] hsv)
      Convert the argb color to its HSV components.
      static int green(int color)
      Return the green component of a color int.
      static int HSBtoColor(float[] hsb)
      Convert HSB components to an ARGB color.
      static int HSBtoColor(float h, float s, float b)
      Convert HSB components to an ARGB color.
      static int HSVToColor(float[] hsv)
      Convert HSV components to an ARGB color.
      static int HSVToColor(int alpha, float[] hsv)
      Convert HSV components to an ARGB color.
      static float hue(int color)
      Returns the hue component of a color int.
      static int parseColor(String colorString)
      Parse the color string, and return the corresponding color-int.
      static int red(int color)
      Return the red component of a color int.
      static int rgb(int red, int green, int blue)
      Return a color-int from red, green, blue components.
      static void RGBToHSV(int red, int green, int blue, float[] hsv)
      Convert RGB components to HSV.
      static float saturation(int color)
      Returns the saturation component of a color int.
    • Constructor Detail

      • Color

        public Color()
    • Method Detail

      • alpha

        public static int alpha(int color)
        Return the alpha component of a color int. This is the same as saying color >>> 24
      • red

        public static int red(int color)
        Return the red component of a color int. This is the same as saying (color >> 16) & 0xFF
      • green

        public static int green(int color)
        Return the green component of a color int. This is the same as saying (color >> 8) & 0xFF
      • blue

        public static int blue(int color)
        Return the blue component of a color int. This is the same as saying color & 0xFF
      • rgb

        public static int rgb(int red,
              int green,
              int blue)
        Return a color-int from red, green, blue components. The alpha component is implicity 255 (fully opaque). These component values should be [0..255], but there is no range check performed, so if they are out of range, the returned color is undefined.
        Parameters:
        red - Red component [0..255] of the color
        green - Green component [0..255] of the color
        blue - Blue component [0..255] of the color
      • argb

        public static int argb(int alpha,
               int red,
               int green,
               int blue)
        Return a color-int from alpha, red, green, blue components. These component values should be [0..255], but there is no range check performed, so if they are out of range, the returned color is undefined.
        Parameters:
        alpha - Alpha component [0..255] of the color
        red - Red component [0..255] of the color
        green - Green component [0..255] of the color
        blue - Blue component [0..255] of the color
      • hue

        public static float hue(int color)
        Returns the hue component of a color int.
        Returns:
        A value between 0.0f and 1.0f
      • saturation

        public static float saturation(int color)
        Returns the saturation component of a color int.
        Returns:
        A value between 0.0f and 1.0f
      • brightness

        public static float brightness(int color)
        Returns the brightness component of a color int.
        Returns:
        A value between 0.0f and 1.0f
      • parseColor

        public static int parseColor(String colorString)
        Parse the color string, and return the corresponding color-int. If the string cannot be parsed, throws an IllegalArgumentException exception. Supported formats are: #RRGGBB #AARRGGBB 'red', 'blue', 'green', 'black', 'white', 'gray', 'cyan', 'magenta', 'yellow', 'lightgray', 'darkgray'
      • HSBtoColor

        public static int HSBtoColor(float[] hsb)
        Convert HSB components to an ARGB color. Alpha set to 0xFF. hsv[0] is Hue [0 .. 1) hsv[1] is Saturation [0...1] hsv[2] is Value [0...1] If hsv values are out of range, they are pinned.
        Parameters:
        hsb - 3 element array which holds the input HSB components.
        Returns:
        the resulting argb color
      • HSBtoColor

        public static int HSBtoColor(float h,
                     float s,
                     float b)
        Convert HSB components to an ARGB color. Alpha set to 0xFF. hsv[0] is Hue [0 .. 1) hsv[1] is Saturation [0...1] hsv[2] is Value [0...1] If hsv values are out of range, they are pinned.
        Parameters:
        h - Hue component
        s - Saturation component
        b - Brightness component
        Returns:
        the resulting argb color
      • RGBToHSV

        public static void RGBToHSV(int red,
                    int green,
                    int blue,
                    float[] hsv)
        Convert RGB components to HSV. hsv[0] is Hue [0 .. 360) hsv[1] is Saturation [0...1] hsv[2] is Value [0...1]
        Parameters:
        red - red component value [0..255]
        green - green component value [0..255]
        blue - blue component value [0..255]
        hsv - 3 element array which holds the resulting HSV components.
      • colorToHSV

        public static void colorToHSV(int color,
                      float[] hsv)
        Convert the argb color to its HSV components. hsv[0] is Hue [0 .. 360) hsv[1] is Saturation [0...1] hsv[2] is Value [0...1]
        Parameters:
        color - the argb color to convert. The alpha component is ignored.
        hsv - 3 element array which holds the resulting HSV components.
      • HSVToColor

        public static int HSVToColor(float[] hsv)
        Convert HSV components to an ARGB color. Alpha set to 0xFF. hsv[0] is Hue [0 .. 360) hsv[1] is Saturation [0...1] hsv[2] is Value [0...1] If hsv values are out of range, they are pinned.
        Parameters:
        hsv - 3 element array which holds the input HSV components.
        Returns:
        the resulting argb color
      • HSVToColor

        public static int HSVToColor(int alpha,
                     float[] hsv)
        Convert HSV components to an ARGB color. The alpha component is passed through unchanged. hsv[0] is Hue [0 .. 360) hsv[1] is Saturation [0...1] hsv[2] is Value [0...1] If hsv values are out of range, they are pinned.
        Parameters:
        alpha - the alpha component of the returned argb color.
        hsv - 3 element array which holds the input HSV components.
        Returns:
        the resulting argb color


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 674 / . Delta: 0.02343 с