line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Photography::EV 0.07 { |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
75272
|
use strict; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
118
|
|
4
|
4
|
|
|
4
|
|
24
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
138
|
|
5
|
4
|
|
|
4
|
|
92
|
use 5.020000; |
|
4
|
|
|
|
|
23
|
|
6
|
4
|
|
|
4
|
|
3496
|
use experimental 'signatures'; |
|
4
|
|
|
|
|
17072
|
|
|
4
|
|
|
|
|
26
|
|
7
|
4
|
|
|
4
|
|
685
|
use base qw( Exporter ); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
1169
|
|
8
|
|
|
|
|
|
|
BEGIN { |
9
|
4
|
|
|
4
|
|
447
|
eval q{ |
|
4
|
|
|
4
|
|
3775
|
|
|
4
|
|
|
|
|
33079
|
|
|
4
|
|
|
|
|
26
|
|
10
|
|
|
|
|
|
|
use POSIX qw( pow ); |
11
|
|
|
|
|
|
|
}; |
12
|
4
|
50
|
|
|
|
8393
|
if($@) |
13
|
|
|
|
|
|
|
{ |
14
|
0
|
0
|
|
|
|
0
|
*pow = sub ($x, $exponent) |
|
0
|
0
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
15
|
0
|
|
|
|
|
0
|
{ |
16
|
0
|
|
|
|
|
0
|
my $value = 1; |
17
|
0
|
|
|
|
|
0
|
for(1..$exponent) |
18
|
|
|
|
|
|
|
{ |
19
|
0
|
|
|
|
|
0
|
$value *= $x; |
20
|
|
|
|
|
|
|
} |
21
|
0
|
|
|
|
|
0
|
$value; |
22
|
|
|
|
|
|
|
} |
23
|
0
|
|
|
|
|
0
|
} |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
our @EXPORT_OK = qw( ev aperture shutter_speed ); |
27
|
|
|
|
|
|
|
our @EXPORT = @EXPORT_OK; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# ABSTRACT: Calculate exposure value (EV) |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub _round :prototype($) |
33
|
|
|
|
|
|
|
{ |
34
|
4
|
100
|
|
4
|
|
28
|
return $_[0] ? int($_[0] + $_[0]/abs($_[0]*2)) : 0; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub _log2 :prototype($) |
38
|
|
|
|
|
|
|
{ |
39
|
4
|
|
|
4
|
|
22
|
return log($_[0])/log(2); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# returns the closest value in @$list to $exact |
43
|
|
|
|
|
|
|
# returns undef if @$list is empty |
44
|
|
|
|
|
|
|
sub _closest :prototype($$) |
45
|
|
|
|
|
|
|
{ |
46
|
5
|
|
|
5
|
|
501
|
my($exact, $list) = @_; |
47
|
5
|
|
|
|
|
7
|
my $answer; |
48
|
|
|
|
|
|
|
my $diff; |
49
|
5
|
|
|
|
|
15
|
for(@$list) |
50
|
|
|
|
|
|
|
{ |
51
|
60
|
|
|
|
|
101
|
my $maybe = abs($_ - $exact); |
52
|
60
|
100
|
100
|
|
|
251
|
if((!defined $answer) || $maybe < $diff) |
53
|
|
|
|
|
|
|
{ |
54
|
41
|
|
|
|
|
51
|
$answer = $_; |
55
|
41
|
|
|
|
|
63
|
$diff = $maybe; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
5
|
|
|
|
|
31
|
$answer; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
my @apertures = qw( |
62
|
|
|
|
|
|
|
1.0 |
63
|
|
|
|
|
|
|
1.4 |
64
|
|
|
|
|
|
|
2.8 |
65
|
|
|
|
|
|
|
4.0 |
66
|
|
|
|
|
|
|
5.6 |
67
|
|
|
|
|
|
|
8.0 |
68
|
|
|
|
|
|
|
11 |
69
|
|
|
|
|
|
|
16 |
70
|
|
|
|
|
|
|
22 |
71
|
|
|
|
|
|
|
32 |
72
|
|
|
|
|
|
|
45 |
73
|
|
|
|
|
|
|
64 |
74
|
|
|
|
|
|
|
); |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
my @times = ( |
77
|
|
|
|
|
|
|
(map { $_ * 60 } qw( 32 16 8 4 2 )), |
78
|
|
|
|
|
|
|
( qw( 60 30 15 8 4 2 1)), |
79
|
|
|
|
|
|
|
(map { 1 / $_ } qw( 2 4 8 15 30 125 250 500 1000 2000 4000 8000 )) |
80
|
|
|
|
|
|
|
); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
4
|
50
|
|
4
|
1
|
18
|
sub ev ($aperture, $time) |
|
4
|
50
|
|
|
|
18
|
|
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
6
|
|
84
|
4
|
|
|
|
|
5
|
{ |
85
|
4
|
|
|
|
|
15
|
return _round _log2 $aperture*$aperture/$time; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
89
|
2
|
50
|
|
2
|
1
|
14
|
sub aperture ($ev, $time, $apertures = \@apertures ) |
|
2
|
50
|
|
|
|
9
|
|
|
2
|
100
|
|
|
|
4
|
|
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
7
|
|
90
|
2
|
|
|
|
|
3
|
{ |
91
|
2
|
|
|
|
|
36
|
return _closest sqrt pow(2, $ev)*$time, $apertures; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
3
|
50
|
|
3
|
1
|
19
|
sub shutter_speed ($ev, $aperture, $times = \@times ) |
|
3
|
50
|
|
|
|
10
|
|
|
3
|
100
|
|
|
|
6
|
|
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
10
|
|
96
|
3
|
|
|
|
|
5
|
{ |
97
|
3
|
|
|
|
|
60
|
return _closest $aperture*$aperture/pow(2, $ev), $times; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
__END__ |