Contents

rippleTransition()

Simulates a ripple in a pond to transiton from one image to another.

Declaration

class func rippleTransition() -> any CIFilter & CIRippleTransition

Return Value

The transition image.

Discussion

This method applies the ripple transition filter to an image. The effect transitions from one image to another by creating a circular wave that expands from the center point, revealing the target image through the wave effect.

The ripple transition filter uses the following properties:

inputImage

The starting image with the type CIImage.

targetImage

The ending image with the type CIImage.

center

A set of coordinates marking the center of the image as a CGPoint.

width

A float representing the width of the ripple effect as an NSNumber.

extent

A CGRect representing the size of the ripple effect.

scale

A float representing the scale of the effect as an NSNumber.

time

A float representing the parametric time of the transition from start (at time 0) to end (at time 1) as an NSNumber.

The following code creates a filter that transitions from the input image to the target image with a water-like ripple effect.

func ripple (inputImage: CIImage, targetImage: CIImage) -> CIImage {
    let rippleTransition = CIFilter.rippleTransition()
    rippleTransition.inputImage = inputImage
    rippleTransition.targetImage = targetImage
    rippleTransition.center = CGPoint(x: 250, y: 150)
    rippleTransition.width = 100
    rippleTransition.extent = CGRect(x: 54, y: 80, width: 300, height: 300)
    rippleTransition.scale = 22
    rippleTransition.time = 0.3
    return rippleTransition.outputImage!
}

[Image]

See Also

Filters