circularWrap()
Distorts an image by increasing the distance of the center of the image.
Declaration
class func circularWrap() -> any CIFilter & CICircularWrapReturn Value
The distorted image.
Discussion
This method applies the circular wrap filter to an image. This effect wraps an image around a transparent circle. The distortion of the image increases with the distance from the center of the circle.
The circular wrap filter uses the following properties:
inputImageAn image with the type CIImage.
angleA
floatrepresenting the angle of the wrap, in radians, as an NSNumber.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.
The following code creates a filter that results in a circular image generated from the input image:
func circularWrap(inputImage: CIImage) -> CIImage { let filter = CIFilter.circularWrap()
filter.inputImage = inputImage
filter.center = CGPoint(
x: inputImage.extent.size.width/2,
y: inputImage.extent.size.height/2
)
filter.angle = .pi
filter.radius = 90
return filter.outputImage!
}
let text = CIFilter.textImageGenerator()
text.text = "Core Image"
text.fontSize = 100
text.fontName = "Chalkboard"
text.outputImage!
circularWrap(inputImage: text.outputImage!)[Image]