Class: OpenHAB::Core::Types::HSBType
- Inherits:
-
PercentType
- Object
- DecimalType
- PercentType
- OpenHAB::Core::Types::HSBType
- Defined in:
- lib/openhab/core/types/hsb_type.rb
Overview
HSBType is a complex type with constituents for hue, saturation and brightness and can be used for color items.
Constant Summary collapse
- BLACK =
- WHITE =
- RED =
- GREEN =
- BLUE =
Instance Attribute Summary collapse
- #blue ⇒ PercentType readonly
- #brightness ⇒ PercentType readonly
- #green ⇒ PercentType readonly
-
#hue ⇒ QuantityType
readonly
The color's hue component as a QuantityType of unit DEGREE_ANGLE.
- #red ⇒ PercentType readonly
- #saturation ⇒ PercentType readonly
Class Method Summary collapse
-
.from_hsb(hue, saturation, brightness) ⇒ HSBType
Create HSBType from hue, saturation, and brightness values.
-
.from_rgb(r, g, b) ⇒ HSBType
Create HSBType from RGB values.
-
.from_xy(x, y) ⇒ HSBType
Create HSBType representing the provided xy color values in CIE XY color model.
Instance Method Summary collapse
-
#<=>(other) ⇒ Integer?
Comparison.
-
#argb ⇒ Integer
Convert to a packed 32-bit RGB value representing the color in the default sRGB color model.
-
#rgb ⇒ Integer
Convert to a packed 24-bit RGB value representing the color in the default sRGB color model.
-
#to_hex ⇒ String
Convert to an HTML-style string of 6 hex characters in the default sRGB color model.
-
#to_rgb ⇒ [PercentType, PercentType, PercentType]
Convert to RGB values representing the color in the default sRGB color model.
-
#to_xy ⇒ [PercentType, PercentType, PercentType]
Convert to the xyY values representing this object's color in CIE XY color model.
Methods inherited from PercentType
#down?, #off?, #on?, #scale, #to_byte, #up?
Methods inherited from DecimalType
#-@, #coerce, #initialize, #|
Methods included from NumericType
#+@, #eql?, #to_d, #to_f, #to_i
Constructor Details
This class inherits a constructor from OpenHAB::Core::Types::DecimalType
Instance Attribute Details
#hue ⇒ QuantityType (readonly)
Returns The color's hue component as a QuantityType of unit DEGREE_ANGLE.
127 128 129 |
# File 'lib/openhab/core/types/hsb_type.rb', line 127 def hue QuantityType.new(raw_hue.to_big_decimal, Units::DEGREE_ANGLE) end |
Class Method Details
.from_hsb(hue, saturation, brightness) ⇒ HSBType
Create HSBType from hue, saturation, and brightness values
54 55 56 |
# File 'lib/openhab/core/types/hsb_type.rb', line 54 def from_hsb(hue, saturation, brightness) new(hue, saturation, brightness) end |
.from_rgb(r, g, b) ⇒ HSBType
Create HSBType from RGB values
|
# File 'lib/openhab/core/types/hsb_type.rb', line 36
|
.from_xy(x, y) ⇒ HSBType
Create HSBType representing the provided xy color values in CIE XY color model
|
# File 'lib/openhab/core/types/hsb_type.rb', line 43
|
Instance Method Details
#<=>(other) ⇒ Integer?
Comparison
112 113 114 115 116 117 118 119 |
# File 'lib/openhab/core/types/hsb_type.rb', line 112 def <=>(other) logger.trace("(#{self.class}) #{self} <=> #{other} (#{other.class})") if other.is_a?(HSBType) [brightness, hue, saturation] <=> [other.brightness, other.hue, other.saturation] else super end end |
#argb ⇒ Integer
Convert to a packed 32-bit RGB value representing the color in the default sRGB color model.
The alpha component is always 100%.
136 |
# File 'lib/openhab/core/types/hsb_type.rb', line 136 alias_method :argb, :rgb |
#rgb ⇒ Integer
Convert to a packed 24-bit RGB value representing the color in the default sRGB color model.
140 141 142 |
# File 'lib/openhab/core/types/hsb_type.rb', line 140 def rgb argb & 0xffffff end |
#to_hex ⇒ String
Convert to an HTML-style string of 6 hex characters in the default sRGB color model.
146 147 148 |
# File 'lib/openhab/core/types/hsb_type.rb', line 146 def to_hex Kernel.format("#%06x", rgb) end |
#to_rgb ⇒ [PercentType, PercentType, PercentType]
Convert to RGB values representing the color in the default sRGB color model
|
# File 'lib/openhab/core/types/hsb_type.rb', line 171
|
#to_xy ⇒ [PercentType, PercentType, PercentType]
Convert to the xyY values representing this object's color in CIE XY color model
|
# File 'lib/openhab/core/types/hsb_type.rb', line 175
|