Re: gd project question
| From: | Michael Davey | Date: | Fri, 31 May 2002 15:36:48 +0000 |
| Subject: | Re: gd project question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-100107@lists.php.net to get a copy of this message | ||
I believe you will need to use sin and cos to do this...
I experimented with drawing circles in javascript (sorry, it's not PHP but
you can see the concept) and ended up with this:
for (j = 0; j <= 360; j += (360 / 10))
{
// x1 & y1 are offset values
var s = x1 + radius * Math.cos (j);
var t = y1 + radius * Math.sin (j);
setLayer (layer_count, s, t);
layer_count++;
}
You would be able to work out the angle by making it a percentage of 180
degrees - although for horizontal gauges, you would need to offset it
by -90.
Hope this helps...
Mikey
"Michael Geier" <mgeier@cdmsports.com> wrote in message
news:CDEMKNODHLIIOKOJNIHGCEPECMAA.mgeier@cdmsports.com...
> I have the following issue:
>
> I am making a "gas guage" based on a percentage.
> ie.
> - a 180 degree arc is created
> - the range will be 0 to n (undetermined ammount)
> - there will be x number of entries
> - the needle will pount to a a percentage
> for (int)floor((x / n) * 100)
>
> The issue is, I have the starting pt for the needle (imagefilledarc
> needs the center of the 'circle' as the starting pt, which is where
> the needle will start too), but how would I get the x|y coordinates
> for the end of the needle based on a perentage of a half-circle
> (180 degree arc)?
>
> Appreciate any clues or ideas.
>
> ---
> Michael Geier
>