| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package CairoX::CuttingLine; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
23710
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
31
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
586
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
CairoX::CuttingLine - draw cutting line to cairo surface |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 VERSION |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Version 0.05 |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
to use CairoX::CuttingLine to render cutting lines to a canvas: |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
use CairoX::CuttingLine; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
we need to provide L for L method new. |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $surf = Cairo::ImageSurface->create ('argb32', 200 , 200 ); |
|
28
|
|
|
|
|
|
|
my $cr = Cairo::Context->create ($surf); |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
set Cairo::Context object |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $page = CairoX::CuttingLine->new( $cr ); |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
or by cr accessor |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
$page->cr( $cr ); |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
$page->set( x => 10 , y => 10 ); |
|
39
|
|
|
|
|
|
|
$page->size( width => 100 , width => 120 ); |
|
40
|
|
|
|
|
|
|
$page->length( 10 ); |
|
41
|
|
|
|
|
|
|
$page->line_width( 3 ); |
|
42
|
|
|
|
|
|
|
$page->color( 1, 1, 1, 1 ); # for set_source_rgba |
|
43
|
|
|
|
|
|
|
$page->stroke(); |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
CairoX::CuttingLine draws cutting line like this: |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
| | |
|
50
|
|
|
|
|
|
|
-+ +- |
|
51
|
|
|
|
|
|
|
IMAGE |
|
52
|
|
|
|
|
|
|
-+ +- |
|
53
|
|
|
|
|
|
|
| | |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 FUNCTIONS |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub new { |
|
60
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
|
61
|
0
|
|
|
|
|
|
my $self = {}; |
|
62
|
0
|
|
|
|
|
|
bless $self , $class; |
|
63
|
0
|
|
|
|
|
|
$self->{cr} = shift; |
|
64
|
0
|
|
|
|
|
|
return $self; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub cr { |
|
68
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
69
|
0
|
0
|
|
|
|
|
$self->{cr} = shift if @_; |
|
70
|
0
|
|
|
|
|
|
$self->{cr}; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub set { |
|
74
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
75
|
0
|
0
|
|
|
|
|
$self->{p} = { @_ } if @_; |
|
76
|
0
|
|
|
|
|
|
return $self->{p}; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub length { |
|
80
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
81
|
0
|
0
|
|
|
|
|
$self->{length} = shift if @_; |
|
82
|
0
|
|
|
|
|
|
$self->{length}; |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub size { |
|
86
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
87
|
0
|
0
|
|
|
|
|
$self->{size} = { @_ } if @_; |
|
88
|
0
|
|
|
|
|
|
$self->{size}; |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub color { |
|
92
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
93
|
0
|
0
|
|
|
|
|
$self->{color} = [ @_ ] if @_; |
|
94
|
0
|
|
|
|
|
|
$self->{color}; |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub line_width { |
|
98
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
99
|
0
|
0
|
|
|
|
|
$self->{line_width} = shift if @_; |
|
100
|
0
|
|
|
|
|
|
$self->{line_width}; |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub stroke { |
|
104
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
105
|
0
|
|
|
|
|
|
my $cr = $self->{cr}; |
|
106
|
0
|
|
|
|
|
|
$cr->save; |
|
107
|
|
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
|
my $color = $self->{color}; |
|
109
|
0
|
|
0
|
|
|
|
$color ||= [1,1,1,1]; |
|
110
|
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
$cr->set_source_rgba( @$color ); |
|
112
|
0
|
|
|
|
|
|
$cr->set_line_width( $self->line_width ); |
|
113
|
0
|
|
|
|
|
|
my $pos = $self->set; |
|
114
|
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
my $s = $self->size; |
|
116
|
0
|
|
|
|
|
|
my $line_len = $self->length; |
|
117
|
|
|
|
|
|
|
|
|
118
|
0
|
|
|
|
|
|
for my $p ( 0 .. 3 ) { |
|
119
|
|
|
|
|
|
|
|
|
120
|
0
|
|
|
|
|
|
my ( $c_x, $c_y ) = ( $pos->{x}, $pos->{y} ); |
|
121
|
0
|
0
|
|
|
|
|
if( $p & 1 ) { |
|
122
|
0
|
|
|
|
|
|
$c_x += $s->{width}; |
|
123
|
|
|
|
|
|
|
} |
|
124
|
0
|
0
|
|
|
|
|
if( $p & 2 ) { |
|
125
|
0
|
|
|
|
|
|
$c_y += $s->{height}; |
|
126
|
|
|
|
|
|
|
} |
|
127
|
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
$cr->move_to( $c_x , $c_y ); |
|
129
|
0
|
0
|
|
|
|
|
$cr->line_to( |
|
130
|
|
|
|
|
|
|
$c_x + ( $p & 1 ? $line_len : -$line_len ), |
|
131
|
|
|
|
|
|
|
$c_y |
|
132
|
|
|
|
|
|
|
); |
|
133
|
|
|
|
|
|
|
|
|
134
|
0
|
|
|
|
|
|
$cr->move_to( $c_x , $c_y ); |
|
135
|
0
|
0
|
|
|
|
|
$cr->line_to( |
|
136
|
|
|
|
|
|
|
$c_x, |
|
137
|
|
|
|
|
|
|
$c_y + ( $p & 2 ? $line_len : -$line_len ), |
|
138
|
|
|
|
|
|
|
); |
|
139
|
0
|
|
|
|
|
|
$cr->stroke(); |
|
140
|
|
|
|
|
|
|
} |
|
141
|
0
|
|
|
|
|
|
$cr->restore; |
|
142
|
|
|
|
|
|
|
} |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 AUTHOR |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Cornelius, C<< >> |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 BUGS |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
|
153
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
|
154
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 SUPPORT |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
perldoc CairoX::CuttingLine |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
You can also look for information at: |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=over 4 |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
L |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
L |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
L |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=item * Search CPAN |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
L |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=back |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
Copyright 2009 Cornelius, all rights reserved. |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
194
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=cut |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
1; # End of CairoX::CuttingLine |