line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Costume::Doublet; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
58906
|
use 5.008001; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
1981
|
|
4
|
1
|
|
|
1
|
|
16
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
5
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
178
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
require Exporter; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Items to export into callers namespace by default. Note: do not export |
12
|
|
|
|
|
|
|
# names by default without a very good reason. Use EXPORT_OK instead. |
13
|
|
|
|
|
|
|
# Do not simply export all your public functions/methods/constants. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# This allows declaration use Costume::Doublet ':all'; |
16
|
|
|
|
|
|
|
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK |
17
|
|
|
|
|
|
|
# will save memory. |
18
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw() ] ); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our @EXPORT_OK = qw(make_pattern); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our @EXPORT = qw( ); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
our $VERSION = '0.001'; |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
1
|
|
1094
|
use GD; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
our @messurments = qw ( chest waist back_length shoulder front_width back_width); |
28
|
|
|
|
|
|
|
# Preloaded methods go here. |
29
|
|
|
|
|
|
|
sub make_pattern |
30
|
|
|
|
|
|
|
{ |
31
|
|
|
|
|
|
|
my %args = (@_); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
#If metric convert to inches |
34
|
|
|
|
|
|
|
if ($args{'unit'} eq 'cm') |
35
|
|
|
|
|
|
|
{ |
36
|
|
|
|
|
|
|
foreach my $mes (@messurments) |
37
|
|
|
|
|
|
|
{ |
38
|
|
|
|
|
|
|
$args{$mes} = $args{$mes} * 2.54; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
## compute stuff |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# |
45
|
|
|
|
|
|
|
# all point names are in refrence to "Costume Technician's |
46
|
|
|
|
|
|
|
# Handbook" by Rosemary Ingham/Liz Covey See page 126- |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
my $waist_dart = &find_waist_dart($args{'chest'},$args{'waist'}); |
50
|
|
|
|
|
|
|
my $ab_height = $args{'back_length'}; |
51
|
|
|
|
|
|
|
my $ac_width = ($args{'chest'} / 2) + 0.5; |
52
|
|
|
|
|
|
|
my $ef_width = ($ac_width / 2); |
53
|
|
|
|
|
|
|
my $gh_height = ($ab_height / 4); |
54
|
|
|
|
|
|
|
my $ij_height = ($ab_height / 2); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
my $img = new GD::Image(800,800); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my $white = $img->colorAllocate(255,255,255); |
59
|
|
|
|
|
|
|
my $black = $img->colorAllocate(0,0,0); |
60
|
|
|
|
|
|
|
my $red = $img->colorAllocate(255,0,0); |
61
|
|
|
|
|
|
|
my $blue = $img->colorAllocate(0,0,255); |
62
|
|
|
|
|
|
|
my $green = $img->colorAllocate(0,255,0); |
63
|
|
|
|
|
|
|
## Draw Bounding box; |
64
|
|
|
|
|
|
|
&draw_grid($img); |
65
|
|
|
|
|
|
|
$img->rectangle (&make_point(0,0), |
66
|
|
|
|
|
|
|
&make_point($ac_width,$ab_height), |
67
|
|
|
|
|
|
|
$blue); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
$img->dashedLine(&make_point(0,$gh_height), |
70
|
|
|
|
|
|
|
&make_point($ac_width,$gh_height), |
71
|
|
|
|
|
|
|
$blue); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
$img->dashedLine(&make_point(0,$ij_height), |
74
|
|
|
|
|
|
|
&make_point($ac_width,$ij_height), |
75
|
|
|
|
|
|
|
$blue); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
$img->dashedLine(&make_point($ef_width,0), |
78
|
|
|
|
|
|
|
&make_point($ef_width,$ab_height), |
79
|
|
|
|
|
|
|
$blue); |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
my @k_point = &make_point(($ac_width - 3), -0.5); |
82
|
|
|
|
|
|
|
my @m_point = &make_point($ac_width,2.5); |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
## Draw the neck hole |
85
|
|
|
|
|
|
|
$img->arc($m_point[0],$k_point[1], |
86
|
|
|
|
|
|
|
(2 * ($m_point[0] - $k_point[0])), |
87
|
|
|
|
|
|
|
(2 * ($m_point[0] - $k_point[0])), |
88
|
|
|
|
|
|
|
90,180, |
89
|
|
|
|
|
|
|
$red); |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
$img->dashedLine(&make_point($ef_width,1.375), |
92
|
|
|
|
|
|
|
&make_point($ac_width,1.375), |
93
|
|
|
|
|
|
|
$blue); |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
my @n_point = &make_point(($ac_width - 3.0) - sqrt(($args{'shoulder'}** 2) - ( 0.5 + 1.375)**2), |
97
|
|
|
|
|
|
|
1.375); ## The sholder line takes some triginomitry |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
$img->line(@k_point,@n_point,$red); |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
my @p_point = &make_point(($ac_width - ($args{'front_width'} / 2)), |
103
|
|
|
|
|
|
|
$gh_height); |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
$img->line(@n_point,@p_point,$red); |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
my @o_point = &make_point($ef_width ,$ij_height); |
108
|
|
|
|
|
|
|
my @bs_point = &make_point($ef_width -1 ,$ij_height -1); |
109
|
|
|
|
|
|
|
my @q_point = &make_point(($ac_width - (($args{'waist'} *.25) + 6 +$waist_dart)), |
110
|
|
|
|
|
|
|
$ab_height); |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
my @ee_point = &make_point ((($args{'waist'} * .25)- 6 - $waist_dart), |
113
|
|
|
|
|
|
|
$ab_height); |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
$img->line(@bs_point,@q_point,$red); |
116
|
|
|
|
|
|
|
$img->line(@bs_point,@ee_point,$red); |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
##Back Nexk |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
my @zero_point = &make_point(0,0); |
121
|
|
|
|
|
|
|
my @aa_point = &make_point(2.5,-.5); |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
# $img->rectangle(&make_point(-2.5,-1), |
124
|
|
|
|
|
|
|
# &make_point(2.5,0), |
125
|
|
|
|
|
|
|
# $green); |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
$img->arc(&make_point(0,-0.5), |
128
|
|
|
|
|
|
|
(2 *($aa_point[0] - $zero_point[0])), |
129
|
|
|
|
|
|
|
(2 *($aa_point[1] - $zero_point[1])), |
130
|
|
|
|
|
|
|
270,360, |
131
|
|
|
|
|
|
|
$red); |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
## back Sholder |
135
|
|
|
|
|
|
|
my @bb_point = &make_point($args{'back_width'}/2, |
136
|
|
|
|
|
|
|
$gh_height); |
137
|
|
|
|
|
|
|
my @cc_point = &make_point( $args{'back_width'}/2, |
138
|
|
|
|
|
|
|
$gh_height -3); |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
my $bs_len = $args{'shoulder'} + 0.5; |
142
|
|
|
|
|
|
|
my $sholder_theta = atan2 (($gh_height-3), |
143
|
|
|
|
|
|
|
(($args{'back_width'} / 2) -2.5)); |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
my @dd_point = &make_point ((2.5 +($bs_len * cos($sholder_theta))), |
146
|
|
|
|
|
|
|
($bs_len * sin($sholder_theta)) - 0.5); |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
# $img->line(@aa_point,@cc_point,$red); |
149
|
|
|
|
|
|
|
# $img->line(@bb_point,@cc_point,$red); |
150
|
|
|
|
|
|
|
$img->line(@aa_point,@dd_point,$red); |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
my $poly = new GD::Polygon; |
154
|
|
|
|
|
|
|
$poly->addPt(@n_point); |
155
|
|
|
|
|
|
|
$poly->addPt(@p_point); |
156
|
|
|
|
|
|
|
$poly->addPt(@o_point); |
157
|
|
|
|
|
|
|
$poly->addPt(@bs_point); |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
$poly->addPt(@bb_point); |
160
|
|
|
|
|
|
|
$poly->addPt(@dd_point); |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
$img->polygon($poly,$green); |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
$img->line(@n_point,@dd_point,$white); |
165
|
|
|
|
|
|
|
## Add label |
166
|
|
|
|
|
|
|
my $date = `date +"%d %B %Y"`; |
167
|
|
|
|
|
|
|
chomp $date; |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
$img->string(gdSmallFont, |
170
|
|
|
|
|
|
|
&make_point ($ef_width+3,$ij_height-2), |
171
|
|
|
|
|
|
|
$args{'name'} , |
172
|
|
|
|
|
|
|
$red); |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
$img->string(gdSmallFont, |
176
|
|
|
|
|
|
|
&make_point ($ef_width+3,$ij_height-1), |
177
|
|
|
|
|
|
|
$date, |
178
|
|
|
|
|
|
|
$red); |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
$img->string(gdSmallFont, |
181
|
|
|
|
|
|
|
&make_point ($ef_width+-6,$ij_height-2), |
182
|
|
|
|
|
|
|
$args{'name'} , |
183
|
|
|
|
|
|
|
$red); |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
$img->string(gdSmallFont, |
187
|
|
|
|
|
|
|
&make_point ($ef_width+-6,$ij_height-1), |
188
|
|
|
|
|
|
|
$date, |
189
|
|
|
|
|
|
|
$red); |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
$img->string(gdLargeFont, |
192
|
|
|
|
|
|
|
&make_point ($ef_width+3,$ij_height+1), |
193
|
|
|
|
|
|
|
"FRONT", |
194
|
|
|
|
|
|
|
$red); |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
$img->string(gdLargeFont, |
197
|
|
|
|
|
|
|
&make_point ($ef_width-6,$ij_height+1), |
198
|
|
|
|
|
|
|
"BACK", |
199
|
|
|
|
|
|
|
$red); |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
## Print out the image |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
open (IMG,">$args{'output'}") or die "Can't open $args{'output'} $!"; |
204
|
|
|
|
|
|
|
binmode IMG; |
205
|
|
|
|
|
|
|
print IMG $img->png; |
206
|
|
|
|
|
|
|
close (IMG); |
207
|
|
|
|
|
|
|
} |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
sub make_point |
210
|
|
|
|
|
|
|
{ |
211
|
|
|
|
|
|
|
my ($x,$y) = @_; |
212
|
|
|
|
|
|
|
my $scale_factor = 25; |
213
|
|
|
|
|
|
|
my $shift_down = 100; |
214
|
|
|
|
|
|
|
my $shift_right = 100; |
215
|
|
|
|
|
|
|
my ($x_point,$y_point) = |
216
|
|
|
|
|
|
|
((($x * $scale_factor) + $shift_right), |
217
|
|
|
|
|
|
|
(($y * $scale_factor) + $shift_down)); |
218
|
|
|
|
|
|
|
# print STDERR "$x_point, $y_point\n"; |
219
|
|
|
|
|
|
|
return($x_point,$y_point); |
220
|
|
|
|
|
|
|
} |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
sub find_waist_dart |
223
|
|
|
|
|
|
|
{ |
224
|
|
|
|
|
|
|
my ($chest,$waist) = @_; |
225
|
|
|
|
|
|
|
my $diff = $chest - $waist; |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
return 0 if ($diff < 4.0); |
228
|
|
|
|
|
|
|
return 0.5 if ($diff < 5.5); |
229
|
|
|
|
|
|
|
return 0.75 if ($diff < 7.5); |
230
|
|
|
|
|
|
|
return 1.0 if ($diff < 9.5); |
231
|
|
|
|
|
|
|
return 1.25 if ($diff < 11.5); |
232
|
|
|
|
|
|
|
return 1.5; |
233
|
|
|
|
|
|
|
} |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
sub draw_grid |
236
|
|
|
|
|
|
|
{ |
237
|
|
|
|
|
|
|
my $img = shift; |
238
|
|
|
|
|
|
|
my $grey = $img->colorAllocate(192,192,192); |
239
|
|
|
|
|
|
|
my $red = $img->colorAllocate(255,0,0); |
240
|
|
|
|
|
|
|
my $x = -5; |
241
|
|
|
|
|
|
|
my $y = -5; |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
while ($x < 60) |
244
|
|
|
|
|
|
|
{ |
245
|
|
|
|
|
|
|
$y = -5; |
246
|
|
|
|
|
|
|
while ($y < 60) |
247
|
|
|
|
|
|
|
{ |
248
|
|
|
|
|
|
|
$img->rectangle(&make_point($x,$y), |
249
|
|
|
|
|
|
|
&make_point($x+1,$y+1), |
250
|
|
|
|
|
|
|
$grey); |
251
|
|
|
|
|
|
|
$y++; |
252
|
|
|
|
|
|
|
} |
253
|
|
|
|
|
|
|
$x++ |
254
|
|
|
|
|
|
|
} |
255
|
|
|
|
|
|
|
$img->string(gdSmallFont, |
256
|
|
|
|
|
|
|
&make_point (-3,-3), |
257
|
|
|
|
|
|
|
"boxes are 1 inch", |
258
|
|
|
|
|
|
|
$red); |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
} |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
1; |
263
|
|
|
|
|
|
|
__END__ |