syntax for using a variable in Draw

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Post Reply
zemlik
Posts: 38
Joined: 2014-03-05T06:12:01-07:00
Authentication code: 6789

syntax for using a variable in Draw

Post by zemlik »

Hello,

Code: Select all

#I can use variables here but a pixel isn't really big enough
$image->Set("pixel[$value[$z][1],$value[$z][2]]"=>"#000000");
	 
#try to make a bigger dot, this works 
$image->Draw(fill=>'black', stroke=>'gold', primitive=>'circle', points=>'200,4 10,10',strokewidth=>2);
	 
#this also works with a variable for "strokewidth 
$image->Draw(fill=>'black', stroke=>'gold', primitive=>'circle', points=>'200,4 10,10',strokewidth=>$c);
	 
#but I can't seem to find the syntax to use a variable in "points"
$image->Draw(fill=>'black', stroke=>'gold', primitive=>'circle', points=>'$c,4 10,10',strokewidth=>2);
any idea what is the syntax ?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: syntax for using a variable in Draw

Post by snibgo »

I don't use or know Perl, but I notice that "strokewidth=>$c" is a single value so doesn't need quotes, where "points=>'$c,4 10,10'" is a list of values, so needs quotes. Perhaps Perl can't expand values in a quoted list, so you need to build the list first, into a variable, then use that variable: "points=>mylist".

I suggest you consult Perl documentation.
snibgo's IM pages: im.snibgo.com
zemlik
Posts: 38
Joined: 2014-03-05T06:12:01-07:00
Authentication code: 6789

Re: syntax for using a variable in Draw

Post by zemlik »

cheers that works

Code: Select all


my $string ="$x \, $y  $x \, $dy";

$image->Draw(fill=>'black', stroke=>'black', primitive=>'circle', points=>$string ,strokewidth=>2);
Post Reply