Contents

perspectiveRotate()

Rotates an image in a 3D space.

Declaration

class func perspectiveRotate() -> any CIFilter & CIPerspectiveRotate

Return Value

The adjusted image.

Discussion

This method applies the perspective rotate filter to an image. The effect rotates the image in 3D space to simulate the observer changing viewing position.

The perspective rotate filter uses the following properties:

inputImage

An image with the type CIImage.

pitch

A float representing the adjustment along the pitch axis in 3D space as an NSNumber.

yaw

A float representing the adjustment along the vertical axis as an NSNumber.

roll

A float representing the amount of horizontal axis in 3D space as an NSNumber.

focalLength

A float representing the simulated focal length as an NSNumber.

The following code creates a filter that rotates the image:

func perspectiveRotate(inputImage: CIImage) -> CIImage {
    let perspectiveRotateFilter = CIFilter.perspectiveRotate()
    perspectiveRotateFilter.inputImage = inputImage
    perspectiveRotateFilter.pitch = 0
    perspectiveRotateFilter.yaw = 0.1
    perspectiveRotateFilter.roll = 0.3
    perspectiveRotateFilter.focalLength = 18
    return perspectiveRotateFilter.outputImage!
}

[Image]

See Also

Filters