addRect method

void addRect(
  1. AABB r,
  2. Mat2D xform,
  3. PathDirection dir
)

Implementation

void addRect(AABB r, Mat2D xform, PathDirection dir) {
  final p0 = xform * Vec2D.fromValues(r.left, r.top);
  final p1 = xform * Vec2D.fromValues(r.right, r.top);
  final p2 = xform * Vec2D.fromValues(r.right, r.bottom);
  final p3 = xform * Vec2D.fromValues(r.left, r.bottom);

  move(p0);
  if (dir == PathDirection.clockwise) {
    line(p1);
    line(p2);
    line(p3);
  } else {
    assert(dir == PathDirection.counterclockwise);
    line(p3);
    line(p2);
    line(p1);
  }
  close();
}