RoundedPolygon.rectangle constructor

RoundedPolygon.rectangle({
  1. double width = 2,
  2. double height = 2,
  3. CornerRounding rounding = CornerRounding.unrounded,
  4. List<CornerRounding>? perVertexRounding,
  5. double centerX = 0,
  6. double centerY = 0,
})

Implementation

factory RoundedPolygon.rectangle({
  double width = 2,
  double height = 2,
  CornerRounding rounding = CornerRounding.unrounded,
  List<CornerRounding>? perVertexRounding,
  double centerX = 0,
  double centerY = 0,
}) {
  final left = centerX - width / 2;
  final top = centerY - height / 2;
  final right = centerX + width / 2;
  final bottom = centerY + height / 2;

  return RoundedPolygon.fromVertices(
    [right, bottom, left, bottom, left, top, right, top],
    rounding: rounding,
    perVertexRounding: perVertexRounding,
    centerX: centerX,
    centerY: centerY,
  );
}