Class SbColor


  • public class SbColor
    extends SbVec3f
    Color vector class. This class is used to represent an RGB color. Each component of the vector is a floating-point number between 0.0 and 1.0. There are routines to convert back and forth between RGB and HSV.

    See Also:
    SbColorRGBA, SbVec3f
    • Constructor Detail

      • SbColor

        public SbColor​(java.awt.Color c)
      • SbColor

        public SbColor​(SbColor copyFrom)
      • SbColor

        public SbColor​(float[] components)
      • SbColor

        public SbColor​(SbVec3f vec3f)
        Constructor that takes a vector value.
      • SbColor

        public SbColor()
        Default constructor. The color value is not initialized.
      • SbColor

        public SbColor​(float r,
                       float g,
                       float b)
        Constructor that takes 3 floats.
    • Method Detail

      • setPackedValue

        public SbColor setPackedValue​(long rgba,
                                      float[] transparency)
        RGBA Packed integer color routines.
        Parameters:
        rgba - The color format expressed in hexadecinal is 0xrrggbbaa, where aa is the alpha value, bb is the blue value, gg is the green value and rr is the red value.
        transparency - is an array which first component will contain the transparency value, after return. You just need to pass a one element float array.
      • toAWTColor

        public java.awt.Color toAWTColor()
      • getPackedValue

        public int getPackedValue()
        Calls getPackedValue((float)0.0).
      • getPackedValueInternal

        @Deprecated(since="9.5.0.0")
        public int getPackedValueInternal()
        Deprecated.
        Calls getPackedValueInternal((float)0.0).
      • getPackedValueEndiannessOrder

        public int getPackedValueEndiannessOrder()
        Calls getPackedValueEndiannessOrder((float)0.0).
      • setValue

        public SbColor setValue​(float[] components,
                                int startIndex)
        Overrides:
        setValue in class SbVec3f
      • setValue

        public void setValue​(SbColor copyFrom)
      • getValue

        public float[] getValue()
        Overrides:
        getValue in class SbVec3f
      • getHSVValue

        public float[] getHSVValue()
        Returns an array of 3 HSV components.
      • toArray

        public static SbColor[] toArray​(long nativeArray,
                                        long length)
      • getPackedValue

        public int getPackedValue​(float transparency)
        Returns an RGBA packed color value, derived from the color vector and the passed transparency value. The alpha component is set to (1.0 - transparency) * 255, resulting in a hex value between 0 and 0xFF. If transparency not specified, alpha is set to 0xFF (opaque). The color format expressed in hexadecimal is 0xrrggbbaa.
      • setRGBValue

        public void setRGBValue​(byte r,
                                byte g,
                                byte b)
        Set RGB values as unsigned char. RGB values range from 0 to 0xFF (255)
      • setPackedValue

        public SbColor setPackedValue​(int orderedRGBA,
                                      float transparency)
        Sets value of color vector from an RGBA packed color value. The packed color format expressed in hexadecimal is 0xrrggbbaa, where

        • rr is the red value
        • gg is the green value
        • bb is the blue value
        • aa is the alpha value

        RGBA component values range from 0 to 0xFF (255). The returned transparency value is a floating point value between 0.0 (opaque) and 1.0 (completely transparent). It is derived from the alpha component of the RGBA color.

      • setHSVValue

        public SbColor setHSVValue​(float[] hsv)
        Sets value of color vector from array of 3 HSV components.
      • getPackedValueInternal

        @Deprecated(since="9.5.0.0")
        public int getPackedValueInternal​(float transparency)
        Deprecated.
        As of Open Inventor 9.5.0.0. Use getPackedValueendiannessOrder(float transparency = 0.0) const instead.

        Warning Deprecated since Open Inventor 9500. Use getPackedValueendiannessOrder(float transparency = 0.0) const instead.

      • getPackedValueEndiannessOrder

        public int getPackedValueEndiannessOrder​(float transparency)
        Returns an RGBA packed color value, derived from the color vector and the passed transparency value. The alpha component is set to (1.0 - transparency) * 255, resulting in a hex value between 0 and 0xFF. If transparency not specified, alpha is set to 0xFF (opaque).

        This method takes "endianness" in account and will return a value according to the processor architecture. For example, on "little-endian" processors like Intel, the color value returned is actually 0xaabbggrr. See the note in SoVolumeData about constructing RGBA voxel values programmatically.

      • setHSVValue

        public SbColor setHSVValue​(float h,
                                   float s,
                                   float v)
        Sets value of color vector from 3 HSV (Hue, Saturation, and Value) components. Value is the same as brightness of the color.