Class: HexaPDF::Content::ColorSpace::DeviceRGB::Color
- Inherits:
-
Object
- Object
- HexaPDF::Content::ColorSpace::DeviceRGB::Color
- Includes:
- ColorUtils
- Defined in:
- lib/hexapdf/content/color_space.rb
Overview
A color in the DeviceRGB color space.
Color values can either be integers in the range from 0 to 255 or floating point numbers between 0.0 and 1.0. The integer color values are automatically normalized to the DeviceRGB color value range of 0.0 to 1.0.
See: PDF1.7 s8.6.4.3
Instance Method Summary collapse
-
#color_space ⇒ Object
Returns the DeviceRGB color space module.
-
#components ⇒ Object
Returns the RGB color as an array of normalized color values.
-
#initialize(r, g, b) ⇒ Color
constructor
Initializes the color with the
r
(red),g
(green) andb
(blue) components.
Methods included from ColorUtils
Constructor Details
#initialize(r, g, b) ⇒ Color
Initializes the color with the r
(red), g
(green) and b
(blue) components.
Each argument has to be either an integer between 0 and 255 or a float between 0.0 and 1.0.
217 218 219 220 221 |
# File 'lib/hexapdf/content/color_space.rb', line 217 def initialize(r, g, b) @r = normalize_value(r, 255) @g = normalize_value(g, 255) @b = normalize_value(b, 255) end |
Instance Method Details
#color_space ⇒ Object
Returns the DeviceRGB color space module.
224 225 226 |
# File 'lib/hexapdf/content/color_space.rb', line 224 def color_space DeviceRGB::DEFAULT end |
#components ⇒ Object
Returns the RGB color as an array of normalized color values.
229 230 231 |
# File 'lib/hexapdf/content/color_space.rb', line 229 def components [@r, @g, @b] end |