line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Graphics::Primitive::Insets; |
2
|
1
|
|
|
1
|
|
24740
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
use MooseX::Storage; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
with 'Geometry::Primitive::Equal'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
with 'MooseX::Clone'; |
8
|
|
|
|
|
|
|
with Storage (format => 'JSON', io => 'File'); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use Moose::Util::TypeConstraints; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
coerce 'Graphics::Primitive::Insets' |
13
|
|
|
|
|
|
|
=> from 'ArrayRef' |
14
|
|
|
|
|
|
|
=> via { |
15
|
|
|
|
|
|
|
Graphics::Primitive::Insets->new( |
16
|
|
|
|
|
|
|
top => $_->[0], right => $_->[1], |
17
|
|
|
|
|
|
|
bottom => $_->[2], left => $_->[3] |
18
|
|
|
|
|
|
|
) |
19
|
|
|
|
|
|
|
}; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
coerce 'Graphics::Primitive::Insets' |
22
|
|
|
|
|
|
|
=> from 'Num' |
23
|
|
|
|
|
|
|
=> via { |
24
|
|
|
|
|
|
|
Graphics::Primitive::Insets->new( |
25
|
|
|
|
|
|
|
top => $_, right => $_, |
26
|
|
|
|
|
|
|
bottom => $_, left => $_ |
27
|
|
|
|
|
|
|
) |
28
|
|
|
|
|
|
|
}; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has 'top' => ( is => 'rw', isa => 'Num', default => 0 ); |
31
|
|
|
|
|
|
|
has 'bottom' => ( is => 'rw', isa => 'Num', default => 0 ); |
32
|
|
|
|
|
|
|
has 'left' => ( is => 'rw', isa => 'Num', default => 0 ); |
33
|
|
|
|
|
|
|
has 'right' => ( is => 'rw', isa => 'Num', default => 0 ); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub as_array { |
36
|
|
|
|
|
|
|
my ($self) = @_; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
return ($self->top, $self->right, $self->bottom, $self->left); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub equal_to { |
42
|
|
|
|
|
|
|
my ($self, $other) = @_; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
return ($self->top == $other->top) && ($self->bottom == $other->bottom) |
45
|
|
|
|
|
|
|
&& ($self->left == $other->left) && ($self->right == $other->right); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub width { |
49
|
|
|
|
|
|
|
my ($self, $width) = @_; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
$self->top($width); $self->bottom($width); |
52
|
|
|
|
|
|
|
$self->left($width); $self->right($width); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub zero { |
56
|
|
|
|
|
|
|
my ($self) = @_; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
$self->width(0); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
no Moose; |
64
|
|
|
|
|
|
|
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. |