simple problem using GD

J

juliani.moon

I am using "GD::Image" to draw graphs, and have this line to print a
text:
$newimg->string(gdSmallFont,3,2,"Data Source: User submitted",$red);
which works fine.

However, when I try to use a variable to define its position, like in:
$ftop= 20;
$newimg->string(gdSmallFont,3,$ftop,"Data Source: User submitted",
$red);
or
$newimg->string(gdSmallFont,3,"$ftop","Data Source: User submitted",
$red);
they fail to work (graph is drawn without the text).

Any suggestion?

joe
 
J

Jim Gibson

I am using "GD::Image" to draw graphs, and have this line to print a
text:
$newimg->string(gdSmallFont,3,2,"Data Source: User submitted",$red);
which works fine.

However, when I try to use a variable to define its position, like in:
$ftop= 20;
$newimg->string(gdSmallFont,3,$ftop,"Data Source: User submitted",
$red);
or
$newimg->string(gdSmallFont,3,"$ftop","Data Source: User submitted",
$red);
they fail to work (graph is drawn without the text).

Any suggestion?

Looks OK. Please post a complete, short program that demonstrates the
problem.
 
P

Paul E. Schoen

I am using "GD::Image" to draw graphs, and have this line to print a
text:
$newimg->string(gdSmallFont,3,2,"Data Source: User submitted",$red);
which works fine.

However, when I try to use a variable to define its position, like in:
$ftop= 20;
$newimg->string(gdSmallFont,3,$ftop,"Data Source: User submitted",
$red);
or
$newimg->string(gdSmallFont,3,"$ftop","Data Source: User submitted",
$red);
they fail to work (graph is drawn without the text).

Any suggestion?

I only see that the Y coordinate that works is 2 while $ftop=20. And maybe
you need to use "my $ftop"?

I'm a newbie and I've never used GD::Image, so this is just an
observation...

Paul
 
M

Marc Girod

Any suggestion?

- don't quote the variable.#
- try with other constant values:

$newimg->string(gdSmallFont,3,3,"Data Source: User submitted",$red);
$newimg->string(gdSmallFont,3,5,"Data Source: User submitted",$red);
$newimg->string(gdSmallFont,3,10,"Data Source: User submitted",$red);
$newimg->string(gdSmallFont,3,20,"Data Source: User submitted",$red);

- and with setting the variable to 2:

$ftop= 2;
$newimg->string(gdSmallFont,3,$ftop,"Data Source: User submitted",
$red);

Marc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,163
Latest member
Sasha15427
Top