Page 553 - Beginning PHP 5.3
P. 553

Chapter 17:  Generating Images with PHP


                           Drawing Circles and Ellipses
                           To draw circles and ellipses in PHP, use the  imageellipse()  function. It works differently from
                          the   imagerectangle()  and  imageline()  functions, in that you do not provide the outer limits of the
                         shape. Rather, you describe an ellipse by providing its center point, and then specifying how high and
                         how wide the ellipse should be.

                          Here ’ s an example:

                             imageellipse( $myImage, 90, 60, 160, 50, $myBlack );

                           This ellipse, shown in Figure 17 - 8, has its center on the pixel at (90,60). The width of the ellipse is 160
                         pixels and the height is 50 pixels.

                           To draw a circle, simply describe an ellipse that has the same width and height (see Figure 17 - 9):


                             imageellipse( $myImage, 90, 60, 70, 70, $myBlack );










                                                   Figure 17-8












                                                       Figure 17-9

                           Drawing an Arc
                           An arc is a partial ellipse  —  one that doesn ’ t join up. To draw an arc, you call the  imagearc()  function.

                           You describe an arc in the same way as an ellipse, except that you need to add two arguments to describe
                         where the arc starts and ends. You specify the start and end points in degrees (there are 360 degrees in a











                                                                                                         515





                                                                                                      9/21/09   2:48:39 PM
          c17.indd   515                                                                              9/21/09   2:48:39 PM
          c17.indd   515
   548   549   550   551   552   553   554   555   556   557   558