xStart = $x1; $this->xEnd = $x2; $this->yStart = $y1; $this->yEnd = $y2; } /** * Create the SVG representation from this Drawable * * @param RenderContext $ctx The context to use for rendering * @return DOMElement The SVG Element */ public function toSvg(RenderContext $ctx) { $doc = $ctx->getDocument(); list($x1, $y1) = $ctx->toAbsolute($this->xStart, $this->yStart); list($x2, $y2) = $ctx->toAbsolute($this->xEnd, $this->yEnd); $line = $doc->createElement('line'); $line->setAttribute('x1', Format::formatSVGNumber($x1)); $line->setAttribute('x2', Format::formatSVGNumber($x2)); $line->setAttribute('y1', Format::formatSVGNumber($y1)); $line->setAttribute('y2', Format::formatSVGNumber($y2)); $id = $this->id ?? uniqid('line-'); $line->setAttribute('id', $id); $this->setId($id); $this->applyAttributes($line); $style = new DOMDocument(); $style->loadHTML($this->getStyle()); $line->appendChild( $line->ownerDocument->importNode( $style->getElementsByTagName('style')->item(0), true ) ); return $line; } }