Class: PhotoUtils::Tools::ChartDOF
- Inherits:
-
PhotoUtils::Tool
- Object
- PhotoUtils::Tool
- PhotoUtils::Tools::ChartDOF
- Defined in:
- lib/photo_utils/tools/chart_dof.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
#run ⇒ Object
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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/photo_utils/tools/chart_dof.rb', line 9 def run # set up basic scene basic_scene = Scene.new basic_scene.subject_distance = 8.feet basic_scene.sensitivity = 400 basic_scene.brightness = 8 scenes = [] if false scene = basic_scene.dup scene.format = Format['35'] scene.focal_length = 50.mm scene.aperture = 2 scene.description = "#{scene.format}: #{scene.focal_length} @ #{scene.aperture}" scenes << scene scene = basic_scene.dup scene.format = Format['6x6'] scene.focal_length = 92.mm scene.aperture = 8 scene.description = "#{scene.format}: #{scene.focal_length} @ #{scene.aperture}" scenes << scene scene = basic_scene.dup scene.format = Format['5x7'] scene.focal_length = 253.mm scene.aperture = 64 scene.description = "#{scene.format}: #{scene.focal_length} @ #{scene.aperture}" scenes << scene end if false scene = basic_scene.dup scene.format = Format['35'] scene.focal_length = 90.mm scene.aperture = 2.8 scene.description = "#{scene.format}: #{scene.focal_length} @ #{scene.aperture}" scenes << scene scene = basic_scene.dup scene.format = Format['35'] scene.focal_length = 90.mm scene.aperture = 4 scene.description = "#{scene.format}: #{scene.focal_length} @ #{scene.aperture}" scenes << scene scene = basic_scene.dup scene.format = Format['35'] scene.focal_length = 90.mm scene.aperture = 5.6 scene.description = "#{scene.format}: #{scene.focal_length} @ #{scene.aperture}" scenes << scene scene = basic_scene.dup scene.format = Format['35'] scene.focal_length = 85.mm scene.aperture = 4 scene.description = "#{scene.format}: #{scene.focal_length} @ #{scene.aperture}" scenes << scene scene = basic_scene.dup scene.format = Format['35'] scene.focal_length = 85.mm scene.aperture = 5.6 scene.description = "#{scene.format}: #{scene.focal_length} @ #{scene.aperture}" scenes << scene end if true camera = Camera[/eastman/i] or raise "Can't find camera" basic_scene.description = camera.name basic_scene.camera = camera aperture = camera.lens.max_aperture while aperture <= camera.lens.min_aperture scene = basic_scene.dup camera.lens.aperture = aperture # break if scene.time > 1.0/30 scene.description += ": #{camera.lens.focal_length} @ #{camera.lens.aperture}" scenes << scene aperture = Aperture.new_from_v(aperture.to_v + 1) end end scenes.each do |scene| scene.print; puts end # max_distance = scenes.map { |s| s.depth_of_field.far }.max # max_distance = scenes.map { |s| s.hyperfocal_distance }.max max_distance = 50.feet camera_width = scenes.map { |s| s.focal_length }.max camera_height = scenes.map { |s| [s.absolute_aperture, s.frame.height].max }.max html = Builder::XmlMarkup.new(indent: 2) html.declare!(:DOCTYPE, :html) html.html do html.head {} html.body do html.table do scenes.each do |scene| scene_view = SceneView.new(scene, max_distance: max_distance, camera_width: camera_width, camera_height: camera_height) html.tr do html.td do html << scene.description end html.td do html << scene_view.to_svg end end end end end end output_file = @args.first or raise Path.new(output_file).write(html.target!) end |