setPos method

void setPos(
  1. Offset tl
)

Implementation

void setPos(Offset tl) {
  if (!isReady()) return;

  final Offset br =
      tl + Offset(rect.width.toDouble(), rect.height.toDouble());
  int left = tl.dx.toInt();
  int right = br.dx.toInt();
  int top = tl.dy.toInt();
  int bottom = br.dy.toInt();

  final int stkWidCenter = innerRectStrokeWidth ~/ 2;
  if (tl.dx < stkWidCenter || br.dx > imageWidth - stkWidCenter) {
    left = rect.x1;
    right = rect.x2;
  }

  if (tl.dy < stkWidCenter || br.dy > imageHeight - stkWidCenter) {
    top = rect.y1;
    bottom = rect.y2;
  }

  rect = Region(
      x1: left.toInt(),
      y1: top.toInt(),
      x2: right.toInt(),
      y2: bottom.toInt());
}