photo-utils 0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +3 -0
  3. data/Gemfile +4 -0
  4. data/README.rdoc +1 -0
  5. data/Rakefile +1 -0
  6. data/TODO.txt +34 -0
  7. data/bin/photo-util +39 -0
  8. data/lib/photo_utils.rb +28 -0
  9. data/lib/photo_utils/angle.rb +17 -0
  10. data/lib/photo_utils/aperture.rb +62 -0
  11. data/lib/photo_utils/apex.rb +210 -0
  12. data/lib/photo_utils/brightness.rb +49 -0
  13. data/lib/photo_utils/camera.rb +82 -0
  14. data/lib/photo_utils/compensation.rb +29 -0
  15. data/lib/photo_utils/extensions/array.rb +11 -0
  16. data/lib/photo_utils/extensions/float.rb +18 -0
  17. data/lib/photo_utils/extensions/math.rb +11 -0
  18. data/lib/photo_utils/extensions/numeric.rb +23 -0
  19. data/lib/photo_utils/formats.rb +146 -0
  20. data/lib/photo_utils/frame.rb +36 -0
  21. data/lib/photo_utils/illuminance.rb +48 -0
  22. data/lib/photo_utils/length.rb +92 -0
  23. data/lib/photo_utils/lens.rb +50 -0
  24. data/lib/photo_utils/scene.rb +180 -0
  25. data/lib/photo_utils/scene_view.rb +134 -0
  26. data/lib/photo_utils/sensitivity.rb +44 -0
  27. data/lib/photo_utils/time.rb +53 -0
  28. data/lib/photo_utils/tool.rb +17 -0
  29. data/lib/photo_utils/tools/blur.rb +43 -0
  30. data/lib/photo_utils/tools/brightness.rb +20 -0
  31. data/lib/photo_utils/tools/calc_aperture.rb +45 -0
  32. data/lib/photo_utils/tools/cameras.rb +24 -0
  33. data/lib/photo_utils/tools/chart_dof.rb +146 -0
  34. data/lib/photo_utils/tools/compare.rb +305 -0
  35. data/lib/photo_utils/tools/dof.rb +42 -0
  36. data/lib/photo_utils/tools/dof_table.rb +45 -0
  37. data/lib/photo_utils/tools/film_test.rb +57 -0
  38. data/lib/photo_utils/tools/focal_length.rb +25 -0
  39. data/lib/photo_utils/tools/reciprocity.rb +36 -0
  40. data/lib/photo_utils/tools/test.rb +91 -0
  41. data/lib/photo_utils/value.rb +37 -0
  42. data/lib/photo_utils/version.rb +5 -0
  43. data/photo-utils.gemspec +29 -0
  44. data/test/aperture_test.rb +40 -0
  45. data/test/apex_test.rb +28 -0
  46. data/test/brightness_test.rb +36 -0
  47. data/test/length_test.rb +40 -0
  48. data/test/scene_test.rb +25 -0
  49. data/test/sensitivity_test.rb +36 -0
  50. data/test/time_test.rb +42 -0
  51. metadata +185 -0
