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.



484
485
486
# File 'lib/hexapdf/content/color_space.rb', line 484

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.



498
499
500
501
502
# File 'lib/hexapdf/content/color_space.rb', line 498

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.



489
490
491
# File 'lib/hexapdf/content/color_space.rb', line 489

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

#familyObject Also known as: definition

Returns :DeviceRGB.



513
514
515
# File 'lib/hexapdf/content/color_space.rb', line 513

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



508
509
510
# File 'lib/hexapdf/content/color_space.rb', line 508

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