fromEllipse static method

XmlElement fromEllipse(
  1. XmlElement ellipseTag
)

Converts a ellipse element into a path element.

Implementation

static XmlElement fromEllipse(XmlElement ellipseTag) {
  final filterAttributes = [
    AttributeName.cx,
    AttributeName.cy,
    AttributeName.rx,
    AttributeName.ry,
  ];

  final cx = _getAttribute(ellipseTag, AttributeName.cx);
  final cy = _getAttribute(ellipseTag, AttributeName.cy);
  final rx = _getAttribute(ellipseTag, AttributeName.rx);
  final ry = _getAttribute(ellipseTag, AttributeName.ry);
  final cdx = rx * _kappa;
  final cdy = ry * _kappa;

  return _buildPath(
    'M $cx ${_c(cy - ry)} '
    'C ${_c(cx + cdx)} ${_c(cy - ry)} ${_c(cx + rx)} ${_c(cy - cdy)} ${_c(cx + rx)} $cy '
    'C ${_c(cx + rx)} ${_c(cy + cdy)} ${_c(cx + cdx)} ${_c(cy + ry)} $cx ${_c(cy + ry)} '
    'C ${_c(cx - cdx)} ${_c(cy + ry)} ${_c(cx - rx)} ${_c(cy + cdy)} ${_c(cx - rx)} $cy '
    'C ${_c(cx - rx)} ${_c(cy - cdy)} ${_c(cx - cdx)} ${_c(cy - ry)} $cx ${_c(cy - ry)} '
    'Z',
    ellipseTag,
    filterAttributes,
  );
}