holeDistortion()
Distorts an image with a circular area that pushes the image outward.
Declaration
class func holeDistortion() -> any CIFilter & CIHoleDistortionReturn Value
The distorted image.
Discussion
This method applies the hole distortion filter to an image. This effect distorts the image by generating a circular area that displaces pixels in the image by pushing them outward from the hole defined by the radius.
The absolute threshold filter uses the following properties:
inputImageAn image with the type CIImage.
centerA set of coordinates marking the center of the image as a CGPoint.
radiusA
floatrepresenting the amount of pixels the filter uses to create the distortion as an NSNumber.
The following code creates a filter that results in an image becoming distorted from the center outward:
func holeDistortion(inputImage: CIImage) -> CIImage {
let filter = CIFilter.holeDistortion()
filter.inputImage = inputImage
filter.radius = 300
filter.center = CGPoint(x: 1791, y: 1344)
return filter.outputImage!
}[Image]