lightTunnel()
Distorts an image by generating a light tunnel.
Declaration
class func lightTunnel() -> any CIFilter & CILightTunnelReturn Value
The distorted image.
Discussion
This method applies the light tunnel filter to an image. This effect distorts the input image by warping the image to cylinder shape.
The light tunnel filter uses the following properties:
inputImageAn image with the type CIImage.
centerA set of coordinates marking the center of the light tunnel as a CGPoint.
radiusA
floatrepresenting the amount of pixels the filter uses to create the light tunnel as an NSNumber.- rotation
A
floatrepresenting the rotation angle of the light tunnel as an NSNumber.
The following code creates a filter that generates a swirling pattern from the input image:
func lightTunnel(inputImage: CIImage) -> CIImage {
let filter = CIFilter.lightTunnel()
filter.inputImage = inputImage
filter.radius = 100
filter.rotation = .pi
filter.center = CGPoint(
x: inputImage.extent.width / 2,
y: inputImage.extent.size.height / 2
)
return filter.outputImage!.cropped(to: inputImage.extent)
}[Image]