Hi, I'm learning to draw with PHP I can do shapes and lines and all sort of stuff. Can I also draw sinusoids or other wave-form shapes that are generated by mathematical formulas? Any ideas please!
Yes, you can. change x from 0 to 100, for example, get y=100*sin(x) and place dots on those coordinates.
that's cool, i always wanted to use PHP for math @Ashine: btw, can you give a simple example of that?
Try this <?php //create our image 1000*400 pixels $im = imagecreatetruecolor(1000, 400); // set white color $w = imagecolorallocate($im,255,255,255); for ($x=1;$x<=1000;$x++) { $y = 200 + 200*sin($x/100); //put pixels imagesetpixel($im,$x,$y,$w); } //output image header('Content-Type: image/png'); imagepng($im); ?> PHP: $y = 200 + 200*sin($x/100); first 200 is to place graph in middle of image, cause sin range is -1..1, so 200*sin($x/100); will give -200..200 play with 100 - change it to 50 or 200 to set horizontal scale,