rectToMobject method

VMobject rectToMobject(
  1. Element rectElement,
  2. SVGElementStyle style
)

Implementation

VMobject rectToMobject(Element rectElement, SVGElementStyle style) {
  var _cornerRadius = rectElement.attributes['rx'];
  var cornerRadius = attributeToDouble(_cornerRadius);

  VMobject mob;

  if (cornerRadius == 0.0) {
    mob = Rectangle(
      width: attributeToDouble(rectElement.attributes['width']),
      height: attributeToDouble(rectElement.attributes['height']),
    );
  } else {
    mob = RoundedRectangle(
      width: attributeToDouble(rectElement.attributes['width']),
      height: attributeToDouble(rectElement.attributes['height']),
      cornerRadius: cornerRadius,
    );
  }

  mob.shift(mob.getCenter() - mob.getCorner(UL));
  return applyStyle(style.update(getElementStyle(rectElement)), mob);
}