blib/lib/Acme/IRC/Art.pm

filter: Statementstmt 99.2% 127 / 128 Branchbran 72.5% 58 / 80 Conditioncond 59.2% 48 / 81 MC/DCmcdc 22.2% 10 / 45 Subroutinesub 100% 15 / 15 Podpod 75.0% 6 / 8 totaltotal 73.9% 264 / 357 CC 76 SCAR 33.7
CC
76
Cov
81%
text
51.7
pixel
23.3
new
10.7
CRAP 29.0
↑ Summary
1 #!/usr/bin/perl
2 package Acme::IRC::Art;
3 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 7 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 7 ▶no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 7 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
8 7 ▶ use Exporter ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 7 ▶ use vars qw ($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 7 $VERSION = 0.2;
11 7 @ISA = qw (Exporter);
12 #Give a hoot don't pollute, do not export more than needed by default
13 7 @EXPORT = qw ();
14 7 @EXPORT_OK = qw ();
15 7 %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 8 ▶sub new {
Subroutine new: called CC=9 SCAR=23.7
Pod documented
69 8 my ($class, $largeur, $hauteur) = @_;
70
71 #gestion d'erreur
72 8 my $syntaxe = 'Syntaxe correcte : $deco = Art->new(largeur, hauteur)';
73 8 ▶ croak("Les arguments de la fonction \'new\' de Art.pm sont: la largeur et la hauteur du canevas
Branch: 1 branch
BranchTrueFalseTotal
if @_ != 3 0 8 8
74 $syntaxe") if @_!=3;
75 8 ▶ croak("Largeur et hauteur doivent être des nombres
Branch: 1 branch
BranchTrueFalseTotal
unless $largeur =~ /^\d+$/ and $hauteur =~ /^\d+$/ 0 8 8
Condition33%1/3
$largeur =~ /^\d+$/ and $hauteur =~ /^\d+$/
!ll&&!rl&&r
008
MC/DC0%0/2
$largeur =~ /^\d+$/ and $hauteur =~ /^\d+$/
$largeur =~ /^\d+$/ $hauteur =~ /^\d+$/
Truth table33%1/3
A and B
A= $largeur =~ /^\d+$/B= $hauteur =~ /^\d+$/
ABresult
0X0
100
111
76 $syntaxe") if ($largeur!~/^\d+$/ or $hauteur!~/^\d+$/);
77 8 ▶ croak("la largeur ou la hauteur ne sont pas des nombre
Branch: 1 branch
BranchTrueFalseTotal
unless $largeur =~ /\d/ and $hauteur =~ /\d/ 0 8 8
Condition33%1/3
$largeur =~ /\d/ and $hauteur =~ /\d/
!ll&&!rl&&r
008
MC/DC0%0/2
$largeur =~ /\d/ and $hauteur =~ /\d/
$largeur =~ /\d/ $hauteur =~ /\d/
Truth table33%1/3
A and B
A= $largeur =~ /\d/B= $hauteur =~ /\d/
ABresult
0X0
100
111
78 $syntaxe") if ($largeur!~/\d/ or $hauteur!~/\d/);
79  
80  
81 8 ▶ $hauteur-- and $largeur--;
Branch: 1 branch
BranchTrueFalseTotal
$hauteur-- and --$largeur 8 0 8
82 8 my @canevas;
83 8 $#canevas = $hauteur;
84 #fill with spaces
85 8 foreach my $temp (0..$hauteur) {
86 36 foreach my $temp2 (0..$largeur) {
87 173 $canevas[$temp][$temp2] = " ";
88 }
89 }
90 8 my $self = {};
91 8 bless ($self,$class);
92 8 $self->{canevas} = [@canevas];
93 8 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<result> 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 29 ▶sub result {
Subroutine result: called CC=1 SCAR=0.0
Pod documented
109 29 my ($this) = shift;
110 7 ▶ use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
111 29 return map {join '',@{$_}} @{$this->{canevas}};
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 254 ▶sub pixel {
Subroutine pixel: called CC=18 SCAR=31.5
Pod undocumented
142 254 my ($this, $x, $y, $color, $on) = @_;
143 254 my @canevas = @{$this->{canevas}};
144
145 #gestion d'erreur
146 254 my $syntaxe = '$deco->pixel( position x , position y , couleur , [on])';
147 254 ▶ croak("Les arguments de \'pixel\' sont : la position en x , la position en y , la couleur et l'état du pixel
Branch: 1 branch
BranchTrueFalseTotal
if @_ < 4 or @_ > 5 0 254 254
Condition33%1/3
@_ < 4 or @_ > 5
l!l&&r!l&&!r
00254
MC/DC0%0/2
@_ < 4 or @_ > 5
@_ < 4 @_ > 5
Truth table33%1/3
A or B
A= @_ < 4B= @_ > 5
ABresult
1X1
011
000
148 $syntaxe") if @_<4 or @_>5;
149 254 ▶ croak("Les tableaux des position x et y ne sont pas de la même taille !
Branch: 1 branch
BranchTrueFalseTotal
if ref $y and ref $x and @$x != @$y 0 254 254
Condition66%4/6
ref $y and ref $x and @$x != @$y
!ll&&!rl&&r
25220
ref $y and ref $x
!ll&&!rl&&r
25202
MC/DC0%0/3
ref $y and ref $x and @$x != @$y
ref $y ref $x @$x != @$y
Truth table50%2/4
A and B and C
A= ref $yB= ref $xC= @$x != @$y
ABCresult
0XX0
10X0
1100
1111
150 $syntaxe") if (ref $y and ref $x and @$x != @$y);
151 254 ▶ croak("l'un d'un arguments de position n'est pas compatible avec l'autre
Branch: 1 branch
BranchTrueFalseTotal
if ref $y and not ref $x or ref $x and not ref $y 0 254 254
Condition55%5/9
ref $y and not ref $x or ref $x and not ref $y
l!l&&r!l&&!r
00254
ref $y and not ref $x
!ll&&!rl&&r
25220
ref $x and not ref $y
!ll&&!rl&&r
25220
MC/DC0%0/4
ref $y and not ref $x or ref $x and not ref $y
ref $y not ref $x ref $x not ref $y
Truth table28%2/7
A and not(B) or C and not(D)
A= ref $yB= not ref $xC= ref $xD= not ref $y
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
152 $syntaxe") if (ref $y and !ref $x or ref $x and !ref $y);
153 254 ▶ croak("Vous etes sortit du canevas définit") if ((!ref $x and !ref $y ) and ($y>$#canevas or $x>(@{$canevas[0]}-1)));
Branch: 1 branch
BranchTrueFalseTotal
if not ref $x || ref $y and $y > $#canevas || $x > @{$canevas[0];} - 1 0 254 254
Condition55%5/9
not ref $x || ref $y and $y > $#canevas || $x > @{$canevas[0];} - 1
!ll&&!rl&&r
22520
ref $x || ref $y
l!l&&r!l&&!r
20252
$y > $#canevas or $x > @{$canevas[0];} - 1
l!l&&r!l&&!r
00252
MC/DC0%0/4
not ref $x || ref $y and $y > $#canevas || $x > @{$canevas[0];} - 1
ref $x ref $y $y > $#canevas $x > @{$canevas[0];} - 1
Truth table40%2/5
not(A || B) and C or D
A= ref $xB= ref $yC= $y > $#canevasD= $x > @{$canevas[0];} - 1
ABCDresult
1XXX0
01XX0
00000
001X1
00011
154
155 254 my (@y, @x);
156 254 ▶ if (ref $y) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $y) { } 2 252 254
157 2 @x = @$x;
158 2 @y = @$y;
159 }
160 else {
161 252 $x[0] = $x;
162 252 $y[0] = $y;
163 252 $#y = 0;
164 }
165 254 ▶ $on = 0 unless defined $on;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $on 101 153 254
166 254 for (0..$#y) {
167 258 ▶ if ($on >= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($on >= 0) { } 129 129 258
168 129 $canevas[$y[$_]][$x[$_]] = "\003$color,$color \003";
169 }
170 else {
171 129 $canevas[$y[$_]][$x[$_]] = " ";
172 }
173 }
174 254 $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 12 ▶sub text {
Subroutine text: called CC=39 SCAR=39.5
Pod documented
209 12 my ($this, $text, $x, $y, $bolt, $fond) = @_;
210 12 my @canevas = @{$this->{canevas}};
211  
212 12 ▶ $bolt = 0 unless defined $bolt;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $bolt 2 10 12
213 12 ▶ $fond = 0 unless defined $fond;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fond 6 6 12
214 #gestion d'erreur
215 12 my $syntaxe = 'Syntaxe correcte : $deco->text($texte,$positionx,$positiony,[$mise_en_forme],[$fond])';
216  
217 12 ▶ croak("les arguments de \'text\' sont le texte, la position x de la première lettre,i".
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 6 or @_ < 4 0 12 12
Condition33%1/3
@_ > 6 or @_ < 4
l!l&&r!l&&!r
0012
MC/DC0%0/2
@_ > 6 or @_ < 4
@_ > 6 @_ < 4
Truth table33%1/3
A or B
A= @_ > 6B= @_ < 4
ABresult
1X1
011
000
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 ▶ 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);
Branch: 1 branch
BranchTrueFalseTotal
if not ref $bolt and length $bolt > 3 || !($bolt =~ /\d/ || $bolt =~ /b/) and @_ == 5 0 12 12
Condition50%6/12
not ref $bolt and length $bolt > 3 || !($bolt =~ /\d/ || $bolt =~ /b/) and @_ == 5
!ll&&!rl&&r
1200
not ref $bolt and length $bolt > 3 || !($bolt =~ /\d/ || $bolt =~ /b/)
!ll&&!rl&&r
1110
length $bolt > 3 or not $bolt =~ /\d/ || $bolt =~ /b/
l!l&&r!l&&!r
0011
$bolt =~ /\d/ || $bolt =~ /b/
l!l&&r!l&&!r
1010
MC/DC0%0/5
not ref $bolt and length $bolt > 3 || !($bolt =~ /\d/ || $bolt =~ /b/) and @_ == 5
not ref $bolt length $bolt > 3 $bolt =~ /\d/ $bolt =~ /b/ @_ == 5
Truth table42%3/7
not(A) and B or not(C || D) and E
A= not ref $boltB= length $bolt > 3C= $bolt =~ /\d/D= $bolt =~ /b/E= @_ == 5
ABCDEresult
0XXXX0
101XX0
1001X0
11XX00
100000
11XX11
100011
222
223 12 ▶ croak("Un des arguments qui devrai être un nombre de l'est pas
Branch: 1 branch
BranchTrueFalseTotal
unless $x =~ /\d/ and $y =~ /\d/ 0 12 12
Condition33%1/3
$x =~ /\d/ and $y =~ /\d/
!ll&&!rl&&r
0012
MC/DC0%0/2
$x =~ /\d/ and $y =~ /\d/
$x =~ /\d/ $y =~ /\d/
Truth table33%1/3
A and B
A= $x =~ /\d/B= $y =~ /\d/
ABresult
0X0
100
111
224 $syntaxe") if ($x !~ /\d/ or $y !~ /\d/);
225  
226 12 ▶ croak("la valeur de fond spécifié est trop grande") if !ref $fond and $fond > 15;
Branch: 1 branch
BranchTrueFalseTotal
if not ref $fond and $fond > 15 0 12 12
Condition66%2/3
not ref $fond and $fond > 15
!ll&&!rl&&r
1110
MC/DC0%0/2
not ref $fond and $fond > 15
not ref $fond $fond > 15
Truth table66%2/3
not(A) and B
A= not ref $fondB= $fond > 15
ABresult
0X0
100
111
227 12 ▶ croak("la couleur de mise en forme est trop grande") if !ref $bolt and $bolt > 15;
Branch: 1 branch
BranchTrueFalseTotal
if not ref $bolt and $bolt > 15 0 12 12
Condition66%2/3
not ref $bolt and $bolt > 15
!ll&&!rl&&r
1110
MC/DC0%0/2
not ref $bolt and $bolt > 15
not ref $bolt $bolt > 15
Truth table66%2/3
not(A) and B
A= not ref $boltB= $bolt > 15
ABresult
0X0
100
111
228 12 ▶ croak("Vous etes sortit du canevas définit") if ($y > $#canevas or $x > (@{$canevas[0]}-1));
Branch: 1 branch
BranchTrueFalseTotal
if $y > $#canevas or $x > @{$canevas[0];} - 1 0 12 12
Condition33%1/3
$y > $#canevas or $x > @{$canevas[0];} - 1
l!l&&r!l&&!r
0012
MC/DC0%0/2
$y > $#canevas or $x > @{$canevas[0];} - 1
$y > $#canevas $x > @{$canevas[0];} - 1
Truth table33%1/3
A or B
A= $y > $#canevasB= $x > @{$canevas[0];} - 1
ABresult
1X1
011
000
229  
230 12 ▶ my $a_bolt = $bolt if ref $bolt;
Branch: 1 branch
BranchTrueFalseTotal
if ref $bolt 1 11 12
231 12 ▶ my $a_fond = $fond if ref $fond;
Branch: 1 branch
BranchTrueFalseTotal
if ref $fond 1 11 12
232 12 my @lettre = split '',$text;
233 12 my $color;
234 0 foreach my $position (0..$#lettre) {
235 53 ▶ $bolt = $a_bolt->[$position] if $a_bolt;
Branch: 1 branch
BranchTrueFalseTotal
if $a_bolt 4 49 53
236 53 ▶ $fond = $a_fond->[$position] if $a_fond;
Branch: 1 branch
BranchTrueFalseTotal
if $a_fond 4 49 53
237 53 my $v;
238 53 my $fond2 = $fond;
239 53 my $pixel = \$canevas[$y][$x+$position];
240
241 # on redéfinis le fond au besoin
242 53 ▶ $this->pixel($x + $position, $y, $2) if $$pixel =~ /\003(\d|),(\d)/;
Branch: 1 branch
BranchTrueFalseTotal
if $$pixel =~ /\003(\d|),(\d)/ 4 49 53
243 53 ▶ $fond2 ||= $2;
Condition100%3/3
$fond2 ||= $2
l!l&&r!l&&!r
28421
MC/DC100%2/2
$fond2 ||= $2
$fond2 $2
Truth table100%3/3
A ||= B
A= $fond2B= $2
ABresult
1X1
011
000
244 53 ▶ $v = ',' if $fond or $$pixel ne " ";
Branch: 1 branch
BranchTrueFalseTotal
if $fond or $$pixel ne " " 36 17 53
Condition100%3/3
$fond or $$pixel ne " "
l!l&&r!l&&!r
28817
MC/DC100%2/2
$fond or $$pixel ne " "
$fond $$pixel ne " "
Truth table100%3/3
A or B
A= $fondB= $$pixel ne " "
ABresult
1X1
011
000
245
246 # on place enfin la lettre
247 53 ▶ $$pixel=~s/\s/\002$lettre[$position]\002/ if $bolt eq 'b';
Branch: 1 branch
BranchTrueFalseTotal
if $bolt eq "b" 4 49 53
248 53 ▶ if (($color) = ($bolt =~ /b(\d+)/)) { #bolt with color
Branch: 1 branch
BranchTrueFalseTotal
if (($color) = $bolt =~ /b(\d+)/) 20 33 53
249 20 ▶ ($fond2, $color, $lettre[$position]) = correction($fond2, $color, $lettre[$position]) and
Branch: 1 branch
BranchTrueFalseTotal
($fond2, $color, $lettre[$position]) = correction($fond2, $color, $lettre[$position]) and $$pixel = "\cC$color$v$fond2\cB$lettre[$position]\cB\cC" 20 0 20
250 $$pixel = "\003${color}${v}${fond2}\002$lettre[$position]\002\003";
251 }
252 53 ▶ if (($color) = ($bolt =~ /^(\d+)/)) { #only color
Branch: 1 branch
BranchTrueFalseTotal
if (($color) = $bolt =~ /^(\d+)/) 29 24 53
253 29 ▶ ($fond2, $color, $lettre[$position]) = correction($fond2, $color, $lettre[$position]) and
Branch: 1 branch
BranchTrueFalseTotal
($fond2, $color, $lettre[$position]) = correction($fond2, $color, $lettre[$position]) and $$pixel = "\cC$color$v$fond2$lettre[$position]\cC" 29 0 29
254 $$pixel = "\003${color}${v}${fond2}$lettre[$position]\003";
255 }
256 53 ▶ if (!$bolt and !$fond) { #euh
Branch: 1 branch
BranchTrueFalseTotal
unless ($bolt or $fond) 9 44 53
Condition66%2/3
$bolt or $fond
l!l&&r!l&&!r
4409
MC/DC50%1/2
$bolt or $fond
$bolt $fond
Truth table66%2/3
A or B
A= $boltB= $fond
ABresult
1X1
011
000
257 9 ▶ ($fond2, $color, $lettre[$position]) = correction($fond2, $color, $lettre[$position]) and
Branch: 1 branch
BranchTrueFalseTotal
($fond2, $color, $lettre[$position]) = correction($fond2, $color, $lettre[$position]) and $$pixel = "\cC$v$fond2$lettre[$position]\cC" 9 0 9
258 $$pixel = "\003${v}${fond2}$lettre[$position]\003";
259 }
260 53 ▶ if (!$bolt and !$fond and !$fond2) { #just text
Branch: 1 branch
BranchTrueFalseTotal
unless ($bolt or $fond or $fond2) 9 44 53
Condition66%4/6
$bolt or $fond or $fond2
l!l&&r!l&&!r
4409
$bolt or $fond
l!l&&r!l&&!r
4409
MC/DC33%1/3
$bolt or $fond or $fond2
$bolt $fond $fond2
Truth table50%2/4
A or B or C
A= $boltB= $fondC= $fond2
ABCresult
1XX1
01X1
0011
0000
261 9 ▶ ($fond2, $color, $lettre[$position]) = correction($fond2, $color, $lettre[$position]) and
Branch: 1 branch
BranchTrueFalseTotal
($fond2, $color, $lettre[$position]) = correction($fond2, $color, $lettre[$position]) and $$pixel = $lettre[$position] 9 0 9
262 $$pixel = $lettre[$position];
263 }
264 67 ▶ sub correction {
Subroutine correction: called CC=5 SCAR=16.1
Pod undocumented
265 #sub qui corrige au besoin pour pouvoir faire aparaître les chiffres
266 67 ▶ $_[0] = "0$_[0]" if $_[0] =~ /^\d$/ and $_[2] =~ /^\d$/;
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] =~ /^\d$/ and $_[2] =~ /^\d$/ 8 59 67
Condition100%3/3
$_[0] =~ /^\d$/ and $_[2] =~ /^\d$/
!ll&&!rl&&r
39208
MC/DC100%2/2
$_[0] =~ /^\d$/ and $_[2] =~ /^\d$/
$_[0] =~ /^\d$/ $_[2] =~ /^\d$/
Truth table100%3/3
A and B
A= $_[0] =~ /^\d$/B= $_[2] =~ /^\d$/
ABresult
0X0
100
111
267 67 ▶ $_[1] = "0$_[1]" if $_[1] =~ /^\d$/ and $_[2] =~ /^\d$/;
Branch: 1 branch
BranchTrueFalseTotal
if $_[1] =~ /^\d$/ and $_[2] =~ /^\d$/ 13 54 67
Condition100%3/3
$_[1] =~ /^\d$/ and $_[2] =~ /^\d$/
!ll&&!rl&&r
25213
MC/DC100%2/2
$_[1] =~ /^\d$/ and $_[2] =~ /^\d$/
$_[1] =~ /^\d$/ $_[2] =~ /^\d$/
Truth table100%3/3
A and B
A= $_[1] =~ /^\d$/B= $_[2] =~ /^\d$/
ABresult
0X0
100
111
268 67 return @_;
269 }
270 }
271 12 $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 17 ▶sub rectangle {
Subroutine rectangle: called CC=3 SCAR=11.0
Pod documented
291 17 my ($this, $x1, $y1, $x2, $y2, $color, $on) = @_;
292 17 foreach my $t1 ($y1..$y2) {
293 43 foreach my $t2 ($x1..$x2) {
294 239 $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 2 ▶sub save {
Subroutine save: called CC=4 SCAR=14.0
Pod documented
313 2 my ($this, $fname) = @_;
314 2 my @canevas = @{$this->{canevas}};
315  
316 2 my $syntax = 'Syntax : $art->save($file_name)';
317 2 ▶ croak("missing argument : $syntax") if ! defined $fname;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fname 0 2 2
318  
319 2 ▶ open FILE, ">", $fname or croak "Error opening $fname with write permision : $!";
Branch: 1 branch
BranchTrueFalseTotal
open FILE, ">", $fname or croak("Error opening $fname with write permision : $!") 2 0 2
320 2 foreach my $t (@canevas) {
321 10 print FILE join('', @$t), "\n";
322 }
323 2 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 1 ▶sub load {
Subroutine load: called CC=4 SCAR=14.0
Pod documented
339 1 my ($this, $fname) = @_;
340 1 my @canevas = @{$this->{canevas}};
341  
342 1 my $syntax = 'Syntax :$art->load($file_name)';
343 1 ▶ croak("missing argument : $syntax") if ! defined $fname;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fname 0 1 1
344  
345 1 ▶ open FILE, "$fname" or croak "Can't open $fname : $!";
Branch: 1 branch
BranchTrueFalseTotal
open FILE, "$fname" or croak("Can't open $fname : $!") 1 0 1
346 1 foreach my $t (<FILE>) {
347 5 push @canevas, chomp $t;
348 }
349 1 close FILE;
350 }
351  
352 7 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__
↑ Summary