In accordance with the concepts that I expressed in the previous section, the GD library also offers a powerful set of functions for drawing basic shapes, such as ellipses, rectangles, and other polygons. However, for now, I'm going to show you only a couple of these functions, which in this case are responsible for displaying some simple ellipses on a given image stream. That being said, here's an example that shows how to use the brand new "imageellipse()" function to display this shape on the browser. The corresponding code sample is as follows: // example of 'imageellipse()' function try{ } As you can see, the above "imagellipse()" function is indeed very easy to grasp. It takes up as its incoming arguments an image stream resource, and them the corresponding start and end coordinates of the ellipse in question, and finally the color to be used with this shape. Based upon the signature of the previous code sample, here's the output that it displays on the browser:
In addition, the GD extension offers the "imagefilledellipse()" function, which behaves very similarly to the one that you learned before. In this case, however, it draws a filled ellipse on a specific image stream. Given that, a basic implementation for this function is shown below: // example of 'imagefilledellipse()' function try{ } As you can see, the above "imagefilledellipse()" function is nearly identical to its counterpart "imageellipse()." However, it displays a filled ellipse on a specified image stream, as clearly illustrated by the below image:
All right, at this stage hopefully you have a much better idea of how to draw some basic shapes by using the functions that come bundled with the GD extension. For now, I recommend that you use the source code of all the examples shown here to improve your skills with using this powerful graphical library. Final thoughts In this third part of the series, I stepped you through using some of the most useful functions included with the GD library to display some basic string characters, on the browser, as well as a few simple arcs and ellipses. In the next tutorial, things will get even more interesting, since I'll teach you how to draw many other shapes by using the functionality provided by the GD extension. Now that you've been warned, you won't want to miss it!
blog comments powered by Disqus |
|
|
|
|
|
|
|