Khorosh Irani wrote:
> Hi
> I worked alittle with gd
> It is my code for y(x)=sin(x)+cos(x):
>
> function Graph($rangeLow, $rangeHigh, $step)
> {
> $img = ImageCreate($this->width, $this->height);
> $background_color = imagecolorallocate($img, 0, 0, 0);
> $white = ImageColorAllocate($img, 255, 255, 255);
> imageline($img, $this->width/2, 0,$this->width/2 , $this->height,
> $white);
> imageline($img, 0, $this->height/2, $this->width, $this->height/2,
> $white);
> for ($x=rangeLow;$x<=$rangeHigh,$x+=$step)
> {
> y=sin(x)*cos(x);//custom function
> //i dont know what should write here but i know that I should
> write imageline() function
> }
> header("Content-type: image/jpeg");
> ImageJpeg($img);
> imagedestroy($img);
> }
>
>
> could anyone write a simple code that complete this code
> I want to learn it
the best way to learn is when 'anyone' is you - write something, try it, try it
again
until it works.
given that your studying/using trigonometry I believe it should not be beyond
you
to figure out some code that generate the pixel coordinates that represent y on
each iteration
and then plot it using the relevant functions.
and of course you could STFW for some code that could help you get started:
http://www.google.com/search?num=100&q=trigonometry+php+gd
e.g. first result of above query:
http://lorenzod8n.wordpress.com/2007/05/19/plotting-trigonometrical-functions-in-php/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php