strokeRect method

  1. @override
void strokeRect(
  1. num x,
  2. num y,
  3. num width,
  4. num height,
  5. PStyle style,
)
override

Stroke a rectangle (x,y , width x height).

Implementation

@override
void strokeRect(num x, num y, num width, num height, PStyle style) {
  x = transform.x(x);
  y = transform.y(y);

  var clip = _clip;
  if (clip != null) {
    var box = PRectangle(x, y, width, height);
    var r = clip.intersection(box);
    if (r.isZeroDimension) return;

    x = r.x;
    y = r.y;
    width = r.width;
    height = r.height;
  }

  if (width <= 0 || height <= 0) return;

  var color = style.color ?? PColor.colorGrey;
  var size = style.size ?? 1;

  var x1 = x.toInt();
  var y1 = y.toInt();

  var x2 = x1 + width.toInt();
  var y2 = y1 + height.toInt();

  _strokeRect(_bitmap, x1, y1, x2, y2, color.imageColor, thickness: size);
}