<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreImage",
  "identifier" : "/documentation/CoreImage/CIFilter-swift.class/checkerboardGenerator()",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Core Image",
      "CoreImage"
    ],
    "preciseIdentifier" : "c:objc(cs)CIFilter(cm)checkerboardGeneratorFilter"
  },
  "title" : "checkerboardGenerator()"
}
-->

# checkerboardGenerator()

Generates a checkerboard image.

```
class func checkerboardGenerator() -> any CIFilter & CICheckerboardGenerator
```

## Return Value

The generated image.

## Discussion

This method generates a checkerboard pattern as an image. The effect requires the size, sharpness, and color properties to create the pattern.

The checkerboard generator filter uses the following properties:

- `center`: A `vector` representing the center of the image as a [`CIVector`](/documentation/CoreImage/CIVector).
- `color0`: A [`CIColor`](/documentation/CoreImage/CIColor) representing the first color of the pattern.
- `color1`: A [`CIColor`](/documentation/CoreImage/CIColor) representing the second color of the pattern.
- `sharpness`: A `float` representing the sharpness of the pattern as an <doc://com.apple.documentation/documentation/Foundation/NSNumber>.
- `width`: A `float` representing the width of the checkerboard squares as an <doc://com.apple.documentation/documentation/Foundation/NSNumber>.

The following code creates a filter that generates a black-and-white checkered pattern:

```swift
func checkerBoard() -> CIImage {
    let checkerBoardGenerator = CIFilter.checkerboardGenerator()
    checkerBoardGenerator.setDefaults()
    checkerBoardGenerator.center = CGPoint(x: 0, y: 0)
    checkerBoardGenerator.color0 = .white
    checkerBoardGenerator.color1 = .black
    checkerBoardGenerator.width = 40
    checkerBoardGenerator.sharpness = 1
    return checkerBoardGenerator.outputImage!
}
```

![An image of small black-and-white squares repeating, creating a checkerboard pattern.](images/com.apple.coreimage/media-3590970@2x.png)

---

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)