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.



545
546
547
# File 'lib/hexapdf/content/color_space.rb', line 545

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.



559
560
561
# File 'lib/hexapdf/content/color_space.rb', line 559

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

#default_colorObject

Returns the default color for the DeviceGray color space.



550
551
552
# File 'lib/hexapdf/content/color_space.rb', line 550

def default_color
  Color.new(0.0)
end

#familyObject Also known as: definition

Returns :DeviceGray.



571
572
573
# File 'lib/hexapdf/content/color_space.rb', line 571

def family
  :DeviceGray
end

#prenormalized_color(gray) ⇒ Object

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

See: #color



566
567
568
# File 'lib/hexapdf/content/color_space.rb', line 566

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