• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/perl
2# Piddle example using PerlMagick methods.
3
4use Image::Magick;
5
6#
7# Create white canvas.
8#
9$image=Image::Magick->new(size=>'300x300');
10$image->Read('xc:white');
11#
12# Draw blue grid
13#
14for ($i=0; $i < 300; $i+=10)
15{
16  $image->Draw(primitive=>'line',points=>"$i,0 $i,300",stroke=>"#ccf");
17  $image->Draw(primitive=>'line',points=>"0,$i 300,$i",stroke=>"#ccf");
18}
19#
20# Draw rounded rectangle.
21#
22$image->Draw(primitive=>'RoundRectangle',fill=>'blue',stroke=>'maroon',
23  strokewidth=>4,points=>'30,30 100,100 10,10');
24#
25# Draw curve.
26#
27$image->Draw(primitive=>'bezier',points=>'20,20, 100,50, 50,100, 160,160',
28  fill=>'none',stroke=>'black',strokewidth=>4);
29#
30# Draw line.
31#
32$image->Draw(primitive=>'line',points=>"10,200 20,190",stroke=>red);
33#
34# Draw arc within a circle.
35#
36$image->Draw(primitive=>'circle',stroke=>'none',fill=>'yellow',,
37  points=>"170,70 200,70");
38$image->Draw(primitive=>'Path',stroke=>'none',fill=>'blue',strokewidth=>4,
39  points=>'M170,70 v-30 a30,30 0 0,0 -30,30 z');
40$image->Draw(primitive=>'circle',stroke=>'black',fill=>'none',strokewidth=>4,
41  points=>"170,70 200,70");
42#
43# Draw pentogram.
44#
45$image->Draw(primitive=>'polygon',
46  points=>"160,120 130,190 210,145 110,145 190,190 160,120",stroke=>red,
47  fill=>LimeGreen,strokewidth=>3);
48#
49# Draw rectangle.
50#
51$image->Draw(primitive=>'line',points=>'200,260 200,200',stroke=>yellow,
52  strokewidth=>5);
53$image->Draw(primitive=>'line',points=>'200,200 260,200',stroke=>yellow,
54  strokewidth=>5);
55$image->Draw(primitive=>'line',points=>'260,200 260,260',stroke=>red,
56  strokewidth=>5);
57$image->Draw(primitive=>'line',points=>'200,260 260,260',stroke=>green,
58  strokewidth=>5);
59#
60# Draw text.
61#
62$image->Annotate(text=>'This is a test!',geometry=>'+30+140',fill=>'green',
63  pointsize=>24,rotate=>45.0);
64$image->Write('piddle.gif');
65$image->Write('piddle.mvg');
66$image->Write('win:');
67