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

# fill(using:)

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

```
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)