Contents

gaussianGradient()

Generates a gradient that varies from one color to another using a Gaussian distribution.

Declaration

class func gaussianGradient() -> any CIFilter & CIGaussianGradient

Return Value

The generated image.

Discussion

This method generates a Gaussian gradient image. The effect uses the Gaussian kernel to calculate the even dispersal of the first color in the center to the second color in the image’s periphery.

The Gaussian gradient filter uses the following properties:

center

A CGPoint representing the center of the effect as x and y coordinates.

color0

A CIColor representing the first color to use in the gradient.

color1

A CIColor representing the second color to use in the gradient.

radius

A float representing the radius of the Gaussian distribution as an NSNumber.

The following code creates a filter that generates a gradient image:

func gaussian() -> CIImage {
    let gaussianGradient = CIFilter.gaussianGradient()
    gaussianGradient.center = CGPoint (x: 150, y: 150)
    gaussianGradient.color0 = CIColor(red: 88/255, green: 201
/255, blue: 175/255)
    gaussianGradient.color1 = CIColor(red: 153/255, green: 153/255, blue: 204/255)
    gaussianGradient.radius = 10
    return gaussianGradient.outputImage!
}

[Image]

See Also

Filters