twirlDistortion()
Distorts an image by rotating pixels around a center point.
Declaration
class func twirlDistortion() -> any CIFilter & CITwirlDistortionReturn Value
The distorted image.
Discussion
This method applies the twirl distortion filter to an image. This effect distorts an image by rotating pixels around the defined center to create a twirling effect. You can specify the number of rotations to control the strength of the effect.
The twirl distortion filter uses the following properties:
inputImageAn image with the type CIImage.
radiusA
floatrepresenting the amount of pixels the filter uses to create the distortion as an NSNumber.centerA set of coordinates marking the center of the image as a CGPoint.
angleA
floatrepresenting the angle of the twirl, in radians, as an NSNumber.
The following code creates a filter that results in the center of the image becoming twirled:
func twirlDistort(inputImage: CIImage) -> CIImage {
let filter = CIFilter.twirlDistortion()
filter.inputImage = inputImage
filter.radius = 600
filter.angle = 3.141592653589793
filter.center = CGPoint(x: 1791, y: 1344)
return filter.outputImage!
}[Image]