Class: HexaPDF::Content::ColorSpace::DeviceGray

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

Overview

The DeviceGray color space.

Defined Under Namespace

Classes: Color

Constant Summary collapse

DEFAULT =

The one (and only) DeviceGray color space.

new

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new(_definition = nil) ⇒ Object

Returns the DeviceGray color space object.



627
628
629
# File 'lib/hexapdf/content/color_space.rb', line 627

def self.new(_definition = nil)
  DEFAULT
end

Instance Method Details

#color(gray) ⇒ Object

Returns the color object for the given gray component.

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 DeviceGray color value range of 0.0 to 1.0.



641
642
643
# File 'lib/hexapdf/content/color_space.rb', line 641

def color(gray)
  Color.new(ColorUtils.normalize_value(gray, 255))
end

#default_colorObject

Returns the default color for the DeviceGray color space.



632
633
634
# File 'lib/hexapdf/content/color_space.rb', line 632

def default_color
  Color.new(0.0)
end

#familyObject Also known as: definition

Returns :DeviceGray.



653
654
655
# File 'lib/hexapdf/content/color_space.rb', line 653

def family
  :DeviceGray
end

#prenormalized_color(gray) ⇒ Object

Returns the color object for the gray component without applying value normalization.

See: #color



648
649
650
# File 'lib/hexapdf/content/color_space.rb', line 648

def prenormalized_color(gray)
  Color.new(gray)
end