Contents

twirlDistortion()

Distorts an image by rotating pixels around a center point.

Declaration

class func twirlDistortion() -> any CIFilter & CITwirlDistortion

Return 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:

inputImage

An image with the type CIImage.

radius

A float representing the amount of pixels the filter uses to create the distortion as an NSNumber.

center

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

angle

A float representing 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]

See Also

Filters