| 1 | package Graphics::Primitive::Insets; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 9 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 9 | ▶ | use MooseX::Storage; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 9 | with 'Geometry::Primitive::Equal'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 9 | with 'MooseX::Clone'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 9 | with Storage (format => 'JSON', io => 'File'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 9 | ▶ | use Moose::Util::TypeConstraints; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | coerce 'Graphics::Primitive::Insets' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | => from 'ArrayRef' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | => via { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | ▶ | Graphics::Primitive::Insets->new( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | top => $_->[0], right => $_->[1], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | bottom => $_->[2], left => $_->[3] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 9 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | coerce 'Graphics::Primitive::Insets' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | => from 'Num' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | => via { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | Graphics::Primitive::Insets->new( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | top => $_, right => $_, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | bottom => $_, left => $_ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 9 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 9 | has 'top' => ( is => 'rw', isa => 'Num', default => 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 9 | has 'bottom' => ( is => 'rw', isa => 'Num', default => 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 9 | has 'left' => ( is => 'rw', isa => 'Num', default => 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 9 | has 'right' => ( is => 'rw', isa => 'Num', default => 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | sub as_array { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_array: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | return ($self->top, $self->right, $self->bottom, $self->left); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | sub equal_to { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 5 | ▶ | my ($self, $other) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
equal_to: called CC=4 SCAR=17.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 5 | ▶ | return ($self->top == $other->top) && ($self->bottom == $other->bottom) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition44%4/9
$self->top == $other->top && $self->bottom == $other->bottom && $self->left == $other->left && $self->right == $other->right
$self->top == $other->top and $self->bottom == $other->bottom and $self->left == $other->left
$self->top == $other->top and $self->bottom == $other->bottom
MC/DC25%1/4
$self->top == $other->top && $self->bottom == $other->bottom && $self->left == $other->left && $self->right == $other->right
$self->top == $other->top
$self->bottom == $other->bottom
$self->left == $other->left
$self->right == $other->right
Truth table40%2/5
A and B and C && D
A= $self->top == $other->topB= $self->bottom == $other->bottomC= $self->left == $other->leftD= $self->right == $other->right
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | && ($self->left == $other->left) && ($self->right == $other->right); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | sub width { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 2 | ▶ | my ($self, $width) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
width: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 2 | $self->top($width); $self->bottom($width); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 2 | $self->left($width); $self->right($width); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | sub zero { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
zero: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 1 | $self->width(0); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 9 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 9 | ▶ | no Moose; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 9 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | Graphics::Primitive::Insets - Space between things | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | Graphics::Primitive::Insets represents the amount of space that surrounds | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | something. This object can be used to represent either padding or margins | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | (in the CSS sense, one being inside the bounding box, the other being outside) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | use Graphics::Primitive::Insets; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | my $insets = Graphics::Primitive::Insets->new({ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | top => 5, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | bottom => 5, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | left => 5, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | right => 5 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | =head2 Constructor | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | =item I<new> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | Creates a new Graphics::Primitive::Insets. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | =head2 Instance Methods | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | =item I<as_array> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | Return these insets as an array in the form of top, right, bottom and left. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | =item I<bottom> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | Set/Get the inset from the bottom. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | =item I<equal_to> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | Determine if these Insets are equal to another. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | =item I<left> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | Set/Get the inset from the left. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | =item I<right> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | Set/Get the inset from the right. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | =item I<top> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | Set/Get the inset from the top. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | =item I<zero> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | Sets all the insets (top, left, bottom, right) to 0. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | Cory Watson, C<< <gphat@cpan.org> >> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | perl(1) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | =head1 COPYRIGHT & LICENSE | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | Copyright 2008-2010 by Cory G Watson. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||