Class: HexaPDF::Content::ColorSpace::DeviceRGB

Inherits:
Object
  • Object
show all
Defined in:
lib/hexapdf/content/color_space.rb

Overview

The DeviceRGB color space.

Defined Under Namespace

Classes: Color

Constant Summary collapse

DEFAULT =

The one (and only) DeviceRGB color space.

new

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new(_definition = nil) ⇒ Object

Returns the DeviceRGB color space object.



437
438
439
# File 'lib/hexapdf/content/color_space.rb', line 437

def self.new(_definition = nil)
  DEFAULT
end

Instance Method Details

#color(r, g, b) ⇒ Object

Returns the color object for the red, green and blue components.

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.



451
452
453
454
455
# File 'lib/hexapdf/content/color_space.rb', line 451

def color(r, g, b)
  Color.new(ColorUtils.normalize_value(r, 255),
            ColorUtils.normalize_value(g, 255),
            ColorUtils.normalize_value(b, 255))
end

#default_colorObject

Returns the default color for the DeviceRGB color space.



442
443
444
# File 'lib/hexapdf/content/color_space.rb', line 442

def default_color
  Color.new(0.0, 0.0, 0.0)
end

#familyObject Also known as: definition

Returns :DeviceRGB.



466
467
468
# File 'lib/hexapdf/content/color_space.rb', line 466

def family
  :DeviceRGB
end

#prenormalized_color(r, g, b) ⇒ Object

Returns the color object for the red, green and blue components without applying value normalization.

See: #color



461
462
463
# File 'lib/hexapdf/content/color_space.rb', line 461

def prenormalized_color(r, g, b)
  Color.new(r, g, b)
end