Hi all
I am working on a php script that will produce css items that will produce a gradient background colour from left to right. I have a working example which I am trying to convert to a class, so I can call it where I need it.
As parameters to this class I pass the start colour and the stop colour. For each colour in the colour triplet, I calculate the difference, divide it by the necessarry width to get the gradient colour shift. This calculation is done in the __construct section of the class and ends with:
//Fill array with intermediate colour values
for ($i = 1; $i < $this->GradientWidth+1; $i += 1) {
$arrColours[$i][red] = round($this->Red1+($i * $this->RedShift),0);
$arrColours[$i][green] = round($this->Green1+($i * $this->GreenShift),0);
$arrColours[$i][blue] = round($this->Blue1+($i * $this->BlueShift),0); }
/* End of For-loop */
Now, in a function I define in the class (which will a method of the object once it is instantiated), I want to extract the individual colours and combine them into CSS items:
function fnCreateCSS() {
for ($i = 1; $i < $this->GradientWidth+1; $i += 1) {
$this->MyCSSItems2 .= <<<EOT
#d$i {background-color:rgb($this->arrColours[$i][red],$this->arrColours[$i][green],$this->arrColours[$i][blue])} <br>
EOT;
}
/* End of for loop */
echo("echo2 <br>".$this->MyCSSItems1."<br>echo 3");
}
/* End of fnCreateCSS */
But unfortunately, this coding of mine is not 100% correct: this is the output:
#d1 {background-color:rgb([1][red],[1][green],[1][blue])}
#d2 {background-color:rgb([2][red],[2][green],[2][blue])}
#d3 {background-color:rgb([3][red],[3][green],[3][blue])}
Where do I go wrong?
Is my coding to retrieve data from the array incorrect?
Is there an easy way to check if my routine to input data into the array has worked as intended?
In case you want to see more:
In Wrapper01.php I have created some html that will create an instance of the class.
In Include01.php is the coding for the class and everything around it.
O yeah: Wrapper expects Include in directory Systools.