public drawClippingPolygon ( array $points ) : |
||
$points | array | |
Результат |
public function drawClippingPolygon($points)
{
$this->curClippingPath = count($this->clippingPaths);
$defs = $this->resource->addChild('defs');
$clip = $defs->addChild('clipPath');
$clip->addAttribute('id', 'clip' . $this->curClippingPath);
$formattedPoints = array();
foreach ($points as $point) {
$formattedPoints[] = $point['x'] . ',' . $point['y'];
}
$poly = $clip->addChild('polygon');
$poly->addAttribute('points', implode(' ', $formattedPoints));
return $this;
}
public function testAddClippingPolygon() { $points = array(array('x' => 320, 'y' => 50), array('x' => 400, 'y' => 100), array('x' => 420, 'y' => 200), array('x' => 280, 'y' => 320), array('x' => 200, 'y' => 180)); $s = new Svg('graph.svg', '640px', '480px'); $s->drawClippingPolygon($points)->setClippingPath(0); $this->assertEquals(640, $s->getWidth()); }