File: shapes.pl

package info (click to toggle)
imagemagick 8%3A7.1.1.47%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 90,424 kB
  • sloc: ansic: 372,037; cpp: 22,844; xml: 11,549; perl: 6,285; sh: 6,203; makefile: 3,484; tcl: 459
file content (40 lines) | stat: -rw-r--r-- 1,240 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/perl
# GD example using PerlMagick methods.

use Image::Magick;

#
# Create a 300x300 white canvas.
#
$image=Image::Magick->new;
$image->Set(size=>'300x300');
$image->Read('xc:white');
#
# Draw shapes.
#
$tile=Image::Magick->new;
$tile->Read('tile.gif');
$image->Draw(primitive=>'Polygon',tile=>$tile,fill=>'none',
  points=>'30,30 100,10 190,290 30,290');
$image->Draw(stroke=>'red',primitive=>'Ellipse',stroke=>'black',fill=>'red',
  strokewidth=>5,points=>'100,100 50,75 0,360');
$image->Draw(primitive=>'Polygon',fill=>'none',stroke=>'black',strokewidth=>5,
  points=>'30,30 100,10 190,290 30,290');
$image->FloodfillPaint(geometry=>'+132+62',fill=>'blue',bordercolor=>'black',
  invert=>'true');
#
# Draw text.
#
$image->Annotate(font=>'Generic.ttf',fill=>'red',geometry=>'+150+20',
  pointsize=>18,text=>'Hello world!');
$image->Annotate(font=>'Generic.ttf',fill=>'blue',geometry=>'+150+38',
  pointsize=>14,text=>'Goodbye cruel world!');
$image->Annotate(font=>'Generic.ttf',fill=>'black',geometry=>'+280+120',
  pointsize=>14,text=>"I'm climbing the wall!",rotate=>90.0);
#
# Write image.
#
print "Write image...\n";
$image->Write('shapes.pam');
print "Display image...\n";
$image->Write(magick=>'SHOW',title=>"Shapes");