SPath.rect constructor

SPath.rect({
  1. required Point<double> at,
  2. required Size size,
  3. bool centered = false,
})

A rectangle shape

Implementation

SPath.rect(
    {required Point<double> at, required Size size, bool centered = false}) {
  if (centered) {
    final dX = size.width / 2;
    final dY = size.height / 2;
    currentPoint = at + Point(-dX, -dY);
    line(to: at + Point(dX, -dY));
    line(to: at + Point(dX, dY));
    line(to: at + Point(-dX, dY));
    close();
  } else {
    currentPoint = at;
    line(to: at + Point(size.width, 0));
    line(to: at + Point(size.width, size.height));
    line(to: at + Point(0, size.height));
    close();
  }
}