---
title: "addRects(_:transform:)"
framework: coregraphics
role: symbol
role_heading: Instance Method
path: "coregraphics/cgmutablepath/addrects(_:transform:)"
---

# addRects(_:transform:)

Adds a set of rectangular subpaths to the path.

## Declaration

```swift
func addRects(_ rects: [CGRect], transform: CGAffineTransform = .identity)
```

## Parameters

- `rects`: An array of rectangles, specified in user space coordinates.
- `transform`: An affine transform to apply to the rectangles before adding to the path. Defaults to the identity transform if not specified.

## Discussion

Discussion Calling this convenience method is equivalent to repeatedly calling the addRect(_:transform:) method for each rectangle in the array.

## See Also

### Constructing a Graphics Path

- [move(to:transform:)](coregraphics/cgmutablepath/move(to:transform:).md)
- [addLine(to:transform:)](coregraphics/cgmutablepath/addline(to:transform:).md)
- [addLines(between:transform:)](coregraphics/cgmutablepath/addlines(between:transform:).md)
- [addRect(_:transform:)](coregraphics/cgmutablepath/addrect(_:transform:).md)
- [addEllipse(in:transform:)](coregraphics/cgmutablepath/addellipse(in:transform:).md)
- [addRoundedRect(in:cornerWidth:cornerHeight:transform:)](coregraphics/cgmutablepath/addroundedrect(in:cornerwidth:cornerheight:transform:).md)
- [addArc(center:radius:startAngle:endAngle:clockwise:transform:)](coregraphics/cgmutablepath/addarc(center:radius:startangle:endangle:clockwise:transform:).md)
- [addArc(tangent1End:tangent2End:radius:transform:)](coregraphics/cgmutablepath/addarc(tangent1end:tangent2end:radius:transform:).md)
- [addRelativeArc(center:radius:startAngle:delta:transform:)](coregraphics/cgmutablepath/addrelativearc(center:radius:startangle:delta:transform:).md)
- [addCurve(to:control1:control2:transform:)](coregraphics/cgmutablepath/addcurve(to:control1:control2:transform:).md)
- [addQuadCurve(to:control:transform:)](coregraphics/cgmutablepath/addquadcurve(to:control:transform:).md)
- [addPath(_:transform:)](coregraphics/cgmutablepath/addpath(_:transform:).md)
- [closeSubpath()](coregraphics/cgmutablepath/closesubpath().md)
