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.



402
403
404
# File 'lib/hexapdf/content/color_space.rb', line 402

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.



416
417
418
419
420
# File 'lib/hexapdf/content/color_space.rb', line 416

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.



407
408
409
# File 'lib/hexapdf/content/color_space.rb', line 407

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

#familyObject Also known as: definition

Returns :DeviceRGB.



431
432
433
# File 'lib/hexapdf/content/color_space.rb', line 431

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



426
427
428
# File 'lib/hexapdf/content/color_space.rb', line 426

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