Drawing a transparent rectangle around a part of an image
Posted: 2007-03-27T02:53:04-07:00
Hi, I am creating a graph (first time I'm using PHP's MagickWand - serious lack in tutorials online!) and I need to draw a frame around the graph
The code I have used to do this is (snippet):
How would I draw a transparent rectangle around the line graph (not around the entire image) ?
Also, if anyone can tell me why some of the lines are darker than the others or if I have done anything wrong here please that would be appreciated.
Thanks
The code I have used to do this is (snippet):
Code: Select all
<?php
$drawing=NewDrawingWand();
DrawSetStrokeWidth($drawing,0);
DrawSetStrokeLineCap($drawing, MW_RoundCap);
DrawSetStrokeLineJoin($drawing, MW_RoundJoin);
DrawSetFillOpacity($drawing,1);
DrawSetFont($drawing,"verdana.ttf");
DrawSetFontSize($drawing,8);
DrawSetStrokeAlpha($drawing,1);
$pixel = NewPixelWand();
// highlight today
PixelSetColor($pixel, 'grey');
DrawSetFillColor($drawing, $pixel);
DrawRectangle($drawing, $this->diagramWidth / 2, 0, (($this->diagramWidth / $this->daysToShow) * ($this->daysToShow / 2 + 1)), $this->diagramHeight - 40);
PixelSetColor($pixel, 'black');
DrawSetFillColor($drawing, $pixel);
for ($i = 1; $i < $this->daysToShow; $i++) {
$thisDate = getDate($diagramDate);
$xCoord = ($this->diagramWidth / $this->daysToShow) * $i;
// draw day mark and day number
DrawLine($drawing, $xCoord, $this->diagramHeight - 40, $xCoord, 0);
DrawAnnotation($drawing, $xCoord - 5, $this->diagramHeight - 29, $thisDate["mday"]);
$diagramDate += $nrSecondsPerDay;
}
// draw middle cross - y axis
DrawLine($drawing, 0, ($this->diagramHeight - 40) / 2, $this->diagramWidth, ($this->diagramHeight - 40) / 2);
?>
Also, if anyone can tell me why some of the lines are darker than the others or if I have done anything wrong here please that would be appreciated.
Thanks