Contents

holeDistortion()

Distorts an image with a circular area that pushes the image outward.

Declaration

class func holeDistortion() -> any CIFilter & CIHoleDistortion

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

inputImage

An image with the type CIImage.

center

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

radius

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

See Also

Filters