<!--
{
  "availability" : [
    "macOS: 10.9.0 -",
    "swift: 4.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/Sequence/fill(using:)-45en6",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:ST6AppKitSo6CGRectV_So7NSColorCt7ElementRtzrlE4fill5usingySo22NSCompositingOperationV_tF"
  },
  "title" : "fill(using:)"
}
-->

# fill(using:)

Fills this list of rects in the current NSGraphicsContext with that rect’s
associated color
The compositing operation of the fill defaults to the context’s
compositing operation, not necessarily using `.copy` like `NSRectFill()`.

```
func fill(using operation: NSCompositingOperation = NSGraphicsContext.current?.compositingOperation ?? .sourceOver)
```

## Discussion> precondition: There must be a set current NSGraphicsContext.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)