Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | import SVG from 'svg.js' import { renderDataToSvgPath } from '../util' import Display from './display' export default class SvgDisplay extends Display { constructor(transitive) { super(transitive) const { el } = transitive.options // TODO: handle case of externally-provided SVG? // We have a DOM element if (el) { this.setDimensions(el.clientWidth, el.clientHeight) this.svg = SVG(el) } } clear() { this.svg.clear() } drawRect(upperLeft, attrs) { this.svg.rect().move(upperLeft.x, upperLeft.y).attr(attrs) } drawCircle(center, attrs) { this.svg.circle().move(center.x, center.y).attr(attrs) } drawEllipse(center, attrs) { this.svg.ellipse().move(center.x, center.y).attr(attrs) } drawPath(renderData, attrs) { this.svg.path(renderDataToSvgPath(renderData)).attr(attrs) } drawText(text, anchor, attrs) { this.svg.text(text).move(anchor.x, anchor.y).attr(attrs) } } |