| 1 | #_{ Encoding and name | ||||||||||
| 2 | =encoding utf8 | ||||||||||
| 3 | =head1 NAME | ||||||||||
| 4 | |||||||||||
| 5 | Grid::Layout::Area | ||||||||||
| 6 | |||||||||||
| 7 | =cut | ||||||||||
| 8 | #_} | ||||||||||
| 9 | package Grid::Layout::Area; | ||||||||||
| 10 | #_{ use … | ||||||||||
| 11 | 5 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 5 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 5 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | 5 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | #_} | ||||||||||
| 17 | 5 | our $VERSION = 0.01; | |||||||||
| 18 | #_{ Synopsis | ||||||||||
| 19 | |||||||||||
| 20 | =head1 SYNOPSIS | ||||||||||
| 21 | =cut | ||||||||||
| 22 | #_} | ||||||||||
| 23 | #_{ Description | ||||||||||
| 24 | |||||||||||
| 25 | =head1 DESCRIPTION | ||||||||||
| 26 | |||||||||||
| 27 | A C<< Grid::Layout::Area >> is bound by 2 different horizontal L<< Grid::Layout::Line >>s and | ||||||||||
| 28 | 2 different vertical L<< Grid::Layout::Line >>s. | ||||||||||
| 29 | |||||||||||
| 30 | Thus, it's I<logical size> is at least one L<< Grid::Layout::Cell >> and an exact integer multiple | ||||||||||
| 31 | of L<< Grid::Layout::Cell >>s. | ||||||||||
| 32 | |||||||||||
| 33 | =cut | ||||||||||
| 34 | #_} | ||||||||||
| 35 | #_{ Methods | ||||||||||
| 36 | #_{ POD | ||||||||||
| 37 | =head1 METHODS | ||||||||||
| 38 | =cut | ||||||||||
| 39 | #_} | ||||||||||
| 40 | 9 | ▶ | sub new { #_{ | ||||||||
|
Subroutine
new: called CC=9 SCAR=22.9
Pod
undocumented
| |||||||||||
| 41 | #_{ POD | ||||||||||
| 42 | =head2 new | ||||||||||
| 43 | |||||||||||
| 44 | |||||||||||
| 45 | =cut | ||||||||||
| 46 | #_} | ||||||||||
| 47 | |||||||||||
| 48 | 9 | my $class = shift; | |||||||||
| 49 | 9 | my $track_v_from = shift; | |||||||||
| 50 | 9 | my $track_h_from = shift; | |||||||||
| 51 | 9 | my $track_v_to = shift; | |||||||||
| 52 | 9 | my $track_h_to = shift; | |||||||||
| 53 | |||||||||||
| 54 | 9 | ▶ | croak 'track_v_from is not a Grid::Layout::Track' unless $track_v_from->isa('Grid::Layout::Track'); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 55 | 9 | ▶ | croak 'track_v_to is not a Grid::Layout::Track' unless $track_v_to ->isa('Grid::Layout::Track'); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 56 | 9 | ▶ | croak 'track_h_from is not a Grid::Layout::Track' unless $track_h_from->isa('Grid::Layout::Track'); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 57 | 9 | ▶ | croak 'track_h_to is not a Grid::Layout::Track' unless $track_h_to ->isa('Grid::Layout::Track'); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 58 | |||||||||||
| 59 | 9 | ▶ | croak 'track_v_from is not a vertical' unless $track_v_from->{V_or_H} eq 'V'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 60 | 9 | ▶ | croak 'track_v_to is not a vertical' unless $track_v_to ->{V_or_H} eq 'V'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 61 | 9 | ▶ | croak 'track_h_from is not a vertical' unless $track_h_from->{V_or_H} eq 'H'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 62 | 9 | ▶ | croak 'track_h_to is not a vertical' unless $track_h_to ->{V_or_H} eq 'H'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 63 | |||||||||||
| 64 | 9 | my $self = {}; | |||||||||
| 65 | |||||||||||
| 66 | 9 | $self->{track}{'V'}{from} = $track_v_from; | |||||||||
| 67 | 9 | $self->{track}{'V'}{to } = $track_v_to ; | |||||||||
| 68 | 9 | $self->{track}{'H'}{from} = $track_h_from; | |||||||||
| 69 | 9 | $self->{track}{'H'}{to } = $track_h_to ; | |||||||||
| 70 | |||||||||||
| 71 | 9 | bless $self, $class; | |||||||||
| 72 | |||||||||||
| 73 | 9 | return $self; | |||||||||
| 74 | |||||||||||
| 75 | } #_} | ||||||||||
| 76 | #_{ x/y_from/to | ||||||||||
| 77 | 48 | ▶ | sub x_from { #_{ | ||||||||
|
Subroutine
x_from: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 78 | #_{ POD | ||||||||||
| 79 | =head2 x_from | ||||||||||
| 80 | |||||||||||
| 81 | =cut | ||||||||||
| 82 | #_} | ||||||||||
| 83 | |||||||||||
| 84 | 48 | my $self = shift; | |||||||||
| 85 | |||||||||||
| 86 | 48 | return $self->{track}{V}{from}->{position}; | |||||||||
| 87 | } | ||||||||||
| 88 | #_} | ||||||||||
| 89 | 12 | ▶ | sub x_to { #_{ | ||||||||
|
Subroutine
x_to: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 90 | #_{ POD | ||||||||||
| 91 | =head2 x_to | ||||||||||
| 92 | |||||||||||
| 93 | =cut | ||||||||||
| 94 | #_} | ||||||||||
| 95 | |||||||||||
| 96 | 12 | my $self = shift; | |||||||||
| 97 | |||||||||||
| 98 | 12 | return $self->{track}{V}{to}->{position}; | |||||||||
| 99 | } | ||||||||||
| 100 | #_} | ||||||||||
| 101 | 31 | ▶ | sub y_from { #_{ | ||||||||
|
Subroutine
y_from: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 102 | #_{ POD | ||||||||||
| 103 | =head2 y_from | ||||||||||
| 104 | |||||||||||
| 105 | =cut | ||||||||||
| 106 | #_} | ||||||||||
| 107 | |||||||||||
| 108 | 31 | my $self = shift; | |||||||||
| 109 | |||||||||||
| 110 | 31 | return $self->{track}{H}{from}->{position}; | |||||||||
| 111 | } | ||||||||||
| 112 | #_} | ||||||||||
| 113 | 12 | ▶ | sub y_to { #_{ | ||||||||
|
Subroutine
y_to: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 114 | #_{ POD | ||||||||||
| 115 | =head2 y_to | ||||||||||
| 116 | |||||||||||
| 117 | =cut | ||||||||||
| 118 | #_} | ||||||||||
| 119 | |||||||||||
| 120 | 12 | my $self = shift; | |||||||||
| 121 | |||||||||||
| 122 | 12 | return $self->{track}{H}{to}->{position}; | |||||||||
| 123 | } | ||||||||||
| 124 | #_} | ||||||||||
| 125 | #_} | ||||||||||
| 126 | #_{ width/height | ||||||||||
| 127 | 10 | ▶ | sub width { #_{ | ||||||||
|
Subroutine
width: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 128 | #_{ POD | ||||||||||
| 129 | =head2 width | ||||||||||
| 130 | |||||||||||
| 131 | =cut | ||||||||||
| 132 | #_} | ||||||||||
| 133 | 10 | my $self = shift; | |||||||||
| 134 | 10 | return $self->x_to - $self->x_from+1; | |||||||||
| 135 | } #_} | ||||||||||
| 136 | 10 | ▶ | sub height { #_{ | ||||||||
|
Subroutine
height: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 137 | #_{ POD | ||||||||||
| 138 | =head2 height | ||||||||||
| 139 | |||||||||||
| 140 | =cut | ||||||||||
| 141 | #_} | ||||||||||
| 142 | 10 | my $self = shift; | |||||||||
| 143 | 10 | return $self->y_to - $self->y_from +1; | |||||||||
| 144 | } #_} | ||||||||||
| 145 | #_} | ||||||||||
| 146 | #_} | ||||||||||
| 147 | #_{ POD: Copyright | ||||||||||
| 148 | |||||||||||
| 149 | =head1 Copyright | ||||||||||
| 150 | |||||||||||
| 151 | Copyright © 2017 René Nyffenegger, Switzerland. All rights reserved. | ||||||||||
| 152 | This program is free software; you can redistribute it and/or modify it | ||||||||||
| 153 | under the terms of the the Artistic License (2.0). You may obtain a | ||||||||||
| 154 | copy of the full license at: L<http://www.perlfoundation.org/artistic_license_2_0> | ||||||||||
| 155 | |||||||||||
| 156 | =cut | ||||||||||
| 157 | |||||||||||
| 158 | #_} | ||||||||||
| 159 | |||||||||||
| 160 | 5 | 'tq84'; | |||||||||