---
title: CGContextAddRects
framework: coregraphics
role: symbol
role_heading: Function
path: coregraphics/cgcontextaddrects
---

# CGContextAddRects

Adds a set of rectangular paths to the current path.

## Declaration

```occ
extern void CGContextAddRects(CGContextRef c, const CGRect *rects, size_t count);
```

## Parameters

- `c`: A graphics context.
- `rects`: An array of rectangles, specified in user space coordinates.
- `count`: The number of rectangles in the rects array.

## Discussion

Discussion This is a convenience function that adds an array of rectangles to a path, as if it called addRect(_:) for each rectangle.

## See Also

### Constructing a Current Graphics Path

- [beginPath()](coregraphics/cgcontext/beginpath().md)
- [CGContextMoveToPoint](coregraphics/cgcontextmovetopoint.md)
- [CGContextAddLineToPoint](coregraphics/cgcontextaddlinetopoint.md)
- [CGContextAddLines](coregraphics/cgcontextaddlines.md)
- [addRect(_:)](coregraphics/cgcontext/addrect(_:).md)
- [addEllipse(in:)](coregraphics/cgcontext/addellipse(in:).md)
- [CGContextAddArc](coregraphics/cgcontextaddarc.md)
- [CGContextAddArcToPoint](coregraphics/cgcontextaddarctopoint.md)
- [CGContextAddCurveToPoint](coregraphics/cgcontextaddcurvetopoint.md)
- [CGContextAddQuadCurveToPoint](coregraphics/cgcontextaddquadcurvetopoint.md)
- [addPath(_:)](coregraphics/cgcontext/addpath(_:).md)
- [closePath()](coregraphics/cgcontext/closepath().md)
- [path](coregraphics/cgcontext/path.md)
- [replacePathWithStrokedPath()](coregraphics/cgcontext/replacepathwithstrokedpath().md)
