---
title: "floodFill(from:newColor:connectivity:)"
framework: accelerate
role: symbol
role_heading: Instance Method
path: "accelerate/vimage/pixelbuffer/floodfill(from:newcolor:connectivity:)-219lg"
---

# floodFill(from:newColor:connectivity:)

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

## Declaration

```swift
func floodFill(from seed: CGPoint, newColor: Pixel_16U, 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 doc://com.apple.accelerate/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 doc://com.apple.accelerate/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

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 unsigned 16-bit planar pixel buffer and uses the image’s center pixel as the seed. // `pixelBuffer` is a `vImage.PixelBuffer<vImage.Planar16U>`.

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:

## See Also

### Related Documentation

- [Applying flood fills to an image](accelerate/applying-flood-fills-to-an-image.md)

### Applying a flood fill to an image

- [floodFill(from:newColor:connectivity:)](accelerate/vimage/pixelbuffer/floodfill(from:newcolor:connectivity:)-44z7t.md)
- [floodFill(from:newColor:connectivity:)](accelerate/vimage/pixelbuffer/floodfill(from:newcolor:connectivity:)-56w4b.md)
- [floodFill(from:newColor:connectivity:)](accelerate/vimage/pixelbuffer/floodfill(from:newcolor:connectivity:)-6hsrg.md)
