Class: Abachrome::Gamut::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/abachrome/gamut/base.rb

Direct Known Subclasses

P3, Rec2020, SRGB

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, primaries, white_point) ⇒ Base

Returns a new instance of Base.



22
23
24
25
26
# File 'lib/abachrome/gamut/base.rb', line 22

def initialize(name, primaries, white_point)
  @name = name
  @primaries = primaries
  @white_point = white_point
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



20
21
22
# File 'lib/abachrome/gamut/base.rb', line 20

def name
  @name
end

#primariesObject (readonly)

Returns the value of attribute primaries.



20
21
22
# File 'lib/abachrome/gamut/base.rb', line 20

def primaries
  @primaries
end

#white_pointObject (readonly)

Returns the value of attribute white_point.



20
21
22
# File 'lib/abachrome/gamut/base.rb', line 20

def white_point
  @white_point
end

Instance Method Details

#contains?(coordinates) ⇒ Boolean

TODO: - make this work properly

Returns:

  • (Boolean)


29
30
31
32
33
34
# File 'lib/abachrome/gamut/base.rb', line 29

def contains?(coordinates)
  x, y, z = coordinates
  x >= 0 && x <= 1 &&
    y >= 0 && y <= 1 &&
    z >= 0 && z <= 1
end

#map(coordinates, method: :clip) ⇒ Object



36
37
38
39
40
41
42
43
44
45
# File 'lib/abachrome/gamut/base.rb', line 36

def map(coordinates, method: :clip)
  case method
  when :clip
    clip(coordinates)
  when :scale
    scale(coordinates)
  else
    raise ArgumentError, "Unknown mapping method: #{method}"
  end
end