Class: Quadtone::CurveSet

Inherits:
Object
  • Object
show all
Defined in:
lib/quadtone/curve_set.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ CurveSet

Returns a new instance of CurveSet.



10
11
12
13
14
15
16
17
18
# File 'lib/quadtone/curve_set.rb', line 10

def initialize(params={})
  @curves = []
  params.each { |key, value| send("#{key}=", value) }
  raise "Profile must be specified" unless @profile
  raise "Channels must be specified" unless @channels
  raise "Type must be specified" unless @type
  @target = Target.new(name: @type.to_s, channels: @channels, base_dir: @profile.dir_path, type: @type, ink_limits: @profile.ink_limits)
  generate_scale
end

Instance Attribute Details

#channels=(value) ⇒ Object

Sets the attribute channels

Parameters:

  • value

    the value to set the attribute channels to.



6
7
8
# File 'lib/quadtone/curve_set.rb', line 6

def channels=(value)
  @channels = value
end

#curvesObject

Returns the value of attribute curves.



8
9
10
# File 'lib/quadtone/curve_set.rb', line 8

def curves
  @curves
end

#profileObject

Returns the value of attribute profile.



5
6
7
# File 'lib/quadtone/curve_set.rb', line 5

def profile
  @profile
end

#typeObject

Returns the value of attribute type.



7
8
9
# File 'lib/quadtone/curve_set.rb', line 7

def type
  @type
end

Instance Method Details

#build_targetObject



20
21
22
# File 'lib/quadtone/curve_set.rb', line 20

def build_target
  @target.build
end

#chart_targetObject



63
64
65
66
67
68
69
# File 'lib/quadtone/curve_set.rb', line 63

def chart_target
  import_from_target
  out_file = (@profile.dir_path / @type.to_s).with_extname('.html')
  out_file.open('w') { |io| io.write(to_html) }
  ;;warn "Saved chart to #{out_file.to_s.inspect}"
  system('qlmanage', '-p', out_file.to_s)
end

#measure_target(options = {}) ⇒ Object



28
29
30
31
32
# File 'lib/quadtone/curve_set.rb', line 28

def measure_target(options={})
  @target.measure(options)
  process_target
  chart_target
end


24
25
26
# File 'lib/quadtone/curve_set.rb', line 24

def print_target
  @profile.print_file(@target.image_file, calibrate: (@type == :characterization), print: true)
end

#process_targetObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/quadtone/curve_set.rb', line 34

def process_target
  case @type
  when :characterization
    import_from_target
    verify_increasing_values
    set_common_white
    # trim_to_limits
    # @profile.ink_limits = Hash[
    #   @curves.map do |curve|
    #     [
    #       curve.channel,
    #       curve.samples.last.input.value
    #     ]
    #   end
    # ]
    # normalize_curves
    @profile.ink_partitions = partitions
  when :linearization, :test
    import_from_target
    if @type == :linearization
      @profile.linearization = grayscale(21)
    elsif @type == :test
      @profile.grayscale = grayscale(21)
    end
  end
  @profile.save
  @profile.install
end