Contents

checkerboardGenerator()

Generates a checkerboard image.

Declaration

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.

color0

A CIColor representing the first color of the pattern.

color1

A CIColor representing the second color of the pattern.

sharpness

A float representing the sharpness of the pattern as an NSNumber.

width

A float representing the width of the checkerboard squares as an NSNumber.

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

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!
}

[Image]

See Also

Filters