Skip to content

HsbColor object API

Michael Miller edited this page May 24, 2024 · 5 revisions

HsbColor represents a color object that is represented by Hue, Saturation, Brightness component values. The primary use of this class is for easy definitions of color. The Wikipedia article on this colorspace uses the term "Value" instead of "Brightness".

NOTE: HsbColor has no concept of RGB or W channels. It can be converted to RGB, but when converted to RGBW, RGBWW, and RGBWWW the W channels will always be empty.

Visual representation of HSV color space

Properties

There are three properties that represent the component values Hue, Saturation, and Brightness. The values range from 0.0f to 1.0f.
H is the primary color component and represents a color wheel. Often you will see examples of this being between 0 and 360, but this library it is between 0.0f and 1.0f inclusive.

float H;
float S;
float B;

Constructors

HsbColor(float h, float s, float b) :

Constructs a HsbColor using Hue, Saturation, and Brightness color component values.

  • h - value for Hue component (0.0f - 1.0f).
  • s - value for Saturation component (0.0f - 1.0f).
  • b - value for Brightness (0.0f - 1.0f).

HsbColor(RgbColor color);

Construct a HsbColor using RgbColor, converting the Rgb to Hsb

  • color - a RgbColor object.

HsbColor()

Construct a HsbColor that will have its values set in latter operations.
CAUTION: The H,S,B members are not initialized and may not be consistent until set.

Methods

template <typename T_NEOHUEBLEND> static HsbColor LinearBlend(HsbColor left, HsbColor right, float progress)

This will blend between two colors by the amount defined by the progress variable.
T_NEOHUEBLEND - a NeoHueBlend object, that will define how the colors are blended.

  • left - the color to start the blend at.
  • right - the color to end the blend at.
  • progress - (0.0f - 1.0f) value where 0.0f will return left and 1.0f will return right and a value between will blend the color weighted linearly between them.
    This is a static function, which means you need to call it scoped to the object class and not an instance like...
    HsbColor results = HsbColor::LinearBlend<NeoHueBlendShortestDistance>(HsbColor(0.88f,1.0f,1.0f), HsbColor(0.12f,1.0f,1.0f), 0.33f);
Clone this wiki locally