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.



379
380
381
# File 'lib/hexapdf/content/color_space.rb', line 379

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.



393
394
395
# File 'lib/hexapdf/content/color_space.rb', line 393

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

#default_colorObject

Returns the default color for the DeviceGray color space.



384
385
386
# File 'lib/hexapdf/content/color_space.rb', line 384

def default_color
  Color.new(0.0)
end

#familyObject Also known as: definition

Returns :DeviceGray.



405
406
407
# File 'lib/hexapdf/content/color_space.rb', line 405

def family
  :DeviceGray
end

#prenormalized_color(gray) ⇒ Object

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

See: #color



400
401
402
# File 'lib/hexapdf/content/color_space.rb', line 400

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