line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Geometry::Primitive::Bezier; |
2
|
1
|
|
|
1
|
|
4229
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
use MooseX::Storage; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
with qw(Geometry::Primitive::Shape MooseX::Clone MooseX::Storage::Deferred); |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use overload ('""' => 'to_string'); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Geometry::Primitive::Point; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has 'control1' => ( |
12
|
|
|
|
|
|
|
is => 'rw', |
13
|
|
|
|
|
|
|
isa => 'Geometry::Primitive::Point', |
14
|
|
|
|
|
|
|
required => 1, |
15
|
|
|
|
|
|
|
coerce => 1 |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
has 'control2' => ( |
18
|
|
|
|
|
|
|
is => 'rw', |
19
|
|
|
|
|
|
|
isa => 'Geometry::Primitive::Point', |
20
|
|
|
|
|
|
|
required => 1, |
21
|
|
|
|
|
|
|
coerce => 1 |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
has 'end' => ( |
24
|
|
|
|
|
|
|
is => 'rw', |
25
|
|
|
|
|
|
|
isa => 'Geometry::Primitive::Point', |
26
|
|
|
|
|
|
|
required => 1, |
27
|
|
|
|
|
|
|
coerce => 1 |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
has 'start' => ( |
30
|
|
|
|
|
|
|
is => 'rw', |
31
|
|
|
|
|
|
|
isa => 'Geometry::Primitive::Point', |
32
|
|
|
|
|
|
|
required => 1, |
33
|
|
|
|
|
|
|
coerce => 1 |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub scale { |
37
|
|
|
|
|
|
|
my ($self, $amount) = @_; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
$self->start->x($self->start->x * $amount); |
40
|
|
|
|
|
|
|
$self->start->y($self->start->y * $amount); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
$self->end->x($self->end->x * $amount); |
43
|
|
|
|
|
|
|
$self->end->y($self->end->y * $amount); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
$self->control1->x($self->control1->x * $amount); |
46
|
|
|
|
|
|
|
$self->control1->y($self->control1->y * $amount); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
$self->control2->x($self->control2->x * $amount); |
49
|
|
|
|
|
|
|
$self->control2->y($self->control2->y * $amount); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub point_end { |
53
|
|
|
|
|
|
|
my ($self) = @_; return $self->end; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub point_start { |
57
|
|
|
|
|
|
|
my ($self) = @_; return $self->start; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub to_string { |
62
|
|
|
|
|
|
|
my ($self) = @_; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
return $self->start->to_string.' - '.$self->control1->to_string |
65
|
|
|
|
|
|
|
.' = '.$self->control2->to_string.' = '.$self->end->to_string; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
no Moose; |
71
|
|
|
|
|
|
|
1; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
__END__ |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=encoding UTF-8 |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 NAME |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Geometry::Primitive::Bezier - Cubic Bézier Curve |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 DESCRIPTION |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Geometry::Primitive::Bezier represents a cubic Bézier curve. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 SYNOPSIS |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
use Geometry::Primitive::Bezier; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
my $line = Geometry::Primitive::Bezier->new( |
90
|
|
|
|
|
|
|
start => $point1, |
91
|
|
|
|
|
|
|
control1 => $point2, |
92
|
|
|
|
|
|
|
control2 => $point3, |
93
|
|
|
|
|
|
|
end => $point4 |
94
|
|
|
|
|
|
|
); |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head2 control1 |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Set/Get the first control point of the curve. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head2 control2 |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Set/Get the second control point of the curve. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 end |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Set/Get the end point of the curve. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head2 start |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Set/Get the start point of the line. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 METHODS |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 new |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Creates a new Geometry::Primitive::Bezier |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head2 grow |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Does nothing, as I'm not sure how. Patches or hints welcome. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head2 point_end |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Get the end point. Provided for Shape role. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head2 point_start |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Get the start point. Provided for Shape role. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head2 scale |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Scales this curve by the amount provided. Multiplies each coordinate by the |
135
|
|
|
|
|
|
|
amount. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head2 to_string |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Guess! |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 AUTHOR |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Cory Watson <gphat@cpan.org> |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
You can redistribute and/or modify this code under the same terms as Perl |
148
|
|
|
|
|
|
|
itself. |