<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Accelerate",
  "identifier" : "/documentation/Accelerate/vImage/PixelBuffer/floodFill(from:newColor:connectivity:)-44z7t",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "s:10Accelerate6vImageO11PixelBufferVAaC7Planar8VRszrlE9floodFill4from8newColor12connectivityySo7CGPointV_s5UInt8VAC05FloodG12ConnectivityOtF"
  },
  "title" : "floodFill(from:newColor:connectivity:)"
}
-->

# floodFill(from:newColor:connectivity:)

Applies an in-place flood-fill operation to the 8-bit planar image.

```
func floodFill(from seed: CGPoint, newColor: Pixel_8, connectivity: vImage.FloodFillConnectivity)
```

## Parameters

`seed`

The coordinates that define the position of the seed pixel inside the connected component.

`newColor`

The new pixel value that overwrites the pixels in the connected component.

`connectivity`

An enumeration that specifies which pixels the operation includes as neighbors. Pass [`vImage.FloodFillConnectivity.edges`](/documentation/Accelerate/vImage/FloodFillConnectivity/edges) to specify a four-connected neighborhood of a pixel that includes the pixels to the left and right, and those above and below. Pass [`vImage.FloodFillConnectivity.edgesAndCorners`](/documentation/Accelerate/vImage/FloodFillConnectivity/edgesAndCorners) to specify an eight-connected neighborhood that includes the four-connected neighborhood and the pixels on the four diagonals.

## Discussion

The flood-fill function sets all pixels that are neighboring and identical to the seed pixel to a new color. The operation continues until it reaches the image boundary or until it sets all pixels within the connected component to the new value.

The following code applies a flood fill to an 8-bit planar pixel buffer and uses the image’s center pixel as the seed.

```swift
// `pixelBuffer` is a `vImage.PixelBuffer<vImage.Planar8>`.

pixelBuffer.floodFill(from: CGPoint(x: pixelBuffer.width / 2,
                                    y: pixelBuffer.height / 2),
                      newColor: fillColor,
                      connectivity: .edgesAndCorners)
```

The image below shows the original line-art image on the left, and the flood-filled image on the right:

![Two versions of a line drawing of a star. On the left is the original outline drawing of a star, and on the right is the same star but flood-filled with a solid color.](images/com.apple.accelerate/media-4165184@2x.png)

## See Also

  <doc://com.apple.accelerate/documentation/Accelerate/applying-flood-fills-to-an-image>



---

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)