As I explained in the beginning of this article, the initial structure of this image generator class will be rather simplistic. It will be composed of only two basic methods (except for the corresponding constructor), called "buildImageStream()" and "displayImage()" respectively. Obviously, as these names suggest, the first one will be tasked with building dynamically an image stream, while the second one will output it on the browser using a specific graphic format. Having said that, here's the basic signature of this image generator class. Have a look at it, please: // define 'ImageGenerator' class class ImageGenerator{ private $width; private $height; private $bgColor; private $textColor; private $inputString; private $img; // initialize input arguments public function __construct($inputString='Default Input String',$width=400,$height=300,$bgColor='0,0,0', $this->inputString=$inputString; $this->width=$width; $this->height=$height; $this->bgColor=explode(',',$bgColor); $this->textColor=explode(',',$textColor); $this->buildImageStream(); } // create image stream private function buildImageStream(){ // implementation for this private method goes here // display image stream on the browser public function displayImage(){ // implementation for this public method goes here } } As you can see, the definition of the above "ImageGenerator" class is very easy to follow, even though it's still incomplete. First, you may notice that the constructor takes up a few simple incoming parameters. These include the corresponding input string that will be embedded in the graphic output, and then the dimensions of the image stream being generated, and finally the foreground and background colors. Additionally, it's clear to see that the constructor also calls the private "buildImageStream()" method from inside its context. This will come in handy for generating the respective dynamic image stream on the fly, based upon the pertinent input arguments. However, for the sake of clarity, the implementation of this method and the "displayImage()" method will be covered in detail in the section to come. Thus, if you're interested in learning how these brand new methods that belong to the image generator class will be defined, please jump ahead and read the next few lines. I'll be there, waiting for you.
blog comments powered by Disqus |
|
|
|
|
|
|
|