Page 1 of 1

syntax for using a variable in Draw

Posted: 2018-03-22T14:27:03-07:00
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 ?

Re: syntax for using a variable in Draw

Posted: 2018-03-22T15:40:42-07:00
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.

Re: syntax for using a variable in Draw

Posted: 2018-03-22T17:30:01-07:00
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);