首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > perl python >

perl中画图的有关问题

2012-09-12 
perl中画图的问题我想用perl画一张随机颜色的图,怎么结果老是同一种颜色呢?Perl code#use image::Magicku

perl中画图的问题
我想用perl画一张随机颜色的图,怎么结果老是同一种颜色呢?

Perl code
#use image::Magick;use GD;# Create a new image$im = new GD::Image(100,100);# Allocate some colors#$white = $im->colorAllocate(255,255,255);#$black = $im->colorAllocate(0,0,0);#$red = $im->colorAllocate(255,0,0);#$blue = $im->colorAllocate(0,0,255);#print $white."\n";#print $black."\n";#print $red."\n";#print $blue."\n";# Make the background transparent and interlaced#$im->transparent($white);#$im->interlaced('false');my $color;$color = $im->colorAllocate(100,100,100);foreach(0..100){  $i =$_;  foreach(0..100)  {      $im->colorDeallocate($color);      $color = $im->colorAllocate(int(rand(256)),int(rand(256)),int(rand(256)));      $im->setPixel($_,$i,$color);      print $color."\n";      $im->setPixel($_,$i,$color);}}# Open a file for writingopen(PICTURE, ">picture.png") or die("Cannot open file for writing");# Make sure we are writing to a binary streambinmode PICTURE;# Convert the image to PNG and print it to the file PICTUREprint PICTURE $im->png;close PICTURE;if( (-e "picture.png")){  system("kview picture.png");  system("rm  picture.png");}


[解决办法]
用的着,先学习了
[解决办法]
收藏一下。
[解决办法]
我也来学习一下
[解决办法]
学习...

热点排行