1#!/usr/bin/perl 2# GD example using PerlMagick methods. 3 4use Image::Magick; 5 6# 7# Create a 300x300 white canvas. 8# 9$image=Image::Magick->new; 10$image->Set(size=>'300x300'); 11$image->Read('xc:white'); 12# 13# Draw shapes. 14# 15$tile=Image::Magick->new; 16$tile->Read('tile.gif'); 17$image->Draw(primitive=>'Polygon',tile=>$tile,fill=>'none', 18 points=>'30,30 100,10 190,290 30,290'); 19$image->Draw(stroke=>'red',primitive=>'Ellipse',stroke=>'black',fill=>'red', 20 strokewidth=>5,points=>'100,100 50,75 0,360'); 21$image->Draw(primitive=>'Polygon',fill=>'none',stroke=>'black',strokewidth=>5, 22 points=>'30,30 100,10 190,290 30,290'); 23$image->FloodfillPaint(geometry=>'+132+62',fill=>'blue',bordercolor=>'black', 24 invert=>'true'); 25# 26# Draw text. 27# 28$image->Annotate(fill=>'red',geometry=>'+150+20',font=>'Generic.ttf', 29 pointsize=>18,text=>'Hello world!'); 30$image->Annotate(fill=>'blue',geometry=>'+150+38',font=>'Generic.ttf', 31 pointsize=>14,text=>'Goodbye cruel world!'); 32$image->Annotate(fill=>'black',geometry=>'+280+120',font=>'Generic.ttf', 33 pointsize=>14,text=>"I'm climbing the wall!",rotate=>90.0); 34# 35# Write image. 36# 37print "Write image...\n"; 38$image->Write('shapes.gif'); 39print "Display image...\n"; 40$image->Write('win:'); 41