@@ -0,0 +1,36 @@
1
+ require 'test/unit'
2
+ require 'wrong'
3
+ require 'photo_utils'
4
+
5
+ class TestBrightness < Test::Unit::TestCase
6
+
7
+ include Wrong
8
+ include PhotoUtils
9
+
10
+ def setup
11
+ @b = Brightness.new(1)
12
+ end
13
+
14
+ def test_zero_value
15
+ assert { Brightness.new(1).to_v == 0 }
16
+ end
17
+
18
+ def test_has_correct_native_value
19
+ assert { @b.to_f == 1 }
20
+ end
21
+
22
+ def test_format_as_string
23
+ assert { @b.to_s == '1 fL' }
24
+ assert { @b.to_s(:value) == 'Bv:0' }
25
+ end
26
+
27
+ def test_converts_to_value
28
+ assert { @b.to_v == 0 }
29
+ end
30
+
31
+ def test_increments_and_decrements
32
+ assert { @b.incr.round == Brightness.new(@b * 2).round }
33
+ assert { @b.decr.round == Brightness.new(@b / 2).round }
34
+ end
35
+
36
+ end
@@ -0,0 +1,40 @@
1
+ require 'test/unit'
2
+ require 'wrong'
3
+ require 'photo_utils'
4
+
5
+ class TestLength < Test::Unit::TestCase
6
+
7
+ include Wrong
8
+ include PhotoUtils
9
+
10
+ def setup
11
+ @table = {
12
+ %q{∞} => Math::Infinity,
13
+ %q{6"} => 6.inches,
14
+ %q{1'} => 1.feet,
15
+ %q{3'6"} => 3.5.feet,
16
+ # %q{100} => 100.mm,
17
+ %q{100mm} => 100.mm,
18
+ %q{2m} => 2.meters,
19
+ %q{10.5m} => 10.5.meters,
20
+ }
21
+ end
22
+
23
+ def test_formatter
24
+ @table.each do |s, n|
25
+ if s =~ /['"]/
26
+ format = :imperial
27
+ else
28
+ format = :metric
29
+ end
30
+ assert { Length.new(n).to_s(format) == s }
31
+ end
32
+ end
33
+
34
+ def test_parse
35
+ @table.each do |s, n|
36
+ assert { Length.new(s) == n }
37
+ end
38
+ end
39
+
40
+ end
@@ -0,0 +1,25 @@
1
+ require 'test/unit'
2
+ require 'wrong'
3
+ require 'photo_utils'
4
+
5
+ class TestScene < Test::Unit::TestCase
6
+
7
+ include Wrong
8
+ include PhotoUtils
9
+
10
+ def setup
11
+ @scene = Scene.new
12
+ @scene.camera = Camera[/RB67/] #FIXME: Use generic
13
+ @scene.subject_distance = 10.feet
14
+ end
15
+
16
+ def test_make_scene
17
+ assert { @scene }
18
+ end
19
+
20
+ def test_blur_is_zero_at_subject
21
+ blur = @scene.blur_at_distance(@scene.subject_distance)
22
+ assert { blur == 0 }
23
+ end
24
+
25
+ end
@@ -0,0 +1,36 @@
1
+ require 'test/unit'
2
+ require 'wrong'
3
+ require 'photo_utils'
4
+
5
+ class TestSensitivity < Test::Unit::TestCase
6
+
7
+ include Wrong
8
+ include PhotoUtils
9
+
10
+ def setup
11
+ @s = Sensitivity.new(400)
12
+ end
13
+
14
+ def test_zero_value
15
+ assert { Sensitivity.new(3.125).to_v == 0 }
16
+ end
17
+
18
+ def test_has_correct_native_value
19
+ assert { @s.to_f == 400 }
20
+ end
21
+
22
+ def test_format_as_string
23
+ assert { @s.to_s == 'ISO 400' }
24
+ assert { @s.to_s(:value) == 'Sv:7' }
25
+ end
26
+
27
+ def test_converts_to_value
28
+ assert { @s.to_v.round == Sensitivity.new_from_v(7).to_v }
29
+ end
30
+
31
+ def test_increments_and_decrements
32
+ assert { @s.incr.round == Sensitivity.new(@s * 2).round }
33
+ assert { @s.decr.round == Sensitivity.new(@s / 2).round }
34
+ end
35
+
36
+ end
@@ -0,0 +1,42 @@
1
+ require 'test/unit'
2
+ require 'wrong'
3
+ require 'photo_utils'
4
+
5
+ class TestTime < Test::Unit::TestCase
6
+
7
+ include Wrong
8
+ include PhotoUtils
9
+
10
+ def setup
11
+ @t = Time.new(1.0 / 10)
12
+ end
13
+
14
+ def test_zero_value
15
+ assert { Time.new(1).to_v == 0 }
16
+ end
17
+
18
+ def test_has_correct_native_value
19
+ assert { @t.to_f == 0.1 }
20
+ end
21
+
22
+ def test_format_as_string
23
+ assert { @t.to_s == '1/10' }
24
+ assert { @t.to_s(:value) == 'Tv:3.3' }
25
+ assert { Time.new(10).to_s == '10s' }
26
+ end
27
+
28
+ def test_converts_to_value
29
+ assert { @t.to_v.round == Time.new_from_v(3).to_v }
30
+ end
31
+
32
+ def test_increments_and_decrements
33
+ assert { @t.incr.round == Time.new(@t * 2).round }
34
+ assert { @t.decr.round == Time.new(@t / 2).round }
35
+ end
36
+
37
+ def test_reciprocity
38
+ assert { Time.new(1).reciprocity.round == Time.new(1) }
39
+ assert { Time.new(10).reciprocity.round == Time.new(23) }
40
+ end
41
+
42
+ end
metadata ADDED
@@ -0,0 +1,185 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: photo-utils
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.2'
5
+ platform: ruby
6
+ authors:
7
+ - John Labovitz
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-12-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: hashstruct
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: builder
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: path
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: wrong
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: "\n PhotoUtils provides Models, formulas, and utilties for photography
98
+ optics, etc.\n "
99
+ email: johnl@johnlabovitz.com
100
+ executables:
101
+ - photo-util
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".gitignore"
106
+ - Gemfile
107
+ - README.rdoc
108
+ - Rakefile
109
+ - TODO.txt
110
+ - bin/photo-util
111
+ - lib/photo_utils.rb
112
+ - lib/photo_utils/angle.rb
113
+ - lib/photo_utils/aperture.rb
114
+ - lib/photo_utils/apex.rb
115
+ - lib/photo_utils/brightness.rb
116
+ - lib/photo_utils/camera.rb
117
+ - lib/photo_utils/compensation.rb
118
+ - lib/photo_utils/extensions/array.rb
119
+ - lib/photo_utils/extensions/float.rb
120
+ - lib/photo_utils/extensions/math.rb
121
+ - lib/photo_utils/extensions/numeric.rb
122
+ - lib/photo_utils/formats.rb
123
+ - lib/photo_utils/frame.rb
124
+ - lib/photo_utils/illuminance.rb
125
+ - lib/photo_utils/length.rb
126
+ - lib/photo_utils/lens.rb
127
+ - lib/photo_utils/scene.rb
128
+ - lib/photo_utils/scene_view.rb
129
+ - lib/photo_utils/sensitivity.rb
130
+ - lib/photo_utils/time.rb
131
+ - lib/photo_utils/tool.rb
132
+ - lib/photo_utils/tools/blur.rb
133
+ - lib/photo_utils/tools/brightness.rb
134
+ - lib/photo_utils/tools/calc_aperture.rb
135
+ - lib/photo_utils/tools/cameras.rb
136
+ - lib/photo_utils/tools/chart_dof.rb
137
+ - lib/photo_utils/tools/compare.rb
138
+ - lib/photo_utils/tools/dof.rb
139
+ - lib/photo_utils/tools/dof_table.rb
140
+ - lib/photo_utils/tools/film_test.rb
141
+ - lib/photo_utils/tools/focal_length.rb
142
+ - lib/photo_utils/tools/reciprocity.rb
143
+ - lib/photo_utils/tools/test.rb
144
+ - lib/photo_utils/value.rb
145
+ - lib/photo_utils/version.rb
146
+ - photo-utils.gemspec
147
+ - test/aperture_test.rb
148
+ - test/apex_test.rb
149
+ - test/brightness_test.rb
150
+ - test/length_test.rb
151
+ - test/scene_test.rb
152
+ - test/sensitivity_test.rb
153
+ - test/time_test.rb
154
+ homepage: http://johnlabovitz.com
155
+ licenses: []
156
+ metadata: {}
157
+ post_install_message:
158
+ rdoc_options: []
159
+ require_paths:
160
+ - lib
161
+ required_ruby_version: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ required_rubygems_version: !ruby/object:Gem::Requirement
167
+ requirements:
168
+ - - ">="
169
+ - !ruby/object:Gem::Version
170
+ version: '0'
171
+ requirements: []
172
+ rubyforge_project:
173
+ rubygems_version: 2.5.0
174
+ signing_key:
175
+ specification_version: 4
176
+ summary: Models, formulas, and utilties for photography optics, etc.
177
+ test_files:
178
+ - test/aperture_test.rb
179
+ - test/apex_test.rb
180
+ - test/brightness_test.rb
181
+ - test/length_test.rb
182
+ - test/scene_test.rb
183
+ - test/sensitivity_test.rb
184
+ - test/time_test.rb
185
+ has_rdoc: