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.



580
581
582
# File 'lib/hexapdf/content/color_space.rb', line 580

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.



594
595
596
# File 'lib/hexapdf/content/color_space.rb', line 594

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

#default_colorObject

Returns the default color for the DeviceGray color space.



585
586
587
# File 'lib/hexapdf/content/color_space.rb', line 585

def default_color
  Color.new(0.0)
end

#familyObject Also known as: definition

Returns :DeviceGray.



606
607
608
# File 'lib/hexapdf/content/color_space.rb', line 606

def family
  :DeviceGray
end

#prenormalized_color(gray) ⇒ Object

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

See: #color



601
602
603
# File 'lib/hexapdf/content/color_space.rb', line 601

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