[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] A graphics program to show Moire lines



I think there should be more examples (preferably short) of
interesting MacPerl programs posted to this discussion list. 
I am now exploring the GD library (as well as working on my 
Perl shell!).

Here is a program to draw two sets of lines in different
colours. You should see interference effects/Moire patterns.

Later I'll upload my code examples and generated GIFS to my
web site.  If you want the GIF file emailed as an attachment,
let me know.

Regards
Charles Cave
charles@irg.com.au     (Australia->Sydney)


#!perl -w

use GD;
print "Starting the drawing\n";
$im = new GD::Image(400,400);

# set colours
$white = $im->colorAllocate(255,255,255);
$black = $im->colorAllocate(0,0,0);
$red =   $im->colorAllocate(255,0,0);
$green = $im->colorAllocate(0,255,0);
$blue =  $im->colorAllocate(0,0,255);

# do some drawing

$ymax = 300;
 for ($y=10; $y<=$ymax; $y+=6) {
    $im->line(10, $y, $ymax, $ymax, $blue);
    $im->line($ymax, $y, 10, $ymax, $red);
 }

print "Drawing finished, now writing to file\n";
open (OUT,">myimage.gif") || die "couldnt create image file\n";
print OUT $im->gif;
close(OUT);
print "Finished!\n";

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org