line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Math::Geometry::Construction::Draw; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
7652
|
use 5.008008; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
32
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
322
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use Carp; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
C<Math::Geometry::Construction::Draw> - base class for drawing |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Version 0.022 |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=cut |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = '0.022'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
########################################################################### |
22
|
|
|
|
|
|
|
# # |
23
|
|
|
|
|
|
|
# Class Variables and Methods # |
24
|
|
|
|
|
|
|
# # |
25
|
|
|
|
|
|
|
########################################################################### |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
########################################################################### |
28
|
|
|
|
|
|
|
# # |
29
|
|
|
|
|
|
|
# Accessors # |
30
|
|
|
|
|
|
|
# # |
31
|
|
|
|
|
|
|
########################################################################### |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
has 'output' => (isa => 'Item', |
34
|
|
|
|
|
|
|
is => 'rw', |
35
|
|
|
|
|
|
|
writer => '_output'); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
has ['width', 'height'] => (isa => 'Str', |
38
|
|
|
|
|
|
|
is => 'ro', |
39
|
|
|
|
|
|
|
required => 1); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
has 'transform' => (isa => 'ArrayRef[Num]', |
42
|
|
|
|
|
|
|
is => 'ro', |
43
|
|
|
|
|
|
|
default => sub { [1, 0, 0, 1, 0, 0] }); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
########################################################################### |
47
|
|
|
|
|
|
|
# # |
48
|
|
|
|
|
|
|
# Generate Output # |
49
|
|
|
|
|
|
|
# # |
50
|
|
|
|
|
|
|
########################################################################### |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub is_flipped { |
53
|
|
|
|
|
|
|
my ($self) = @_; |
54
|
|
|
|
|
|
|
my $t = $self->transform; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
return($t->[0] * $t->[3] - $t->[1] * $t->[2] <= 0 ? 1 : 0); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub transform_coordinates { |
60
|
|
|
|
|
|
|
my ($self, $x, $y) = @_; |
61
|
|
|
|
|
|
|
my $t = $self->transform; |
62
|
|
|
|
|
|
|
my $split = qr/(.*?)(\s*[a-zA-Z]*)$/; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
my @x_parts = $x =~ $split; |
65
|
|
|
|
|
|
|
my @y_parts = $y =~ $split; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
my $xt = $t->[0] * $x_parts[0] + $t->[2] * $y_parts[0] + $t->[4]; |
68
|
|
|
|
|
|
|
my $yt = $t->[1] * $x_parts[0] + $t->[3] * $y_parts[0] + $t->[5]; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
return("$xt$x_parts[1]", "$yt$y_parts[1]"); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub transform_x_length { |
74
|
|
|
|
|
|
|
my ($self, $l) = @_; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
return(abs($l * $self->transform->[0])); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub transform_y_length { |
80
|
|
|
|
|
|
|
my ($self, $l) = @_; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
return(abs($l * $self->transform->[3])); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub line {} |
86
|
|
|
|
|
|
|
sub circle {} |
87
|
|
|
|
|
|
|
sub text {} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
__END__ |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=pod |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 SYNOPSIS |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 DESCRIPTION |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 INTERFACE |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head2 Public Attributes |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head2 Methods for Users |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head2 Methods for Subclass Developers |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head3 is_flipped |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Returns the sign of the transformation matrix. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head3 transform_coordinates |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head3 transform_x_length |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head3 transform_y_length |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head3 create_derived_point |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head3 as_svg |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head3 id_template |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 AUTHOR |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Lutz Gehlen, C<< <perl at lutzgehlen.de> >> |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Copyright 2011, 2013 Lutz Gehlen. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
138
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
139
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=cut |
145
|
|
|
|
|
|
|
|