-
-
//Basic steps of drawing technology Prerequisite: Enable the gd library in the php.ini file - //Create a canvas with a default background of black
- $img=imagecreatetruecolor(400,300) ;
- //Draw various graphics
- //Create a color
- $background = imagecolorallocate($img, 255, 0, 0);
- //Draw a circle
- //imageellipse($img,30,30,50,50 ,$background);
- //Ellipse
- //imageellipse($img,30,30,50,30,$background);
- //Draw a straight line
- //imageline($img,0,0,400,300,$background);
- //Draw a rectangle
- //imagerectangle ($img, 50, 20, 100, 40, $background);
- //Fill the rectangle
- //imagefilledrectangle ($img, 50, 20, 100, 40, $background);
- //Draw an arc
- //imagearc($img, 100, 100, 150, 150, 180, 270, $background);
- //Draw a fan-shaped IMG_ARC_CHORD straight line connecting the starting and ending points IMG_ARC_PIE
- //imagefilledarc ($img, 100, 100, 150, 150, 180, 270, $background,IMG_ARC_PIE);
//Copy the image to the canvas
- /*$scrImg=imagecreatefromgif('http:/ /www.baidu.com/img/shouye_b5486898c692066bd2cbaeda86d74448.gif');
- $scrImgInfo=getimagesize('http://www.baidu.com/img/shouye_b5486898c692066bd2cbaeda86d74448.gif');
- imagecopy ($img,$scrImg,10 ,10,0,0,$scrImgInfo[0],$scrImgInfo[1]);
- */
- //imagecopy ($img,$scrImg,10,10,0,0,270,129);
- < ;p>//Write words
- //imagestring ($img, 5, 20, 20, "hello,world", $background);
- //Write Chinese
- $str="PHP painting technology";
- imagettftext ($img , 30 , 0 , 50 ,50, $background , "MSYHBD.TTF" , $str);
- //Output the image to the web page (or save it as)
- header("content-type: image/png");
- imagepng ($img);
- //Destroy the image (release memory)
- imagedestroy($img);
- ?>
-
Copy code
|