line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
package Acme::IRC::Art; |
3
|
7
|
|
|
7
|
|
182951
|
use strict; |
|
7
|
|
|
|
|
20
|
|
|
7
|
|
|
|
|
413
|
|
4
|
7
|
|
|
7
|
|
40
|
use Carp; |
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
753
|
|
5
|
7
|
|
|
7
|
|
67
|
no warnings; |
|
7
|
|
|
|
|
19
|
|
|
7
|
|
|
|
|
321
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
BEGIN { |
8
|
7
|
|
|
7
|
|
45
|
use Exporter (); |
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
163
|
|
9
|
7
|
|
|
7
|
|
36
|
use vars qw ($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); |
|
7
|
|
|
|
|
11
|
|
|
7
|
|
|
|
|
953
|
|
10
|
7
|
|
|
7
|
|
15
|
$VERSION = 0.2; |
11
|
7
|
|
|
|
|
113
|
@ISA = qw (Exporter); |
12
|
|
|
|
|
|
|
#Give a hoot don't pollute, do not export more than needed by default |
13
|
7
|
|
|
|
|
19
|
@EXPORT = qw (); |
14
|
7
|
|
|
|
|
14
|
@EXPORT_OK = qw (); |
15
|
7
|
|
|
|
|
2570
|
%EXPORT_TAGS = (); |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 NOM |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Acme::IRC::Art - |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 SYNOPSIS |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
use Acme::IRC::Art; |
26
|
|
|
|
|
|
|
use NET::IRC; |
27
|
|
|
|
|
|
|
... |
28
|
|
|
|
|
|
|
définition d'un connexion avec Net::IRC (voir la documentation de NET::IRC) |
29
|
|
|
|
|
|
|
... |
30
|
|
|
|
|
|
|
my $art = Art->new(5,5); |
31
|
|
|
|
|
|
|
$art->rectangle(0,0,4,4,2); |
32
|
|
|
|
|
|
|
for ($art->result) { |
33
|
|
|
|
|
|
|
$connection_irc->privmsg("#channel",$_); |
34
|
|
|
|
|
|
|
select(undef,undef,undef,0.5); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 DESCRIPTION |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Acme::IRC::Art est un module qui vous permet de faire des jolis dessins sur l'irc comme si vous utilisiez une librairie |
41
|
|
|
|
|
|
|
graphique très basique, il n'a pas était conçut pour faire de l'ascii art ( faire automatiquement des |
42
|
|
|
|
|
|
|
dessins avec les caractères acsii), il se contente de manipuler des couleurs et du texte. |
43
|
|
|
|
|
|
|
Vous pouvez l'utiliser avec n'importe quel module qui fournis un client irc (eg Net::IRC) ou dans des script perl pour des client IRC. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 UTILISATION |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=over |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=item new |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
D'abord il vous faut en premier lieu appeler le constructeur qui se nome new, il se contente de creer un canevas vide sur lequel vous allez travailler, |
54
|
|
|
|
|
|
|
vous pouvez spécifier sa hauteur et sa largeur, le canevas est remplis d'espace par défaut. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my $art->new($largeur,$hauteur); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Une règle à ne pas oublier c'est de définir votre dessin dans l'ordre auquel les éléments doivent apparaître |
62
|
|
|
|
|
|
|
si par exemple vous definissez un texte puis que vous dessinez un rectangle dessus le texte sera effacé |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub new { |
69
|
8
|
|
|
8
|
1
|
92
|
my ($class, $largeur, $hauteur) = @_; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
#gestion d'erreur |
72
|
8
|
|
|
|
|
21
|
my $syntaxe = 'Syntaxe correcte : $deco = Art->new(largeur, hauteur)'; |
73
|
8
|
50
|
|
|
|
39
|
croak("Les arguments de la fonction \'new\' de Art.pm sont: la largeur et la hauteur du canevas |
74
|
|
|
|
|
|
|
$syntaxe") if @_!=3; |
75
|
8
|
50
|
33
|
|
|
113
|
croak("Largeur et hauteur doivent être des nombres |
76
|
|
|
|
|
|
|
$syntaxe") if ($largeur!~/^\d+$/ or $hauteur!~/^\d+$/); |
77
|
8
|
50
|
33
|
|
|
70
|
croak("la largeur ou la hauteur ne sont pas des nombre |
78
|
|
|
|
|
|
|
$syntaxe") if ($largeur!~/\d/ or $hauteur!~/\d/); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
8
|
50
|
|
|
|
34
|
$hauteur-- and $largeur--; |
82
|
8
|
|
|
|
|
16
|
my @canevas; |
83
|
8
|
|
|
|
|
36
|
$#canevas = $hauteur; |
84
|
|
|
|
|
|
|
#fill with spaces |
85
|
8
|
|
|
|
|
27
|
foreach my $temp (0..$hauteur) { |
86
|
36
|
|
|
|
|
51
|
foreach my $temp2 (0..$largeur) { |
87
|
173
|
|
|
|
|
290
|
$canevas[$temp][$temp2] = " "; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
} |
90
|
8
|
|
|
|
|
20
|
my $self = {}; |
91
|
8
|
|
|
|
|
33
|
bless ($self,$class); |
92
|
8
|
|
|
|
|
75
|
$self->{canevas} = [@canevas]; |
93
|
8
|
|
|
|
|
47
|
return $self; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=pod |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=item result |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Quand vous avez finis de définir votre dessin avec les méthodes qui sont décrite par la suite, appeler |
102
|
|
|
|
|
|
|
la methode C qui ne prend aucun arguments et qui retourne un tableau qui contient chaque ligne |
103
|
|
|
|
|
|
|
de messages à envoyer pour afficher votre dessin. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=cut |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub result { |
109
|
29
|
|
|
29
|
1
|
2041
|
my ($this) = shift; |
110
|
7
|
|
|
7
|
|
10899
|
use Data::Dumper; |
|
7
|
|
|
|
|
79361
|
|
|
7
|
|
|
|
|
12626
|
|
111
|
29
|
|
|
|
|
41
|
return map {join '',@{$_}} @{$this->{canevas}}; |
|
97
|
|
|
|
|
96
|
|
|
97
|
|
|
|
|
438
|
|
|
29
|
|
|
|
|
68
|
|
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 Methodes |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Voici la liste des méthodes avec lesquelles vous allez pouvoir dessiner |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=over |
121
|
|
|
|
|
|
|
=item pixel |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
La méthode 'pixel' pour afficher ou non un pixel , vous devez spécifier sa position et sa couleur |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
$art->pixel($x,$y,$couleur,$on); |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
$on est une valeur bouléenn pour dire d'afficher ou d'effacer le pixel (-1 pour effacer). |
128
|
|
|
|
|
|
|
$on est vraie par défaut vous pouvez utiliser la synthaxe suivante |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
$art->pixel($x,$y,$couleur); |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Une dernière chose : le $x et $y peuvent être des références vers un tableau, mais attention les coordonnées en |
133
|
|
|
|
|
|
|
x et en y doivent correspondent une à une, exemple pour remplir la diagional d'un carré de 3 sur 3 |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
$art->pixel([0,1,2],[0,1,2],5); |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=cut |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub pixel { |
142
|
254
|
|
|
254
|
0
|
393
|
my ($this, $x, $y, $color, $on) = @_; |
143
|
254
|
|
|
|
|
265
|
my @canevas = @{$this->{canevas}}; |
|
254
|
|
|
|
|
627
|
|
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
#gestion d'erreur |
146
|
254
|
|
|
|
|
354
|
my $syntaxe = '$deco->pixel( position x , position y , couleur , [on])'; |
147
|
254
|
50
|
33
|
|
|
1062
|
croak("Les arguments de \'pixel\' sont : la position en x , la position en y , la couleur et l'état du pixel |
148
|
|
|
|
|
|
|
$syntaxe") if @_<4 or @_>5; |
149
|
254
|
50
|
66
|
|
|
581
|
croak("Les tableaux des position x et y ne sont pas de la même taille ! |
|
|
|
66
|
|
|
|
|
150
|
|
|
|
|
|
|
$syntaxe") if (ref $y and ref $x and @$x != @$y); |
151
|
254
|
50
|
66
|
|
|
2155
|
croak("l'un d'un arguments de position n'est pas compatible avec l'autre |
|
|
|
66
|
|
|
|
|
|
|
|
33
|
|
|
|
|
152
|
|
|
|
|
|
|
$syntaxe") if (ref $y and !ref $x or ref $x and !ref $y); |
153
|
254
|
50
|
66
|
|
|
1857
|
croak("Vous etes sortit du canevas définit") if ((!ref $x and !ref $y ) and ($y>$#canevas or $x>(@{$canevas[0]}-1))); |
|
|
|
33
|
|
|
|
|
|
|
|
66
|
|
|
|
|
154
|
|
|
|
|
|
|
|
155
|
254
|
|
|
|
|
339
|
my (@y, @x); |
156
|
254
|
100
|
|
|
|
1000
|
if (ref $y) { |
157
|
2
|
|
|
|
|
5
|
@x = @$x; |
158
|
2
|
|
|
|
|
4
|
@y = @$y; |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
else { |
161
|
252
|
|
|
|
|
329
|
$x[0] = $x; |
162
|
252
|
|
|
|
|
314
|
$y[0] = $y; |
163
|
252
|
|
|
|
|
515
|
$#y = 0; |
164
|
|
|
|
|
|
|
} |
165
|
254
|
100
|
|
|
|
510
|
$on = 0 unless defined $on; |
166
|
254
|
|
|
|
|
523
|
for (0..$#y) { |
167
|
258
|
100
|
|
|
|
408
|
if ($on >= 0) { |
168
|
129
|
|
|
|
|
460
|
$canevas[$y[$_]][$x[$_]] = "\003$color,$color \003"; |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
else { |
171
|
129
|
|
|
|
|
401
|
$canevas[$y[$_]][$x[$_]] = " "; |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
} |
174
|
254
|
|
|
|
|
1279
|
$this->{canevas} = [@canevas]; |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=item text |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
La méthode 'text' permet d'afficher du texte à partir d'une position donnée, la syntaxe est : |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
$art->text($texte,$position_x, $position_y,[$mise_en_forme],[$couleur_fond]); |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
plusieurs mise en forme de texte sont disponible |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
-"b" : met le texte en gras |
187
|
|
|
|
|
|
|
-un nombre met le texte à la couleur correspondante |
188
|
|
|
|
|
|
|
-"b".un nombre met le texte en gras avec une couleur |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
exemple: |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
$art->text("Bonjour !",2,0,"b5",2); |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
Celà mettra le "B" au pixel de coordonnée 2,0 , les autres lettres seront placées à la suite, |
195
|
|
|
|
|
|
|
par exemple le premier "o" aura comme coordonnée 3,0. Le texte sera en rouge foncé avec du gras ("b5") |
196
|
|
|
|
|
|
|
sur fond bleu. |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
Expérimentale : |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
$art->text($text,$x,$y,\@mise_en_forme,[\@fond]); |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
Soyez prudent car aucun vérification n'est faite le la validité des arguments dans ce cas là |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=cut |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
sub text { |
209
|
12
|
|
|
12
|
1
|
33
|
my ($this, $text, $x, $y, $bolt, $fond) = @_; |
210
|
12
|
|
|
|
|
15
|
my @canevas = @{$this->{canevas}}; |
|
12
|
|
|
|
|
31
|
|
211
|
|
|
|
|
|
|
|
212
|
12
|
100
|
|
|
|
29
|
$bolt = 0 unless defined $bolt; |
213
|
12
|
100
|
|
|
|
25
|
$fond = 0 unless defined $fond; |
214
|
|
|
|
|
|
|
#gestion d'erreur |
215
|
12
|
|
|
|
|
18
|
my $syntaxe = 'Syntaxe correcte : $deco->text($texte,$positionx,$positiony,[$mise_en_forme],[$fond])'; |
216
|
|
|
|
|
|
|
|
217
|
12
|
50
|
33
|
|
|
62
|
croak("les arguments de \'text\' sont le texte, la position x de la première lettre,i". |
218
|
|
|
|
|
|
|
" la position x de la permière lettre, sa mise en forme, [le fond de couleur du texte] |
219
|
|
|
|
|
|
|
$syntaxe") if (@_ > 6 or @_ < 4); |
220
|
|
|
|
|
|
|
|
221
|
12
|
50
|
33
|
|
|
113
|
croak("Mise en forme : $bolt incorrecte regardez la documentation pour avoir des informations sur la mise en forme") if (!ref $bolt and (length($bolt) > 3 or $bolt !~ /\d/ and $bolt !~ /b/) and @_ == 5); |
|
|
|
66
|
|
|
|
|
|
|
|
33
|
|
|
|
|
222
|
|
|
|
|
|
|
|
223
|
12
|
50
|
33
|
|
|
694
|
croak("Un des arguments qui devrai être un nombre de l'est pas |
224
|
|
|
|
|
|
|
$syntaxe") if ($x !~ /\d/ or $y !~ /\d/); |
225
|
|
|
|
|
|
|
|
226
|
12
|
50
|
66
|
|
|
56
|
croak("la valeur de fond spécifié est trop grande") if !ref $fond and $fond > 15; |
227
|
12
|
50
|
66
|
|
|
61
|
croak("la couleur de mise en forme est trop grande") if !ref $bolt and $bolt > 15; |
228
|
12
|
50
|
33
|
|
|
42
|
croak("Vous etes sortit du canevas définit") if ($y > $#canevas or $x > (@{$canevas[0]}-1)); |
|
12
|
|
|
|
|
44
|
|
229
|
|
|
|
|
|
|
|
230
|
12
|
100
|
|
|
|
28
|
my $a_bolt = $bolt if ref $bolt; |
231
|
12
|
100
|
|
|
|
23
|
my $a_fond = $fond if ref $fond; |
232
|
12
|
|
|
|
|
49
|
my @lettre = split '',$text; |
233
|
12
|
|
|
|
|
19
|
my $color; |
234
|
12
|
|
|
|
|
25
|
foreach my $position (0..$#lettre) { |
235
|
53
|
100
|
|
|
|
102
|
$bolt = $a_bolt->[$position] if $a_bolt; |
236
|
53
|
100
|
|
|
|
114
|
$fond = $a_fond->[$position] if $a_fond; |
237
|
53
|
|
|
|
|
60
|
my $v; |
238
|
53
|
|
|
|
|
62
|
my $fond2 = $fond; |
239
|
53
|
|
|
|
|
105
|
my $pixel = \$canevas[$y][$x+$position]; |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
# on redéfinis le fond au besoin |
242
|
53
|
100
|
|
|
|
131
|
$this->pixel($x + $position, $y, $2) if $$pixel =~ /\003(\d|),(\d)/; |
243
|
53
|
|
100
|
|
|
227
|
$fond2 ||= $2; |
244
|
53
|
100
|
100
|
|
|
172
|
$v = ',' if $fond or $$pixel ne " "; |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
# on place enfin la lettre |
247
|
53
|
100
|
|
|
|
122
|
$$pixel=~s/\s/\002$lettre[$position]\002/ if $bolt eq 'b'; |
248
|
53
|
100
|
|
|
|
182
|
if (($color) = ($bolt =~ /b(\d+)/)) { #bolt with color |
249
|
20
|
50
|
|
|
|
45
|
($fond2, $color, $lettre[$position]) = correction($fond2, $color, $lettre[$position]) and |
250
|
|
|
|
|
|
|
$$pixel = "\003${color}${v}${fond2}\002$lettre[$position]\002\003"; |
251
|
|
|
|
|
|
|
} |
252
|
53
|
100
|
|
|
|
225
|
if (($color) = ($bolt =~ /^(\d+)/)) { #only color |
253
|
29
|
50
|
|
|
|
63
|
($fond2, $color, $lettre[$position]) = correction($fond2, $color, $lettre[$position]) and |
254
|
|
|
|
|
|
|
$$pixel = "\003${color}${v}${fond2}$lettre[$position]\003"; |
255
|
|
|
|
|
|
|
} |
256
|
53
|
50
|
66
|
|
|
139
|
if (!$bolt and !$fond) { #euh |
257
|
9
|
50
|
|
|
|
20
|
($fond2, $color, $lettre[$position]) = correction($fond2, $color, $lettre[$position]) and |
258
|
|
|
|
|
|
|
$$pixel = "\003${v}${fond2}$lettre[$position]\003"; |
259
|
|
|
|
|
|
|
} |
260
|
53
|
50
|
66
|
|
|
168
|
if (!$bolt and !$fond and !$fond2) { #just text |
|
|
|
33
|
|
|
|
|
261
|
9
|
50
|
|
|
|
16
|
($fond2, $color, $lettre[$position]) = correction($fond2, $color, $lettre[$position]) and |
262
|
|
|
|
|
|
|
$$pixel = $lettre[$position]; |
263
|
|
|
|
|
|
|
} |
264
|
|
|
|
|
|
|
sub correction { |
265
|
|
|
|
|
|
|
#sub qui corrige au besoin pour pouvoir faire aparaître les chiffres |
266
|
67
|
100
|
100
|
67
|
0
|
269
|
$_[0] = "0$_[0]" if $_[0] =~ /^\d$/ and $_[2] =~ /^\d$/; |
267
|
67
|
100
|
100
|
|
|
364
|
$_[1] = "0$_[1]" if $_[1] =~ /^\d$/ and $_[2] =~ /^\d$/; |
268
|
67
|
|
|
|
|
427
|
return @_; |
269
|
|
|
|
|
|
|
} |
270
|
|
|
|
|
|
|
} |
271
|
12
|
|
|
|
|
61
|
$this->{canevas} = [@canevas]; |
272
|
|
|
|
|
|
|
} |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
=item rectangle |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
La méthode rectangle permet de faire facilement des rectangles mais aussi des lignes |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
La syntaxe est la suivante : |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
$art->rectangle($position_x1,$position_y1,$position_x2,$position_y2,$couleur,[$on]); |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
x1 et y1 représentent les coordonnées du pixel au coin en haut à gauche, et x2 et y2 celle du coin en bas à droite |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
=back |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
=cut |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
sub rectangle { |
291
|
17
|
|
|
17
|
1
|
56
|
my ($this, $x1, $y1, $x2, $y2, $color, $on) = @_; |
292
|
17
|
|
|
|
|
42
|
foreach my $t1 ($y1..$y2) { |
293
|
43
|
|
|
|
|
75
|
foreach my $t2 ($x1..$x2) { |
294
|
239
|
|
|
|
|
523
|
$this->pixel($t2, $t1, $color, $on); |
295
|
|
|
|
|
|
|
} |
296
|
|
|
|
|
|
|
} |
297
|
|
|
|
|
|
|
} |
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
=item save |
300
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
La méthode save permet de sauvegarder dans un fichier l'image obtenus pour la recharger par la suite avec |
302
|
|
|
|
|
|
|
la méthode load par exemple. C'est un simple fichier avec le texte ascii nécessaire pour l'irc. |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
La syntaxe est la suivante : |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
$art->save($path_to_file); |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
path_to_file est évidement le chemin vers le fichier |
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
=cut |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
sub save { |
313
|
2
|
|
|
2
|
1
|
15
|
my ($this, $fname) = @_; |
314
|
2
|
|
|
|
|
3
|
my @canevas = @{$this->{canevas}}; |
|
2
|
|
|
|
|
8
|
|
315
|
|
|
|
|
|
|
|
316
|
2
|
|
|
|
|
27
|
my $syntax = 'Syntax : $art->save($file_name)'; |
317
|
2
|
50
|
|
|
|
8
|
croak("missing argument : $syntax") if ! defined $fname; |
318
|
|
|
|
|
|
|
|
319
|
2
|
50
|
|
|
|
307
|
open FILE, ">", $fname or croak "Error opening $fname with write permision : $!"; |
320
|
2
|
|
|
|
|
6
|
foreach my $t (@canevas) { |
321
|
10
|
|
|
|
|
38
|
print FILE join('', @$t), "\n"; |
322
|
|
|
|
|
|
|
} |
323
|
2
|
|
|
|
|
214
|
close FILE; |
324
|
|
|
|
|
|
|
} |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
=item load |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
La méthode load permet de charger des fichiers d'image au format utilisé par la méthode save. |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
La syntaxe est la suivante : |
331
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
$art->load($path_to_file) |
333
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
path_to_file est toujours le chemin vers le fichier |
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
=cut |
337
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
sub load { |
339
|
1
|
|
|
1
|
1
|
7
|
my ($this, $fname) = @_; |
340
|
1
|
|
|
|
|
3
|
my @canevas = @{$this->{canevas}}; |
|
1
|
|
|
|
|
6
|
|
341
|
|
|
|
|
|
|
|
342
|
1
|
|
|
|
|
3
|
my $syntax = 'Syntax :$art->load($file_name)'; |
343
|
1
|
50
|
|
|
|
5
|
croak("missing argument : $syntax") if ! defined $fname; |
344
|
|
|
|
|
|
|
|
345
|
1
|
50
|
|
|
|
35
|
open FILE, "$fname" or croak "Can't open $fname : $!"; |
346
|
1
|
|
|
|
|
30
|
foreach my $t () { |
347
|
5
|
|
|
|
|
10
|
push @canevas, chomp $t; |
348
|
|
|
|
|
|
|
} |
349
|
1
|
|
|
|
|
15
|
close FILE; |
350
|
|
|
|
|
|
|
} |
351
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
1; |
353
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
=head1 Annexe |
356
|
|
|
|
|
|
|
|
357
|
|
|
|
|
|
|
couleurs : |
358
|
|
|
|
|
|
|
|
359
|
|
|
|
|
|
|
0 : Gris clair (ou blanc) |
360
|
|
|
|
|
|
|
1 : Noir |
361
|
|
|
|
|
|
|
2 : Bleu foncé |
362
|
|
|
|
|
|
|
3 : Vert foncé |
363
|
|
|
|
|
|
|
4 : Rouge |
364
|
|
|
|
|
|
|
5 : Rouge foncé |
365
|
|
|
|
|
|
|
6 : Violet |
366
|
|
|
|
|
|
|
7 : Orange |
367
|
|
|
|
|
|
|
8 : Jaune |
368
|
|
|
|
|
|
|
9 : Vert clair |
369
|
|
|
|
|
|
|
10 : Bleu ciel foncé |
370
|
|
|
|
|
|
|
11 : Bleu ciel clair |
371
|
|
|
|
|
|
|
12 : Bleu |
372
|
|
|
|
|
|
|
13 : Rose |
373
|
|
|
|
|
|
|
14 : Gris foncé |
374
|
|
|
|
|
|
|
15 : Gris |
375
|
|
|
|
|
|
|
|
376
|
|
|
|
|
|
|
=head1 BUGS |
377
|
|
|
|
|
|
|
|
378
|
|
|
|
|
|
|
Il n'y a pas de bugs connus, le problème de rendu peut venir d'un choix de police dont les |
379
|
|
|
|
|
|
|
caractère ne sont pas tous de la même taille, ce qui pose un problème aussi pour |
380
|
|
|
|
|
|
|
les dessins ascii. |
381
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
=head1 SUPPORT |
383
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
|
385
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
=head1 AUTHOR |
387
|
|
|
|
|
|
|
|
388
|
|
|
|
|
|
|
Colinet Sylvain |
389
|
|
|
|
|
|
|
skarsnikum@free.fr |
390
|
|
|
|
|
|
|
http://skarsnik.homelinux.org/~skarsnik |
391
|
|
|
|
|
|
|
|
392
|
|
|
|
|
|
|
=head1 COPYRIGHT |
393
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
This program is free software; you can redistribute |
395
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
396
|
|
|
|
|
|
|
|
397
|
|
|
|
|
|
|
The full text of the license can be found in the |
398
|
|
|
|
|
|
|
LICENSE file included with this module. |
399
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
|
401
|
|
|
|
|
|
|
=head1 SEE ALSO |
402
|
|
|
|
|
|
|
|
403
|
|
|
|
|
|
|
perl(1). Net::IRC, POE::Component::IRC |
404
|
|
|
|
|
|
|
|
405
|
|
|
|
|
|
|
=cut |
406
|
|
|
|
|
|
|
|
407
|
|
|
|
|
|
|
__END__ |