glassDistortion()
Distorts an image by applying a glass-like texture.
Declaration
class func glassDistortion() -> any CIFilter & CIGlassDistortionReturn 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:
inputImageAn image with the type CIImage.
textureAn image with the type CIImage.
scaleThe amount of texturing to apply. Larger values increase the effect. Defaults to 200.
centerA 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]