Name
Draw( )
Synopsis
$image->Draw(primitive=>string
, points=>string
, method=>{Point, Replace, Floodfill, FillToBorder, Reset}, stroke=>colorname
, fill=>colorname
, tile=>image_object
, strokewidth=>float
, antialias=>boolean
, bordercolor=>colorname
, affine=>float_array
, x=>float,
y=>float,
translate=>geometry,
scale=>geometry,
rotate=>float,
skewX=>float,
skewY=>float
)
The Draw( )
method allows
you to draw anywhere on an image with one of many graphics
primitives. The points
parameter indicates the position to start drawing and must be a
string of one or more coordinates, depending on the primitive
being used. A coordinate string can look like any of
these:
"3,5" # a single point "10,10 20,20" # two coordinates for a line, rectangle or circle "40,40 80,80 50,80 90,40" # four points for a polygon
Choose one of the following primitive types:
Bezier
This draws a curved line whose points are written as a cubic Bezier curve, where each curved segment is defined by two points and a single control point. For example:
$image->Draw(primitive=>'Bezier', points=> "350,475 250,475 250,400 ". "250,350 325,350 325,400", stroke=>'red', antialias=>1, linewidth=>1 );
Circle
The
Circle
primitive uses the first coordinate to define its center and the second coordinate to define a point on the edge. For example, to draw a circle centered at (100,100) that extends to (150,150), use:# draw a fat circle of radius 50 centered at 100,100 $image->Draw(primitive=>'Circle', points=>'100,100 150,150', linewidth=>10);
Get Perl Graphics Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.