Contents

ninePartStretched()

Distorts an image by stretching it between two breakpoints.

Declaration

class func ninePartStretched() -> any CIFilter & CINinePartStretched

Return Value

The distorted image.

Discussion

This method applies the nine-part stretched filter to an image. This effect distorts an image by stretching an image to the breakpoint properties while distorting the image based on the grow amount.

The nine-part stretched filter uses the following properties:

inputImage

An image with the type CIImage.

growAmount

A CGPoint representing the amount of stretching applied.

breakpoint0

A CGPoint representing the lower-left corner of the image to retain before stretching begins.

breakpoint1

A CGPoint representing the upper-right corner of the image to retain after stretching ends.

The following code creates a filter that results in a significantly warped image:

func ninePartStretch(inputImage: CIImage) -> CIImage {
    let filter = CIFilter.ninePartStretched()
    filter.inputImage = inputImage
    filter.setDefaults()
    filter.breakpoint0 = CGPoint(x: 200, y: 200)
    filter.breakpoint1 = CGPoint(x: inputImage.extent.size.width-200, y: inputImage.extent.size.height - 200)
    filter.growAmount = CGPoint(x: 500, y: 500)
    return filter.outputImage!
}

[Image]

See Also

Filters