Open Inventor Release 2024.1.1
 
Loading...
Searching...
No Matches
SbColor Class Reference

Color vector class. More...

#include <Inventor/SbColor.h>

+ Inheritance diagram for SbColor:

Public Member Functions

 SbColor ()
 Default constructor.
 
 SbColor (const SbVec3f vec3f)
 Constructor that takes a vector value.
 
 SbColor (const float rgb[3])
 Constructor that takes an array of 3 floats.
 
 SbColor (float r, float g, float b)
 Constructor that takes 3 floats.
 
SbColorsetHSVValue (float h, float s, float v)
 Sets value of color vector from 3 HSV (Hue, Saturation, and Value) components.
 
SbColorsetHSVValue (const float hsv[3])
 Sets value of color vector from array of 3 HSV components.
 
void getHSVValue (float &h, float &s, float &v) const
 Returns 3 individual HSV components.
 
void getHSVValue (float hsv[3]) const
 Returns an array of 3 HSV components.
 
void setRGBValue (unsigned char r, unsigned char g, unsigned char b)
 Set RGB values as unsigned char.
 
SbColorsetPackedValue (uint32_t orderedRGBA, float &transparency)
 Sets value of color vector from an RGBA packed color value.
 
uint32_t getPackedValue (float transparency=0.0) const
 Returns an RGBA packed color value, derived from the color vector and the passed transparency value.
 
uint32_t getPackedValueEndiannessOrder (float transparency=0.0) const
 Returns an RGBA packed color value, derived from the color vector and the passed transparency value.
 
Deprecated
SoDEPRECATED uint32_t getPackedValueInternal (float transparency=0.0) const
 
- Public Member Functions inherited from SbVec3f
 SbVec3f ()
 Default constructor.
 
 SbVec3f (const float v[3])
 Constructor given vector components.
 
 SbVec3f (float x, float y, float z)
 Constructor given vector components.
 
 SbVec3f (SbPlane &p0, SbPlane &p1, SbPlane &p2)
 Constructor given 3 planes.
 
SbVec3f cross (const SbVec3f &v) const
 Returns right-handed cross product of vector and another vector.
 
float dot (const SbVec3f &v) const
 Returns dot (inner) product of vector and another vector.
 
const float * getValue () const
 Returns vector components.
 
void getValue (float &x, float &y, float &z) const
 Returns vector components.
 
float length () const
 Returns geometric length of vector.
 
float lengthSquared () const
 Returns square length of vector.
 
float normalize ()
 Changes vector to be unit length, returning the length before normalization.
 
void negate ()
 Negates each component of vector in place.
 
SbVec3fsetValue (const float v[3])
 Sets the vector components.
 
SbVec3fsetValue (float x, float y, float z)
 Sets the vector components.
 
SbVec3fsetValue (const SbVec3f &barycentic, const SbVec3f &v0, const SbVec3f &v1, const SbVec3f &v2)
 Sets value of vector as the weighted average of 3 other vectors.
 
SbVec3fsetValue (const SbVec3d &vec3d)
 Sets value of vector from a double precision vector.
 
float & operator[] (int i)
 Accesses indexed component of vector.
 
const float & operator[] (int i) const
 
SbVec3foperator*= (float d)
 Component-wise scalar multiplication operator.
 
SbVec3foperator/= (float d)
 Component-wise scalar division operator.
 
SbVec3foperator+= (const SbVec3f &v)
 Component-wise vector addition operator.
 
SbVec3foperator-= (const SbVec3f &v)
 Component-wise vector subtraction operator.
 
SbVec3f operator- () const
 Nondestructive unary negation - returns a new vector.
 
SbVec3f operator* (const SbVec3f &v) const
 Component-wise vector multiplication operator.
 
SbVec3foperator*= (const SbVec3f &v)
 Component-wise vector multiplication operator.
 
SbBool equals (const SbVec3f &v, float tolerance) const
 Equality comparison within given tolerance - the square of the length of the maximum distance between the two vectors.
 
SbVec3f getClosestAxis () const
 Returns principal axis that is closest (based on maximum dot product) to this vector.
 
template<typename T >
 SbVec3f (const T &v)
 Constructor that converts an arbitrary SbVec3 to an SbVec3f.
 

Detailed Description

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

Definition at line 82 of file SbColor.h.

Constructor & Destructor Documentation

◆ SbColor() [1/4]

SbColor::SbColor ( )

Default constructor.

The color value is not initialized.

◆ SbColor() [2/4]

SbColor::SbColor ( const SbVec3f  vec3f)
inline

Constructor that takes a vector value.

Definition at line 92 of file SbColor.h.

◆ SbColor() [3/4]

SbColor::SbColor ( const float  rgb[3])
inline

Constructor that takes an array of 3 floats.

Definition at line 98 of file SbColor.h.

◆ SbColor() [4/4]

SbColor::SbColor ( float  r,
float  g,
float  b 
)
inline

Constructor that takes 3 floats.

Definition at line 104 of file SbColor.h.

Member Function Documentation

◆ getHSVValue() [1/2]

void SbColor::getHSVValue ( float &  h,
float &  s,
float &  v 
) const

Returns 3 individual HSV components.

◆ getHSVValue() [2/2]

void SbColor::getHSVValue ( float  hsv[3]) const
inline

Returns an array of 3 HSV components.

Definition at line 132 of file SbColor.h.

◆ getPackedValue()

uint32_t SbColor::getPackedValue ( float  transparency = 0.0) const

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.

◆ getPackedValueEndiannessOrder()

uint32_t SbColor::getPackedValueEndiannessOrder ( float  transparency = 0.0) const

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.

◆ getPackedValueInternal()

SoDEPRECATED uint32_t SbColor::getPackedValueInternal ( float  transparency = 0.0) const
inline

Definition at line 194 of file SbColor.h.

◆ setHSVValue() [1/2]

SbColor & SbColor::setHSVValue ( const float  hsv[3])
inline

Sets value of color vector from array of 3 HSV components.

Definition at line 121 of file SbColor.h.

◆ setHSVValue() [2/2]

SbColor & 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.

◆ setPackedValue()

SbColor & SbColor::setPackedValue ( uint32_t  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.

◆ setRGBValue()

void SbColor::setRGBValue ( unsigned char  r,
unsigned char  g,
unsigned char  b 
)
inline

Set RGB values as unsigned char.

RGB values range from 0 to 0xFF (255)

Definition at line 149 of file SbColor.h.


The documentation for this class was generated from the following file: