Hello,
I have a class that I have been using but now I would like to modify it slightly but I am having a few problems. It is a simple image class.
Here is my working code..
class ImgClass {
function init($imgWidth,$imgHeight) {
$this->Chart_Max_Width = $imgWidth;
$this->Chart_Max_Height = $imgHeight;
$this->im = imagecreatetruecolor($this->Chart_Max_Width, $this->Chart_Max_Height);
}
function preLoadColours() {
$this->colour_Snow = ImageColorAllocate($this->im, 255, 250, 250);
$this->colour_Snow2 = ImageColorAllocate($this->im, 238, 233, 233);
$this->colour_Snow3 = ImageColorAllocate($this->im, 205, 201, 201);
$this->colour_Snow4 = ImageColorAllocate($this->im, 139, 137, 137);
}
function setBG() {
imagefilledrectangle($this->im, 0, 0, $this->Chart_Max_Width, $this->Chart_Max_Height, $this->colour_Snow4);
}
function outputimg() {
//Output the image
header ("Content-type: image/png");
imagepng ($this->im,Null,0);
}
}
$g=new ImgClass;
$g->init(600,400);
$g->preLoadColours();
$g->setBG();
$g->outputimg();
So the above code will create a 600x400 image and paint the background as colour_Snow4
What I would like to do is supply the BG colour when calling the function setBG, this will give me more flexability.
I tried using $g->setBG(colour_Snow2) and $g->setBG(this->colour_Snow2) but this does not work.
Is there a way I can call the colour?
Thanks