J
john.swilting
my code not work
its obvious for me
#!/usr/bin/perl -w
use strict;
use diagnostics;
use GD;
use GD::Text;
use GD::Text::Wrap;
use CGI;
use CGI::Carp;
my $q = new CGI;
# create a new
my $im = new GD::Image(100,100);
# allocate some colors
my $white = $im->colorAllocate(255,255,255);
my $black = $im->colorAllocate(0,0,0);
my $red = $im->colorAllocate(255,0,0);
my $blue = $im->colorAllocate(0,0,255);
# make the background tra $im_pngnsparent and interlaced
$im->transparent($white);
$im->interlaced('true');
# put a black frame around the picture
$im->rectangle(0,0,99,99,$black);
# draw a blue oval
$im->arc(50,50,95,75,0,360,$blue);
# and fill it with red
$im->fill(50,50,$red);
my $text = Random->Random::new();
my $wp = GD::Text::Wrap->new ( $im,
width => 100,
line_space => 4,
color => $black,
text => $text,
);
$im->rectangle ( $wp->get_bounds(50,50), $blue);
$wp->draw(50,50);
print $q->header( -type => "image/png", -expires => "-1d");
binmode STDOUT;
print STDOUT $im->png
package Random;
sub new{
my $class=shift;
my $self={};
bless $self,$class;
my@liste=('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15',
'16','17','18','19','20','21','22','23','24','25','26','27','28',
'29','30','31','32','33','34','35','36','37','38','39','40','41',
'42','43','44','45','46','47','48','49','50','51','52','53','54',
'55','56','57','58','59','60','61','62','63','64','65','66','67',
'68','69','70','71','72','73','74','75','76','77','78','79','78',
'79','80','81','82','83','84','85','86','87','88','89','90','91',
'92','93','94','95','96','97','98','99','100','101','102','103',
'104','105','106','107','108','109','110');
$self="";
my$self1="";
my$self2="";
my$self3="";
my$self4="";
$self1.=$liste[int rand@liste];
$self .= $self1;
$self2.=$liste[int rand@liste];
$self .=$self2;
$self3.=$liste[int rand@liste];
$self .=$self3;
$self4.=$liste[int rand@liste];
return $self;
}
1
its obvious for me
#!/usr/bin/perl -w
use strict;
use diagnostics;
use GD;
use GD::Text;
use GD::Text::Wrap;
use CGI;
use CGI::Carp;
my $q = new CGI;
# create a new
my $im = new GD::Image(100,100);
# allocate some colors
my $white = $im->colorAllocate(255,255,255);
my $black = $im->colorAllocate(0,0,0);
my $red = $im->colorAllocate(255,0,0);
my $blue = $im->colorAllocate(0,0,255);
# make the background tra $im_pngnsparent and interlaced
$im->transparent($white);
$im->interlaced('true');
# put a black frame around the picture
$im->rectangle(0,0,99,99,$black);
# draw a blue oval
$im->arc(50,50,95,75,0,360,$blue);
# and fill it with red
$im->fill(50,50,$red);
my $text = Random->Random::new();
my $wp = GD::Text::Wrap->new ( $im,
width => 100,
line_space => 4,
color => $black,
text => $text,
);
$im->rectangle ( $wp->get_bounds(50,50), $blue);
$wp->draw(50,50);
print $q->header( -type => "image/png", -expires => "-1d");
binmode STDOUT;
print STDOUT $im->png
package Random;
sub new{
my $class=shift;
my $self={};
bless $self,$class;
my@liste=('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15',
'16','17','18','19','20','21','22','23','24','25','26','27','28',
'29','30','31','32','33','34','35','36','37','38','39','40','41',
'42','43','44','45','46','47','48','49','50','51','52','53','54',
'55','56','57','58','59','60','61','62','63','64','65','66','67',
'68','69','70','71','72','73','74','75','76','77','78','79','78',
'79','80','81','82','83','84','85','86','87','88','89','90','91',
'92','93','94','95','96','97','98','99','100','101','102','103',
'104','105','106','107','108','109','110');
$self="";
my$self1="";
my$self2="";
my$self3="";
my$self4="";
$self1.=$liste[int rand@liste];
$self .= $self1;
$self2.=$liste[int rand@liste];
$self .=$self2;
$self3.=$liste[int rand@liste];
$self .=$self3;
$self4.=$liste[int rand@liste];
return $self;
}
1