Contents

glassDistortion()

Distorts an image by applying a glass-like texture.

Declaration

class func glassDistortion() -> any CIFilter & CIGlassDistortion

Return Value

The distorted image.

Discussion

This method applies the glass distortion filter to an image. This effect distorts an image by applying a glass texture from the raised portions of the texture map image.

The glass distortion filter uses the following properties:

inputImage

An image with the type CIImage.

texture

An image with the type CIImage.

scale

The amount of texturing to apply. Larger values increase the effect. Defaults to 200.

center

A set of coordinates marking the center of the image as a CGPoint.

The following code creates a filter that results in a glass-like distortion applied to the image:

func glassDistortion(inputImage: CIImage, textureImage: CIImage) -> CIImage {
    let filter = CIFilter.glassDistortion()
    filter.inputImage = inputImage
    filter.textureImage = textureImage
    filter.center = CGPoint(x: 1791, y: 1344)
    filter.scale = 500
    return filter.outputImage!
}

[Image]

See Also

Filters