I got caught out on this too. The Ros Pdf system takes floating-point
colour values, from 0.0 to 1.0.

So for red (#FF0000) you'd say

$this->setColor(1.0, 0.0, 0.0);

and for Cosmic Latte #FFF8E7 or rgb(255, 248, 231) you'd say:

$this->setColor(255/255, 248/255, 231/255);

I've overridden the Pdf class to handle colours nicer:
http://bin.cakephp.org/view/35237595


On 2 Aug, 13:25, Unite <[EMAIL PROTECTED]> wrote:
> Dunno if anyone knows here but there proberbaly are lots of people who
> do know or used it before.
>
> My problem is that $this->setColor function from a pdf helper isnt
> doing what its ment to do. Sometimes it will give the "graphics" a
> colour other times will ignore it and remain white.
>
> Heres a snipit of the code
>
> $this->html2rgb works and has been tested returning 3 values for R G
> and B from a HTML hash value.
> even when I say $this->setColor(100,100,100,1); the colour doesnt
> change.
>
> Basically is there something to reset or iniate the pallete or
> setColour that I am supposed to call?
>
> function ezDrawBox($x,$y,$xx,$yy, $data = array(), $values = array())
> {
>         $size=10;
>         $height = $this->getFontHeight($size);
>         $width = 0;
>         $y=800-$y;
>
>         if(!empty($data['bg_colour'])) {
>                 $rgb = $this->html2rgb($data['bg_colour']);
>                 $this->setColor($rgb[0],$rgb[1],$rgb[2],1);
>                 $this->filledRectangle($x,$y+$height,$xx,-$yy-$height);
>
>         }
>         if(!empty($data['box_name'])) {
>                 $rgb = $this->html2rgb($data['border_colour']);
>                 $this->setColor($rgb[0],$rgb[1],$rgb[2],1);
>                 $width = $this->getTextWidth($size+1,$data['box_name']);
>                 $this->addText($x+5,$y+9,$size+1,$data['box_name']);
>         }
>         if($data['hasborder'] == "Yes") {
>                 $rgb = $this->html2rgb($data['border_colour']);
>                 $this->setStrokeColor($rgb[0],$rgb[1],$rgb[2]);
>                 $this->line($x,$y+$height,$x, $y-$yy);
>                 $this->line($x,$y+$height,$x+5,$y+$height);
>                 $this->line($x+5+$width,$y+$height,$x+$xx,$y+$height);
>                 $this->line($x+$xx,$y+$height,$x+$xx, $y-$yy);
>                 $this->line($x,$y-$yy,$x+$xx,$y-$yy);
>         }
>
>         $rgb = $this->html2rgb($data['font_colour']);
>         $this->setColor($rgb[0],$rgb[1],$rgb[2],1);
>
>         for($i=0;$i<$data['amt_fields'];$i++)
>                 if(!empty($data['field'.$i])) 
> $this->addText($x+2,($y-5)-($i*9),
> $size,$data['field'.$i]);
>
> }


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to