Contents

circularWrap()

Distorts an image by increasing the distance of the center of the image.

Declaration

class func circularWrap() -> any CIFilter & CICircularWrap

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

inputImage

An image with the type CIImage.

angle

A float representing the angle of the wrap, in radians, as an NSNumber.

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.

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]

See Also

Filters