Class: PhotoUtils::Tools::DOFTable

Inherits:
PhotoUtils::Tool show all
Defined in:
lib/photo_utils/tools/dof_table.rb

Instance Method Summary collapse

Methods inherited from PhotoUtils::Tool

#description, #initialize, #name, #usage

Constructor Details

This class inherits a constructor from PhotoUtils::Tool

Instance Method Details

#runObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/photo_utils/tools/dof_table.rb', line 9

def run
  scene = Scene.new
  scene.camera = Camera[/Eastman/]

  puts
  scene.print_camera
  puts

  # Av equivalents of f/4 ~ f/64
  apertures = (4..12).map { |av| Aperture.new_from_v(av) }

  first = true

  1.upto(30) do |s|
    scene.subject_distance = s.feet
    if first
      first = false
      puts (['', ''] + apertures.map { |a| "Av #{a.to_v.to_i}" }).join("\t")
      puts (['', ''] + apertures.map { |a| a.to_s(:us) }).join("\t")
      puts (['Distance', 'Field of view'] + apertures).join("\t")
    end
    print scene.subject_distance.to_s(:imperial)
    print "\t" + "#{scene.field_of_view(scene.subject_distance).height.to_s(:imperial)}H x #{scene.field_of_view(scene.subject_distance).width.to_s(:imperial)}W"
    apertures.each do |a|
      scene.camera.lens.aperture = a
      # print "\t" + "%s (%s ~ %s)" % [scene.total_depth_of_field, scene.near_distance_from_subject, scene.far_distance_from_subject].map { |d| d.to_s(:imperial) }
      print "\t" + "%s" % [scene.total_depth_of_field].map { |d| d.to_s(:imperial) }
    end
    puts
  end
end