| 1 | package SVG::Calendar; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | # Created on: 2006-04-22 10:36:43 | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # Create by: ivan | ||||||||||||||||||||||||||||||||||||||||||
| 5 | # $Id$ | ||||||||||||||||||||||||||||||||||||||||||
| 6 | # # $Revision$, $HeadURL$, $Date$ | ||||||||||||||||||||||||||||||||||||||||||
| 7 | # # $Revision$, $Source$, $Date$ | ||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 4 | ▶ | use version; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 4 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 4 | ▶ | use Scalar::Util qw/blessed/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 4 | ▶ | use Data::Dumper qw/Dumper/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 4 | ▶ | use Clone qw/clone/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 4 | ▶ | use Math::Trig; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 4 | ▶ | use DateTime::Format::Strptime qw/strptime strftime/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 4 | ▶ | use Template; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 4 | ▶ | use File::ShareDir qw/dist_dir/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 4 | ▶ | use Readonly; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 4 | ▶ | use Image::ExifTool qw/ImageInfo/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 4 | ▶ | use English '-no_match_vars'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 4 | ▶ | use base qw/Exporter/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 4 | our $VERSION = version->new('0.3.14'); | |||||||||||||||||||||||||||||||||||||||||
| 26 | 4 | our @EXPORT_OK = qw//; | |||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 4 | Readonly my $MARGIN_RATIO => 0.04; | |||||||||||||||||||||||||||||||||||||||||
| 29 | 4 | Readonly my $DAY_COLS => 8; | |||||||||||||||||||||||||||||||||||||||||
| 30 | 4 | Readonly my $ROUNDING_FACTOR => 0.5; | |||||||||||||||||||||||||||||||||||||||||
| 31 | 4 | Readonly my $TEXT_OFFSET_Y => 0.1; | |||||||||||||||||||||||||||||||||||||||||
| 32 | 4 | Readonly my $TEXT_OFFSET_X => 0.15; | |||||||||||||||||||||||||||||||||||||||||
| 33 | 4 | Readonly my $TEXT_WIDTH_RATIO => 0.1; | |||||||||||||||||||||||||||||||||||||||||
| 34 | 4 | Readonly my $TEXT_HEIGHT_RATIO => 0.145; | |||||||||||||||||||||||||||||||||||||||||
| 35 | 4 | Readonly my $MOON_SCALE_WIDTH => 0.3; | |||||||||||||||||||||||||||||||||||||||||
| 36 | 4 | Readonly my $MOON_SCALE_HEIGHT => 0.8; | |||||||||||||||||||||||||||||||||||||||||
| 37 | 4 | Readonly my $HEADING_WIDTH_SCALE => 0.8; | |||||||||||||||||||||||||||||||||||||||||
| 38 | 4 | Readonly my $HEADING_HEIGHT_SCALE => 0.45; | |||||||||||||||||||||||||||||||||||||||||
| 39 | 4 | Readonly my $HEADING_DOW_WIDTH_SCALE => 2; | |||||||||||||||||||||||||||||||||||||||||
| 40 | 4 | Readonly my $HEADING_DOW_HEIGHT_SCALE => 0.4; | |||||||||||||||||||||||||||||||||||||||||
| 41 | 4 | Readonly my $HEADING_WOY_WIDTH_SCALE => 4; | |||||||||||||||||||||||||||||||||||||||||
| 42 | 4 | Readonly my $HEADING_WOY_HEIGHT_SCALE => 0.9; | |||||||||||||||||||||||||||||||||||||||||
| 43 | 4 | Readonly my $MAX_WEEK_ROW => 5; | |||||||||||||||||||||||||||||||||||||||||
| 44 | 4 | Readonly my $MAX_DAYS => 42; | |||||||||||||||||||||||||||||||||||||||||
| 45 | 4 | Readonly my $INTERVAL_ONE_DAY => DateTime::Duration->new(days => 1); | |||||||||||||||||||||||||||||||||||||||||
| 46 | 4 | Readonly my $INTERVAL_ONE_WEEK => DateTime::Duration->new(days => 7); | |||||||||||||||||||||||||||||||||||||||||
| 47 | 4 | Readonly my $INTERVAL_ONE_MONTH => DateTime::Duration->new(months => 1); | |||||||||||||||||||||||||||||||||||||||||
| 48 | 4 | Readonly my $INTERVAL_ELEVEN_MONTHS => DateTime::Duration->new(months => 11); | |||||||||||||||||||||||||||||||||||||||||
| 49 | 4 | Readonly my $FULL_MOON => 100; | |||||||||||||||||||||||||||||||||||||||||
| 50 | 4 | Readonly my $MOON_RADIAL_STEP => 1.34; | |||||||||||||||||||||||||||||||||||||||||
| 51 | 4 | Readonly my $MOON_AT_NIGHT => DateTime::Duration->new(hours => 20); | |||||||||||||||||||||||||||||||||||||||||
| 52 | 4 | Readonly my $FULL_CIRCLE_DEGREES => 360; | |||||||||||||||||||||||||||||||||||||||||
| 53 | 4 | Readonly my $ONE_WEEK => 7; | |||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 3 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | 3 | my ( $class, %param ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 58 | 3 | my $self = clone \%param; | |||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | 3 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 3 | $self->init(); | |||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 3 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 3 | ▶ | sub init { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=11 SCAR=24.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 69 | 3 | my %size = $self->get_page(); | |||||||||||||||||||||||||||||||||||||||||
| 70 | 3 | my %temp = ( page => \%size, xu => $self->{page}{width_unit}, yu => $self->{page}{height_unit}, ); | |||||||||||||||||||||||||||||||||||||||||
| 71 | 3 | my $height = $self->{page}{height}; | |||||||||||||||||||||||||||||||||||||||||
| 72 | 3 | my $width = $self->{page}{width}; | |||||||||||||||||||||||||||||||||||||||||
| 73 | 3 | my $xu = $self->{page}{width_unit}; | |||||||||||||||||||||||||||||||||||||||||
| 74 | 3 | my $yu = $self->{page}{height_unit}; | |||||||||||||||||||||||||||||||||||||||||
| 75 | 3 | ▶ | my $xmargin = $self->{page}{margin} || $self->{page}{width} * $MARGIN_RATIO; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{'page'}{'margin'} || $self->{'page'}{'width'} * $MARGIN_RATIO
MC/DC0%0/2
$self->{'page'}{'margin'} || $self->{'page'}{'width'} * $MARGIN_RATIO
$self->{'page'}{'margin'}
$self->{'page'}{'width'} * $MARGIN_RATIO
Truth table33%1/3
A || B
A= $self->{'page'}{'margin'}B= $self->{'page'}{'width'} * $MARGIN_RATIO
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | 3 | ▶ | my $ymargin = $self->{page}{margin} || $self->{page}{height} * $MARGIN_RATIO; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{'page'}{'margin'} || $self->{'page'}{'height'} * $MARGIN_RATIO
MC/DC0%0/2
$self->{'page'}{'margin'} || $self->{'page'}{'height'} * $MARGIN_RATIO
$self->{'page'}{'margin'}
$self->{'page'}{'height'} * $MARGIN_RATIO
Truth table33%1/3
A || B
A= $self->{'page'}{'margin'}B= $self->{'page'}{'height'} * $MARGIN_RATIO
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 3 | $self->{page}{x_margin} = $xmargin; | |||||||||||||||||||||||||||||||||||||||||
| 78 | 3 | $self->{page}{y_margin} = $ymargin; | |||||||||||||||||||||||||||||||||||||||||
| 79 | 3 | ▶ | $self->{moon}{xoffset} ||= 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"moon"}{"xoffset"} ||= 0
MC/DC0%0/1
$self->{"moon"}{"xoffset"} ||= 0
$self->{"moon"}{"xoffset"}
Truth table50%1/2
A
A= $self->{"moon"}{"xoffset"}
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 3 | ▶ | $self->{moon}{yoffset} ||= 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"moon"}{"yoffset"} ||= 0
MC/DC0%0/1
$self->{"moon"}{"yoffset"} ||= 0
$self->{"moon"}{"yoffset"}
Truth table50%1/2
A
A= $self->{"moon"}{"yoffset"}
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | 3 | ▶ | $self->{calendar_height} ||= '0.5'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"calendar_height"} ||= "0.5"
MC/DC0%0/1
$self->{"calendar_height"} ||= "0.5"
$self->{"calendar_height"}
Truth table50%1/2
A
A= $self->{"calendar_height"}
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | 3 | $self->{calendar_height} =~ s/%//exms; | |||||||||||||||||||||||||||||||||||||||||
| 83 | 3 | ▶ | if ( $self->{calendar_height} > 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | # assume that the height is a percentage value and divide by 100 | ||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | $self->{calendar_height} /= 100; | |||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||
| 87 | 3 | $self->{classes} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | # cal bounding box (bb) | ||||||||||||||||||||||||||||||||||||||||||
| 90 | $temp{bb} = { | ||||||||||||||||||||||||||||||||||||||||||
| 91 | x => $xmargin, | ||||||||||||||||||||||||||||||||||||||||||
| 92 | y => ( $height * ( 1 - $self->{calendar_height} ) + $ymargin ), | ||||||||||||||||||||||||||||||||||||||||||
| 93 | 3 | height => ( $height * $self->{calendar_height} - $ymargin * 2 ), | |||||||||||||||||||||||||||||||||||||||||
| 94 | width => ( $width - $xmargin * 2 ), | ||||||||||||||||||||||||||||||||||||||||||
| 95 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | 3 | my $rows = $MAX_WEEK_ROW + 1; | |||||||||||||||||||||||||||||||||||||||||
| 98 | 3 | my $row_height = $temp{bb}{height} / ( $rows + $ROUNDING_FACTOR ) * ( 0.5 + $self->{calendar_height} ); | |||||||||||||||||||||||||||||||||||||||||
| 99 | 3 | my $row_margin_height = $row_height / ( $rows * 2 ); | |||||||||||||||||||||||||||||||||||||||||
| 100 | 3 | my $cols = $DAY_COLS; | |||||||||||||||||||||||||||||||||||||||||
| 101 | 3 | my $col_width = $temp{bb}{width} / ( $cols + $ROUNDING_FACTOR ); | |||||||||||||||||||||||||||||||||||||||||
| 102 | 3 | my $col_margin_width = $col_width / ( $cols * 2 ); | |||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | # setup the day boxes row by row | ||||||||||||||||||||||||||||||||||||||||||
| 105 | 3 | for my $i ( 2 .. $rows ) { | |||||||||||||||||||||||||||||||||||||||||
| 106 | 15 | my $row_y = $temp{bb}{y} + $row_margin_height * ( 2 * $i - 1 ) + $row_height * ( $i - 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | # setup the individual days | ||||||||||||||||||||||||||||||||||||||||||
| 109 | 15 | for my $j ( 2 .. $cols ) { | |||||||||||||||||||||||||||||||||||||||||
| 110 | 105 | my $x = ( $temp{bb}{x} + $col_margin_width * ( 2 * $j - 1 ) + $col_width * ( $j - 1 ) ) - $col_width / 2; | |||||||||||||||||||||||||||||||||||||||||
| 111 | 105 | my $y = $row_y - $row_height / 2; | |||||||||||||||||||||||||||||||||||||||||
| 112 | 105 | $temp{cal}[ $i - 1 ][ $j - 1 ] = { | |||||||||||||||||||||||||||||||||||||||||
| 113 | x => $x, | ||||||||||||||||||||||||||||||||||||||||||
| 114 | y => $y, | ||||||||||||||||||||||||||||||||||||||||||
| 115 | height => $row_height, | ||||||||||||||||||||||||||||||||||||||||||
| 116 | width => $col_width, | ||||||||||||||||||||||||||||||||||||||||||
| 117 | text => { | ||||||||||||||||||||||||||||||||||||||||||
| 118 | x => $x + $col_margin_width * $TEXT_OFFSET_X, | ||||||||||||||||||||||||||||||||||||||||||
| 119 | y => $y + $row_height * $TEXT_OFFSET_X, | ||||||||||||||||||||||||||||||||||||||||||
| 120 | length => $col_width * $TEXT_WIDTH_RATIO, | ||||||||||||||||||||||||||||||||||||||||||
| 121 | class => 'mday ', | ||||||||||||||||||||||||||||||||||||||||||
| 122 | style => 'font-size: ' . ( $row_height * $TEXT_HEIGHT_RATIO ), | ||||||||||||||||||||||||||||||||||||||||||
| 123 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 124 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | # set up the week day headings | ||||||||||||||||||||||||||||||||||||||||||
| 129 | 3 | my $count = 1; | |||||||||||||||||||||||||||||||||||||||||
| 130 | 3 | for my $day (qw/Mon Tue Wed Thu Fri Sat Sun/) { | |||||||||||||||||||||||||||||||||||||||||
| 131 | 21 | my $x = $temp{bb}{x} + $col_margin_width * ( 2 * $count + 1 ) + $col_width * ( $count - 1 ) + $col_width / 2; | |||||||||||||||||||||||||||||||||||||||||
| 132 | 21 | my $y = $temp{bb}{y} + $row_margin_height; | |||||||||||||||||||||||||||||||||||||||||
| 133 | $temp{cal}[0][$count] = { | ||||||||||||||||||||||||||||||||||||||||||
| 134 | x => $x, | ||||||||||||||||||||||||||||||||||||||||||
| 135 | y => $y, | ||||||||||||||||||||||||||||||||||||||||||
| 136 | height => $row_height * $self->{calendar_height}, | ||||||||||||||||||||||||||||||||||||||||||
| 137 | 21 | width => $col_width, | |||||||||||||||||||||||||||||||||||||||||
| 138 | text => { | ||||||||||||||||||||||||||||||||||||||||||
| 139 | text => $day, | ||||||||||||||||||||||||||||||||||||||||||
| 140 | x => $x + $col_width / $HEADING_DOW_WIDTH_SCALE, | ||||||||||||||||||||||||||||||||||||||||||
| 141 | y => $y + $row_height * $HEADING_DOW_HEIGHT_SCALE, | ||||||||||||||||||||||||||||||||||||||||||
| 142 | length => $col_width * $HEADING_WIDTH_SCALE, | ||||||||||||||||||||||||||||||||||||||||||
| 143 | adjust => 'spacing', #AndGlyphs', | ||||||||||||||||||||||||||||||||||||||||||
| 144 | class => 'day ' . lc $day, | ||||||||||||||||||||||||||||||||||||||||||
| 145 | style => 'font-size: ' . ( $row_height * $HEADING_HEIGHT_SCALE ), | ||||||||||||||||||||||||||||||||||||||||||
| 146 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 147 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 148 | 21 | $count++; | |||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | # set up the week of the year column | ||||||||||||||||||||||||||||||||||||||||||
| 152 | 3 | $count = 1; | |||||||||||||||||||||||||||||||||||||||||
| 153 | 3 | for my $week ( 1 .. $MAX_WEEK_ROW ) { | |||||||||||||||||||||||||||||||||||||||||
| 154 | 15 | my $x = $temp{bb}{x} + $col_margin_width; | |||||||||||||||||||||||||||||||||||||||||
| 155 | 15 | my $y = $temp{bb}{y} + $row_margin_height * ( 2 * $count + 1 ) + $row_height * ( $count - 1 ) + $row_height / 2; | |||||||||||||||||||||||||||||||||||||||||
| 156 | 15 | $temp{cal}[$count][0] = { | |||||||||||||||||||||||||||||||||||||||||
| 157 | x => $x, | ||||||||||||||||||||||||||||||||||||||||||
| 158 | y => $y, | ||||||||||||||||||||||||||||||||||||||||||
| 159 | height => $row_height, | ||||||||||||||||||||||||||||||||||||||||||
| 160 | width => $col_width / 2, | ||||||||||||||||||||||||||||||||||||||||||
| 161 | text => { | ||||||||||||||||||||||||||||||||||||||||||
| 162 | text => $week, | ||||||||||||||||||||||||||||||||||||||||||
| 163 | x => $x + $col_width / $HEADING_WOY_WIDTH_SCALE, | ||||||||||||||||||||||||||||||||||||||||||
| 164 | y => $y + $row_height * $HEADING_WOY_HEIGHT_SCALE, | ||||||||||||||||||||||||||||||||||||||||||
| 165 | length => $col_width * $HEADING_WIDTH_SCALE, | ||||||||||||||||||||||||||||||||||||||||||
| 166 | adjust => 'spacing', #AndGlyphs', | ||||||||||||||||||||||||||||||||||||||||||
| 167 | class => 'week', | ||||||||||||||||||||||||||||||||||||||||||
| 168 | style => 'font-size: ' . ( $row_height * $HEADING_HEIGHT_SCALE ), | ||||||||||||||||||||||||||||||||||||||||||
| 169 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 170 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 171 | 15 | $count++; | |||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||
| 174 | # get the month display stuff | ||||||||||||||||||||||||||||||||||||||||||
| 175 | $temp{month} = { | ||||||||||||||||||||||||||||||||||||||||||
| 176 | x => $temp{bb}{x} + $col_margin_width * 2, | ||||||||||||||||||||||||||||||||||||||||||
| 177 | 3 | y => $temp{bb}{y} - $ymargin/2, | |||||||||||||||||||||||||||||||||||||||||
| 178 | style => 'font-size: ' . ($row_height), | ||||||||||||||||||||||||||||||||||||||||||
| 179 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | # set up the year display | ||||||||||||||||||||||||||||||||||||||||||
| 182 | $temp{year} = { | ||||||||||||||||||||||||||||||||||||||||||
| 183 | x => $temp{bb}{x} + $temp{bb}{width}, | ||||||||||||||||||||||||||||||||||||||||||
| 184 | 3 | y => $temp{bb}{y} - $ymargin/2, | |||||||||||||||||||||||||||||||||||||||||
| 185 | style => 'text-align: end; text-anchor: end; font-size: ' . $row_height, | ||||||||||||||||||||||||||||||||||||||||||
| 186 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | 3 | $self->{template} = \%temp; | |||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | 3 | return; | |||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||
| 193 | 20 | ▶ | sub get_page { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_page: called CC=19 SCAR=30.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | 20 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 196 | 20 | ▶ | my $page = ref $self->{page} ? $self->{page}{page} : $self->{page}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 197 | 20 | my %size = ( width => '210.00mm', height => '297.00mm' ); | |||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | 20 | ▶ | if ($page) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | 2 | ▶ | %size = | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 7 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | $page eq 'A0' ? ( width => '840.00mm', height => '1188.00mm' ) | ||||||||||||||||||||||||||||||||||||||||||
| 202 | : $page eq 'A1' ? ( width => '594.00mm', height => '840.00mm' ) | ||||||||||||||||||||||||||||||||||||||||||
| 203 | : $page eq 'A2' ? ( width => '420.00mm', height => '594.00mm' ) | ||||||||||||||||||||||||||||||||||||||||||
| 204 | : $page eq 'A3' ? ( width => '297.00mm', height => '420.00mm' ) | ||||||||||||||||||||||||||||||||||||||||||
| 205 | : $page eq 'A4' ? ( width => '210.00mm', height => '297.00mm' ) | ||||||||||||||||||||||||||||||||||||||||||
| 206 | : $page eq 'A5' ? ( width => '148.50mm', height => '210.00mm' ) | ||||||||||||||||||||||||||||||||||||||||||
| 207 | : $page eq 'A6' ? ( width => '105.00mm', height => '148.50mm' ) | ||||||||||||||||||||||||||||||||||||||||||
| 208 | : croak "Unknown page type '$page'!\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | 20 | ▶ | if ( ref $self->{page} && $self->{page}{width} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $self->{"page"} and $self->{"page"}{"width"}
MC/DC50%1/2
ref $self->{"page"} and $self->{"page"}{"width"}
ref $self->{"page"}
$self->{"page"}{"width"}
Truth table66%2/3
A and B
A= ref $self->{"page"}B= $self->{"page"}{"width"}
| |||||||||||||||||||||||||||||||||||||||||||
| 212 | 15 | $size{width} = $self->{page}{width}; | |||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||
| 214 | 20 | ▶ | if ( ref $self->{page} && $self->{page}{height} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $self->{"page"} and $self->{"page"}{"height"}
MC/DC50%1/2
ref $self->{"page"} and $self->{"page"}{"height"}
ref $self->{"page"}
$self->{"page"}{"height"}
Truth table66%2/3
A and B
A= ref $self->{"page"}B= $self->{"page"}{"height"}
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | 15 | $size{height} = $self->{page}{height}; | |||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | # Get the values to internal variables | ||||||||||||||||||||||||||||||||||||||||||
| 219 | 20 | my ( $width, $width_unit ) = $size{width} =~ /\A(.+?)(px|pt|mm|cm|m|in)?\Z/xms; | |||||||||||||||||||||||||||||||||||||||||
| 220 | 20 | $width *= 1.0; | |||||||||||||||||||||||||||||||||||||||||
| 221 | 20 | ▶ | croak "Unable to get a width from $self->{page} or $self->{width}" if !$width; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | 20 | ▶ | $width_unit ||= 'px'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$width_unit ||= "px"
MC/DC100%1/1
$width_unit ||= "px"
$width_unit
Truth table100%2/2
A
A= $width_unit
| |||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | 20 | my ( $height, $height_unit ) = $size{height} =~ /\A(.+?)(px|pt|mm|cm|m|in)?\Z/xms; | |||||||||||||||||||||||||||||||||||||||||
| 225 | 20 | $height *= 1.0; | |||||||||||||||||||||||||||||||||||||||||
| 226 | 20 | ▶ | croak "Unable to get a height from $self->{page} or $self->{height}" if !$height; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 227 | 20 | ▶ | $height_unit ||= 'px'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$height_unit ||= "px"
MC/DC100%1/1
$height_unit ||= "px"
$height_unit
Truth table100%2/2
A
A= $height_unit
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | # store the internal variables | ||||||||||||||||||||||||||||||||||||||||||
| 230 | 20 | ▶ | if ( !ref $self->{page} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 231 | 5 | $self->{page} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||
| 233 | 20 | $self->{page}{width} = $width; | |||||||||||||||||||||||||||||||||||||||||
| 234 | 20 | $self->{page}{width_unit} = $width_unit; | |||||||||||||||||||||||||||||||||||||||||
| 235 | 20 | $self->{page}{height} = $height; | |||||||||||||||||||||||||||||||||||||||||
| 236 | 20 | $self->{page}{height_unit} = $height_unit; | |||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | return ( | ||||||||||||||||||||||||||||||||||||||||||
| 239 | 20 | width => $width, | |||||||||||||||||||||||||||||||||||||||||
| 240 | width_unit => $width_unit, | ||||||||||||||||||||||||||||||||||||||||||
| 241 | height => $height, | ||||||||||||||||||||||||||||||||||||||||||
| 242 | height_unit => $height_unit, | ||||||||||||||||||||||||||||||||||||||||||
| 243 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||
| 246 | 1 | ▶ | sub output_year { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
output_year: called CC=4 SCAR=14.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | 1 | my ( $self, @params ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 249 | 1 | my $file = pop @params; | |||||||||||||||||||||||||||||||||||||||||
| 250 | 1 | my ( $start, $end ) = @params; | |||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||
| 252 | 1 | ▶ | return if !$start; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | 1 | ▶ | if ($end) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | $start = strptime('%F', "$start-01"); | |||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | $end = strptime('%F', "$end-01"); | |||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||
| 258 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 259 | 1 | $start = strptime('%F', "$start-01-01"); | |||||||||||||||||||||||||||||||||||||||||
| 260 | 1 | $end = $start + $INTERVAL_ELEVEN_MONTHS; | |||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | 1 | my @files; | |||||||||||||||||||||||||||||||||||||||||
| 264 | 1 | ▶ | while ( $start <= $end ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 265 | 12 | my $month = $start->strftime('%Y-%m'); | |||||||||||||||||||||||||||||||||||||||||
| 266 | 12 | push @files, "$file-$month.svg"; | |||||||||||||||||||||||||||||||||||||||||
| 267 | 12 | $self->output_month( $month, "$file-$month.svg" ); | |||||||||||||||||||||||||||||||||||||||||
| 268 | 12 | $start += $INTERVAL_ONE_MONTH; | |||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||
| 271 | 1 | return @files; | |||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||
| 274 | 13 | ▶ | sub output_month { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
output_month: called CC=23 SCAR=43.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||
| 276 | 13 | my ( $self, $month, $file, ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | # add the month specific details to a clone of the general settings | ||||||||||||||||||||||||||||||||||||||||||
| 279 | 13 | my $templ = clone $self->{template}; | |||||||||||||||||||||||||||||||||||||||||
| 280 | 13 | my %size = $self->get_page(); | |||||||||||||||||||||||||||||||||||||||||
| 281 | 13 | $self->{full_moon} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||
| 283 | 13 | ▶ | carp "Month '$month' is not the correct format (YYYY-MM) " if !$month || $month !~ /\A\d{4}-\d{2}\Z/xms; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$month and $month =~ /\A\d{4}-\d{2}\Z/msx
MC/DC0%0/2
$month and $month =~ /\A\d{4}-\d{2}\Z/msx
$month
$month =~ /\A\d{4}-\d{2}\Z/msx
Truth table33%1/3
A and B
A= $monthB= $month =~ /\A\d{4}-\d{2}\Z/msx
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||
| 285 | 13 | my $date = strptime('%F', "$month-01"); | |||||||||||||||||||||||||||||||||||||||||
| 286 | 13 | $templ->{year}{text} = $date->year(); | |||||||||||||||||||||||||||||||||||||||||
| 287 | 13 | $templ->{month}{text} = $date->month_name(); | |||||||||||||||||||||||||||||||||||||||||
| 288 | 13 | my $month_day = $date - $INTERVAL_ONE_WEEK; | |||||||||||||||||||||||||||||||||||||||||
| 289 | 13 | my $row = 1; | |||||||||||||||||||||||||||||||||||||||||
| 290 | 13 | my $wrap = 0; | |||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||
| 292 | # make sure that we start on a monday | ||||||||||||||||||||||||||||||||||||||||||
| 293 | 13 | ▶ | while ( $month_day->wday() != 2 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 294 | 35 | $month_day += $INTERVAL_ONE_DAY; | |||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||
| 297 | DAY: | ||||||||||||||||||||||||||||||||||||||||||
| 298 | 13 | for my $count ( 1 .. $MAX_DAYS ) { | |||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||
| 300 | # get the day of the week (of the first day of the month) | ||||||||||||||||||||||||||||||||||||||||||
| 301 | 466 | my $wday = $month_day->wday(); | |||||||||||||||||||||||||||||||||||||||||
| 302 | 466 | ▶ | $wday = $wday == 1 ? $ONE_WEEK : $wday - 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 303 | 466 | my $r = $templ->{cal}[$row][$wday]{width} / $DAY_COLS; | |||||||||||||||||||||||||||||||||||||||||
| 304 | 466 | ▶ | if ( $self->{moon}{radius} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | $r *= $self->{moon}{radius}; | |||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||
| 308 | 466 | $templ->{cal}[$row][$wday]{text}{text} = $month_day->mday(); | |||||||||||||||||||||||||||||||||||||||||
| 309 | 466 | ▶ | $templ->{cal}[$row][$wday]{current} = $date->month() == $month_day->month() ? 1 : 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 310 | 466 | ▶ | if ( $date->month() == $month_day->month() ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 311 | 397 | $templ->{cal}[$row][$wday]{text}{class} .= 'current_month'; | |||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||
| 314 | 466 | ▶ | if ( $self->{moon} && $self->{moon}{display} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"moon"} and $self->{"moon"}{"display"}
MC/DC0%0/2
$self->{"moon"} and $self->{"moon"}{"display"}
$self->{"moon"}
$self->{"moon"}{"display"}
Truth table33%1/3
A and B
A= $self->{"moon"}B= $self->{"moon"}{"display"}
| |||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||
| 316 | # get the phase info at 8:00pm | ||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | my $moon_date = $month_day + $MOON_AT_NIGHT; | |||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | my $phase = $self->get_moon_phase($moon_date); | |||||||||||||||||||||||||||||||||||||||||
| 319 | $templ->{cal}[$row][$wday]{moon} = $self->moon( | ||||||||||||||||||||||||||||||||||||||||||
| 320 | phase => $phase, | ||||||||||||||||||||||||||||||||||||||||||
| 321 | id => 'moon_' . $month_day->strftime('%Y-%m-%d'), | ||||||||||||||||||||||||||||||||||||||||||
| 322 | x => $templ->{cal}[$row][$wday]{x} + $r + $templ->{cal}[$row][$wday]{width} * $MOON_SCALE_WIDTH + $self->{moon}{xoffset}, | ||||||||||||||||||||||||||||||||||||||||||
| 323 | y => $templ->{cal}[$row][$wday]{y} - $r + $templ->{cal}[$row][$wday]{height} * $MOON_SCALE_HEIGHT + $self->{moon}{yoffset}, | ||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | r => $r, | |||||||||||||||||||||||||||||||||||||||||
| 325 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||
| 328 | 466 | ▶ | if ( $wday == $ONE_WEEK ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 329 | 65 | $row++; | |||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||
| 331 | 466 | ▶ | if ( $row > $MAX_WEEK_ROW ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 332 | 13 | $row = 1; | |||||||||||||||||||||||||||||||||||||||||
| 333 | 13 | $wrap = 1; | |||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||
| 335 | 466 | $month_day += $INTERVAL_ONE_DAY; | |||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||
| 337 | # stop if we leave the current month. | ||||||||||||||||||||||||||||||||||||||||||
| 338 | 466 | ▶ | last DAY if $wrap && $date->month() != $month_day->month(); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$wrap and $date->month != $month_day->month
MC/DC100%2/2
$wrap and $date->month != $month_day->month
$wrap
$date->month != $month_day->month
Truth table100%3/3
A and B
A= $wrapB= $date->month != $month_day->month
| |||||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||
| 341 | # process the image if present | ||||||||||||||||||||||||||||||||||||||||||
| 342 | 13 | ▶ | if ( $self->{image} && ( $self->{image}{src} || $self->{image}{$month} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition16%1/6
$self->{"image"} and $self->{"image"}{"src"} || $self->{"image"}{$month}
$self->{"image"}{"src"} or $self->{"image"}{$month}
MC/DC0%0/3
$self->{"image"} and $self->{"image"}{"src"} || $self->{"image"}{$month}
$self->{"image"}
$self->{"image"}{"src"}
$self->{"image"}{$month}
Truth table25%1/4
A and B or C
A= $self->{"image"}B= $self->{"image"}{"src"}C= $self->{"image"}{$month}
| |||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | ▶ | my $image = $self->{image}{$month} || $self->{image}{src}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{'image'}{$month} || $self->{'image'}{'src'}
MC/DC0%0/2
$self->{'image'}{$month} || $self->{'image'}{'src'}
$self->{'image'}{$month}
$self->{'image'}{'src'}
Truth table0%0/3
A || B
A= $self->{'image'}{$month}B= $self->{'image'}{'src'}
| |||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | $templ->{image}{src} = $image; | |||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | $templ->{image}{x} = $self->{page}{x_margin}; | |||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | $templ->{image}{y} = $self->{page}{y_margin}; | |||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | if ( -f $image ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | my $info = ImageInfo($image); | |||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | ▶ | if ( $info->{ImageHeight} && $info->{ImageWidth} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$info->{"ImageHeight"} and $info->{"ImageWidth"}
MC/DC0%0/2
$info->{"ImageHeight"} and $info->{"ImageWidth"}
$info->{"ImageHeight"}
$info->{"ImageWidth"}
Truth table0%0/3
A and B
A= $info->{"ImageHeight"}B= $info->{"ImageWidth"}
| |||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | $templ->{image}{x} = $self->{page}{x_margin}; | |||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | $templ->{image}{y} = $self->{page}{y_margin}; | |||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | $templ->{image}{width} = $self->{page}{width} - 2 * $self->{page}{x_margin}; | |||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | $templ->{image}{height} = $self->{page}{height} * (1 - $self->{calendar_height}) - $self->{page}{y_margin} * 2; | |||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | my $image_scale = $info->{ImageHeight} / $info->{ImageWidth}; | |||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | my $page_scale = $templ->{image}{height} / $templ->{image}{width}; | |||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | ▶ | if ($image_scale < $page_scale) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | $templ->{image}{y} -= ( $templ->{image}{height} - ( $templ->{image}{height} * $page_scale / $image_scale ) ) / 2; | |||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | $templ->{image}{height} *= $image_scale / $page_scale; | |||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||
| 364 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | $templ->{image}{x} += ( $templ->{image}{width} - ( $templ->{image}{width} * $page_scale / $image_scale ) ) / 2; | |||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | $templ->{image}{width} *= $page_scale / $image_scale; | |||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||
| 369 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | die "The image $image doesn't apear to have a height or width\n"; | |||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||
| 375 | 13 | return $self->output( $file, $templ ); | |||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||
| 378 | 14 | ▶ | sub output { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
output: called CC=16 SCAR=35.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||
| 380 | 14 | my ( $self, $file, $template ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||
| 382 | 14 | my $fh; | |||||||||||||||||||||||||||||||||||||||||
| 383 | 14 | my %option = ( EVAL_PERL => 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 384 | 14 | ▶ | $option{INCLUDE_PATH} = $self->{INCLUDE_PATH} || dist_dir('SVG-Calendar'); | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{'INCLUDE_PATH'} || dist_dir('SVG-Calendar')
MC/DC0%0/2
$self->{'INCLUDE_PATH'} || dist_dir('SVG-Calendar')
$self->{'INCLUDE_PATH'}
dist_dir('SVG-Calendar')
Truth table33%1/3
A || B
A= $self->{'INCLUDE_PATH'}B= dist_dir('SVG-Calendar')
| |||||||||||||||||||||||||||||||||||||||||||
| 385 | 14 | ▶ | if ( $self->{path} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | $option{INCLUDE_PATH} .= ':' . $self->{path}; | |||||||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||
| 389 | 14 | ▶ | my $tmpl = $self->{tt} || Template->new(%option); | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{'tt'} || 'Template'->new(%option)
MC/DC0%0/2
$self->{'tt'} || 'Template'->new(%option)
$self->{'tt'}
'Template'->new(%option)
Truth table66%2/3
A || B
A= $self->{'tt'}B= 'Template'->new(%option)
| |||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||
| 391 | 14 | my $text; | |||||||||||||||||||||||||||||||||||||||||
| 392 | 14 | ▶ | print Dumper($template) if $self->{verbose}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||
| 394 | 14 | ▶ | $tmpl->process( 'calendar.svg', $template, \$text ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 395 | or croak( $tmpl->error ); | ||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||
| 397 | 14 | ▶ | if ($file) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 398 | 12 | ▶ | if ( $file eq q/-/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | ▶ | print $text or carp "Could not write to STDOUT: $OS_ERROR\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||||||
| 401 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 402 | 12 | ▶ | open $fh, q/>/, $file or croak "Cannot write SVG to file '$file': $!\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||
| 404 | 12 | ▶ | print {$fh} $text or carp "Could not write to file '$file': $OS_ERROR\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||
| 406 | 12 | ▶ | close $fh or carp "There was an issue closing file '$file': $OS_ERROR\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||
| 408 | 12 | ▶ | if ( -f $file && $self->{inkscape} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
-f $file and $self->{"inkscape"}
MC/DC0%0/2
-f $file and $self->{"inkscape"}
-f $file
$self->{"inkscape"}
Truth table33%1/3
A and B
A= -f $fileB= $self->{"inkscape"}
| |||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | ▶ | if ( $self->{inkscape}{pdf} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 410 | # get inkscape to convert svg to PDF | ||||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | ▶ | if ( $self->{inkscape}{print} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 413 | # get inkscape to print out the document | ||||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||
| 419 | 14 | $self->{tt} = $tmpl; | |||||||||||||||||||||||||||||||||||||||||
| 420 | 14 | return $text; | |||||||||||||||||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||
| 423 | 31 | ▶ | sub moon { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
moon: called CC=11 SCAR=24.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 424 | 31 | my ( $self, %params ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||
| 426 | 31 | my $phase = $params{phase}; | |||||||||||||||||||||||||||||||||||||||||
| 427 | 31 | my $id = $params{id}; | |||||||||||||||||||||||||||||||||||||||||
| 428 | 31 | ▶ | my $x = $params{x} || $FULL_MOON; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$params{'x'} || $FULL_MOON
MC/DC0%0/2
$params{'x'} || $FULL_MOON
$params{'x'}
$FULL_MOON
Truth table33%1/3
A || B
A= $params{'x'}B= $FULL_MOON
| |||||||||||||||||||||||||||||||||||||||||||
| 429 | 31 | ▶ | my $y = $params{y} || $FULL_MOON; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$params{'y'} || $FULL_MOON
MC/DC0%0/2
$params{'y'} || $FULL_MOON
$params{'y'}
$FULL_MOON
Truth table33%1/3
A || B
A= $params{'y'}B= $FULL_MOON
| |||||||||||||||||||||||||||||||||||||||||||
| 430 | 31 | ▶ | my $r = $params{r} || $FULL_MOON; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$params{'r'} || $FULL_MOON
MC/DC0%0/2
$params{'r'} || $FULL_MOON
$params{'r'}
$FULL_MOON
Truth table33%1/3
A || B
A= $params{'r'}B= $FULL_MOON
| |||||||||||||||||||||||||||||||||||||||||||
| 431 | 31 | my $class = q//; | |||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||
| 433 | # approx error of less than one lunar day | ||||||||||||||||||||||||||||||||||||||||||
| 434 | 31 | my $error = 2 * pi / 56; ## no critic | |||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||
| 436 | 31 | my $moon = { id => $id }; | |||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||
| 438 | # moon phases 0 == new moon 3 == last quarter | ||||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||
| 440 | 31 | my ( $sx, $sy ) = ( $x, $y ); | |||||||||||||||||||||||||||||||||||||||||
| 441 | 31 | my ( $ex, $ey ) = ( $x, $y + 2 * $r ); | |||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||
| 443 | 31 | ▶ | if ( $phase < $error || 2 * pi - $error < $phase ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition66%2/3
$phase < $error or "6.28318530717959" - $error < $phase
MC/DC50%1/2
$phase < $error or "6.28318530717959" - $error < $phase
$phase < $error
"6.28318530717959" - $error < $phase
Truth table66%2/3
A or B
A= $phase < $errorB= "6.28318530717959" - $error < $phase
| |||||||||||||||||||||||||||||||||||||||||||
| 444 | 1 | $class = ' new-moon'; | |||||||||||||||||||||||||||||||||||||||||
| 445 | } | ||||||||||||||||||||||||||||||||||||||||||
| 446 | ▶ | elsif ( pi - $error < $phase && $phase < pi + $error ) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
"3.14159265358979" - $error < $phase and $phase < "3.14159265358979" + $error
MC/DC100%2/2
"3.14159265358979" - $error < $phase and $phase < "3.14159265358979" + $error
"3.14159265358979" - $error < $phase
$phase < "3.14159265358979" + $error
Truth table100%3/3
A and B
A= "3.14159265358979" - $error < $phaseB= $phase < "3.14159265358979" + $error
| |||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||
| 448 | # approx full moon | ||||||||||||||||||||||||||||||||||||||||||
| 449 | 1 | ▶ | my $moon_type = $self->{full_moon}++ ? 'blue-moon' : 'full-moon'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 450 | $moon->{highlight} = { | ||||||||||||||||||||||||||||||||||||||||||
| 451 | 1 | type => 'circle', | |||||||||||||||||||||||||||||||||||||||||
| 452 | id => $id, | ||||||||||||||||||||||||||||||||||||||||||
| 453 | class => $moon_type, | ||||||||||||||||||||||||||||||||||||||||||
| 454 | cx => $x, | ||||||||||||||||||||||||||||||||||||||||||
| 455 | cy => ( $sy + $ey ) / 2, | ||||||||||||||||||||||||||||||||||||||||||
| 456 | r => $r, | ||||||||||||||||||||||||||||||||||||||||||
| 457 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||||||||||||||||
| 459 | elsif ( $phase < pi ) { | ||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||
| 461 | # moon waxing partial | ||||||||||||||||||||||||||||||||||||||||||
| 462 | 16 | my $d = "M $sx\t$sy C "; | |||||||||||||||||||||||||||||||||||||||||
| 463 | 16 | $d .= ( $sx + $r * $MOON_RADIAL_STEP ) . q/ / . $sy . q/,/; | |||||||||||||||||||||||||||||||||||||||||
| 464 | 16 | $d .= ( $sx + $r * $MOON_RADIAL_STEP ) . q/ / . $ey; | |||||||||||||||||||||||||||||||||||||||||
| 465 | 16 | $d .= ",$ex\t$ey C "; | |||||||||||||||||||||||||||||||||||||||||
| 466 | 16 | $d .= ( $ex - $r * $MOON_RADIAL_STEP * ( -cos($phase) ) ) . q/ / . ( $ey + $r / 2 * ( -sin($phase) ) ) . q/,/; | |||||||||||||||||||||||||||||||||||||||||
| 467 | 16 | $d .= ( $ex - $r * $MOON_RADIAL_STEP * ( -cos($phase) ) ) . q/ / . ( $sy - $r / 2 * ( -sin($phase) ) ); | |||||||||||||||||||||||||||||||||||||||||
| 468 | 16 | $d .= ", $sx\t$sy Z"; | |||||||||||||||||||||||||||||||||||||||||
| 469 | $moon->{highlight} = { | ||||||||||||||||||||||||||||||||||||||||||
| 470 | 16 | type => 'path', | |||||||||||||||||||||||||||||||||||||||||
| 471 | id => $id, | ||||||||||||||||||||||||||||||||||||||||||
| 472 | d => $d, | ||||||||||||||||||||||||||||||||||||||||||
| 473 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||||||||||||
| 475 | elsif ( $phase > pi ) { | ||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||
| 477 | # moon waning partial | ||||||||||||||||||||||||||||||||||||||||||
| 478 | 13 | my $d = "M $sx\t$sy C "; | |||||||||||||||||||||||||||||||||||||||||
| 479 | 13 | $d .= ( $sx - $r * $MOON_RADIAL_STEP ) . q/ / . $sy . q/,/; | |||||||||||||||||||||||||||||||||||||||||
| 480 | 13 | $d .= ( $sx - $r * $MOON_RADIAL_STEP ) . q/ / . $ey; | |||||||||||||||||||||||||||||||||||||||||
| 481 | 13 | $d .= ",$ex\t$ey C "; | |||||||||||||||||||||||||||||||||||||||||
| 482 | 13 | $d .= ( $ex + $r * $MOON_RADIAL_STEP * ( -cos($phase) ) ) . q/ / . ( $ey - $r / 2 * ( -sin($phase) ) ) . q/,/; | |||||||||||||||||||||||||||||||||||||||||
| 483 | 13 | $d .= ( $ex + $r * $MOON_RADIAL_STEP * ( -cos($phase) ) ) . q/ / . ( $sy + $r / 2 * ( -sin($phase) ) ); | |||||||||||||||||||||||||||||||||||||||||
| 484 | 13 | $d .= ", $sx\t$sy Z"; | |||||||||||||||||||||||||||||||||||||||||
| 485 | $moon->{highlight} = { | ||||||||||||||||||||||||||||||||||||||||||
| 486 | 13 | type => 'path', | |||||||||||||||||||||||||||||||||||||||||
| 487 | id => $id, | ||||||||||||||||||||||||||||||||||||||||||
| 488 | d => $d, | ||||||||||||||||||||||||||||||||||||||||||
| 489 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||
| 492 | $moon->{border} = { | ||||||||||||||||||||||||||||||||||||||||||
| 493 | 31 | id => "moon_border_$id", | |||||||||||||||||||||||||||||||||||||||||
| 494 | class => "outline$class", | ||||||||||||||||||||||||||||||||||||||||||
| 495 | cx => $x, | ||||||||||||||||||||||||||||||||||||||||||
| 496 | cy => ( $sy + $ey ) / 2, | ||||||||||||||||||||||||||||||||||||||||||
| 497 | r => $r, | ||||||||||||||||||||||||||||||||||||||||||
| 498 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||
| 500 | 31 | return $moon; | |||||||||||||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||
| 503 | 93 | ▶ | sub get_moon_phase { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_moon_phase: called CC=10 SCAR=24.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||
| 505 | 93 | my ( $self, $date ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||
| 507 | 93 | ▶ | if ( !blessed $date || !$date->isa('DateTime') ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($date) and $date->isa("DateTime")
MC/DC0%0/2
builtin::blessed($date) and $date->isa("DateTime")
builtin::blessed($date)
$date->isa("DateTime")
Truth table33%1/3
A and B
A= builtin::blessed($date)B= $date->isa("DateTime")
| |||||||||||||||||||||||||||||||||||||||||||
| 508 | 93 | $date = strptime('%F %T', "$date 20:00:00"); | |||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||
| 511 | 93 | ▶ | if ( !$date ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | carp 'Unable to create a date!'; | |||||||||||||||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||
| 515 | # check if we have a way to calculate the phase of the moon | ||||||||||||||||||||||||||||||||||||||||||
| 516 | 93 | ▶ | if ( !$self->{moon_phase} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 517 | 1 | my @packages = qw/Astro::Coord::ECI::Moon Astro::MoonPhase/; | |||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||
| 519 | PACKAGE: | ||||||||||||||||||||||||||||||||||||||||||
| 520 | 1 | for my $package (@packages) { | |||||||||||||||||||||||||||||||||||||||||
| 521 | 1 | my $package_file = $package; | |||||||||||||||||||||||||||||||||||||||||
| 522 | 1 | $package_file =~ s{::}{/}gxms; | |||||||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||||||||
| 524 | 1 | eval{ require $package_file . '.pm' }; ## no critic | |||||||||||||||||||||||||||||||||||||||||
| 525 | 1 | ▶ | if ( !$EVAL_ERROR ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 526 | 1 | $self->{moon_phase} = $package; | |||||||||||||||||||||||||||||||||||||||||
| 527 | 1 | last PACKAGE; | |||||||||||||||||||||||||||||||||||||||||
| 528 | } | ||||||||||||||||||||||||||||||||||||||||||
| 529 | } | ||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||
| 531 | # croak if there is no way to calculate the phase of the moon | ||||||||||||||||||||||||||||||||||||||||||
| 532 | 1 | ▶ | if ( !$self->{moon_phase} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | die "Cannot find any packages installed to calculate the moon phase\nTry installing one of:\ncpan " | |||||||||||||||||||||||||||||||||||||||||
| 534 | . join( "\ncpan ", @packages ) . "\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||||||||||||||||
| 536 | } | ||||||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||||||
| 538 | 93 | my $phase; | |||||||||||||||||||||||||||||||||||||||||
| 539 | 93 | ▶ | if ( $self->{moon_phase} eq 'Astro::Coord::ECI::Moon' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||
| 541 | # phase in radians | ||||||||||||||||||||||||||||||||||||||||||
| 542 | 62 | $phase = Astro::Coord::ECI::Moon->phase( $date->epoch() ); | |||||||||||||||||||||||||||||||||||||||||
| 543 | } | ||||||||||||||||||||||||||||||||||||||||||
| 544 | elsif ( $self->{moon_phase} eq 'Astro::MoonPhase' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||
| 546 | # phase in fraction of circle | ||||||||||||||||||||||||||||||||||||||||||
| 547 | 31 | ($phase) = Astro::MoonPhase::phase( $date->epoch() ); | |||||||||||||||||||||||||||||||||||||||||
| 548 | 31 | $phase *= 2 * pi; | |||||||||||||||||||||||||||||||||||||||||
| 549 | } | ||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||
| 551 | 93 | return $phase; | |||||||||||||||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||
| 554 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||
| 556 | __DATA__ | ||||||||||||||||||||||||||||||||||||||||||